// The vault's kept flow (`SettingsKeptFlows.unlockVault`): the device's// prompt, then the unwrap. Driven through `ScriptedCore` and a key held in// memory, never the Keychain. Every value here is invented.importCottonKitimportFoundationimport XCTest@testable importCottonUIfinalclassConnectedActionsTests: XCTestCase {/// The kept flow the page runs: the device's prompt, then the unwrap. A/// cancel is said plainly and nothing is tried again. @MainActorfunc testTheVaultFlowOpensTheVaultOrSaysWhyNot() asyncthrows {// A scalar and the public half derived from it — the pair// `SecretPageTests` pins. Not a key anything holds.let scalar = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8"let publicHalf = "j0DFrbaPJWJK5bIU6nZ6bslNgp09e14a0bpvPiE4KF8"func access(_ prompt: @escaping @Sendable () async -> DevicePrompt) -> VaultAccess {VaultAccess( keyring: VaultKeyring( keys: InMemoryVaultKeyStore(seeded: scalar), cache: InMemorySecretStore([VaultKeyring.publicSlot: publicHalf])), ask: prompt) }let core = ScriptedCore([CottonMethod.vaultUnlock: .ok(#"{"until":"2026-09-21T10:00:00Z"}"#)])let toasts = ToastCenter(scheduler: ManualToastScheduler())let opened = awaitSettingsKeptFlows.unlockVault( through: ScreenWriter(core: core), toasts: toasts, vault: access { .allowed }) XCTAssertTrue(opened)let unlocks = await core.methodsCalled().filter { $0 == CottonMethod.vaultUnlock }.count XCTAssertEqual(unlocks, 1)let cancelled = awaitSettingsKeptFlows.unlockVault( through: ScreenWriter(core: core), toasts: toasts, vault: access { .cancelled }) XCTAssertFalse(cancelled) XCTAssertNotNil(toasts.current?.message, "a cancelled unlock says so") }}