From 9ffb9a22e3145bfc9cdd0254a5372fa6589bd7a1 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 11 Dec 2025 09:36:07 +0200 Subject: [PATCH] Attempt to make the EncryptionSettings UI tests more resilient The secure backup disabling sheet doesn't show up in the snapshots. No idea what the actual problem is though, completely unreproducible locally. --- .../SecureBackupScreenViewModel.swift | 26 +++++++++---------- UITests/Sources/EncryptionSettingsTests.swift | 3 ++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift index cd0b1d9dc..24c98fdc0 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenViewModel.swift @@ -55,7 +55,7 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup switch (keyBackupState, enable) { case (.unknown, true): state.bindings.keyStorageEnabled = keyBackupState.keyStorageToggleState // Reset the toggle in case enabling fails - enableBackup() + Task { await enableBackup() } case (.enabled, false): state.bindings.keyStorageEnabled = keyBackupState.keyStorageToggleState // Reset the toggle in case the user cancels actionsSubject.send(.disableKeyBackup) @@ -67,20 +67,18 @@ class SecureBackupScreenViewModel: SecureBackupScreenViewModelType, SecureBackup // MARK: - Private - private func enableBackup() { - Task { - let loadingIndicatorIdentifier = "SecureBackupScreenLoading" - userIndicatorController.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true)) - switch await secureBackupController.enable() { - case .success: - break - case .failure(let error): - MXLog.error("Failed enabling key backup with error: \(error)") - state.bindings.alertInfo = .init(id: .init()) - } - - userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier) + private func enableBackup() async { + let loadingIndicatorIdentifier = "SecureBackupScreenLoading" + userIndicatorController.submitIndicator(.init(id: loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true)) + switch await secureBackupController.enable() { + case .success: + break + case .failure(let error): + MXLog.error("Failed enabling key backup with error: \(error)") + state.bindings.alertInfo = .init(id: .init()) } + + userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier) } } diff --git a/UITests/Sources/EncryptionSettingsTests.swift b/UITests/Sources/EncryptionSettingsTests.swift index b2e2a8278..5f6949c53 100644 --- a/UITests/Sources/EncryptionSettingsTests.swift +++ b/UITests/Sources/EncryptionSettingsTests.swift @@ -34,7 +34,8 @@ class EncryptionSettingsUITests: XCTestCase { // Broken by https://github.com/element-hq/compound-ios/pull/140 app.switches[A11yIdentifiers.secureBackupScreen.keyStorage].switches.firstMatch.tap() - try await app.assertScreenshot(step: Step.keyBackupScreen) + // Has been failing often on CI, reasons unclear. + try await app.assertScreenshot(step: Step.keyBackupScreen, delay: .seconds(1)) // Confirm deletion of keys. app.buttons[A11yIdentifiers.secureBackupKeyBackupScreen.deleteKeyStorage].tap()