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.
This commit is contained in:
Stefan Ceriu
2025-12-11 09:36:07 +02:00
committed by Stefan Ceriu
parent bc7ced11cb
commit 9ffb9a22e3
2 changed files with 14 additions and 15 deletions
@@ -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)
}
}
@@ -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()