Add iOS lifecycle hardening hooks

This commit is contained in:
Mikhail Kilin
2026-05-20 15:51:15 +03:00
parent 8bea159569
commit 59050d0b5f
3 changed files with 106 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ struct TeleTuiIOSSmokeTests {
try await chatDetailLoadsAndSendsMessage()
try await messageActionsCoverEditReplyForwardReactDeleteSearchAndCopy()
try await platformServicesCoverNotificationsMediaVoiceClipboardAndAccounts()
lifecycleCoordinatorDropsStaleAccountEvents()
try await profileLoadsFromSelectedChat()
appStorageUsesApplicationSupportStyleAccountPaths()
print("TeleTuiIOS smoke tests passed")
@@ -141,6 +142,35 @@ struct TeleTuiIOSSmokeTests {
precondition(switcher.activeAccount.databasePath.path.hasSuffix("/Accounts/work/tdlib"))
}
@MainActor
private static func lifecycleCoordinatorDropsStaleAccountEvents() {
let coordinator = SessionLifecycleCoordinator(activeAccountId: "personal")
precondition(coordinator.shouldPollEvents)
coordinator.enterBackground()
precondition(!coordinator.shouldPollEvents)
coordinator.enterForeground()
precondition(coordinator.shouldPollEvents)
let oldGenerationEvent = ScopedSessionEvent(
accountId: "personal",
generation: coordinator.generation,
event: .authChanged(.ready)
)
precondition(coordinator.accepts(oldGenerationEvent))
coordinator.switchAccount(to: "work")
precondition(!coordinator.accepts(oldGenerationEvent))
let newGenerationEvent = ScopedSessionEvent(
accountId: "work",
generation: coordinator.generation,
event: .authChanged(.ready)
)
precondition(coordinator.accepts(newGenerationEvent))
}
@MainActor
private static func profileLoadsFromSelectedChat() async throws {
let bridge = FakeSessionBridge(auth: .ready)