diff --git a/BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings b/BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings index 23d987fe7..48bb8fa96 100644 --- a/BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings +++ b/BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings @@ -1042,3 +1042,5 @@ "AutofillPasswords" = "Autofill passwords"; "SetUpAutofillOnAllYourDevicesToLoginWithASingleTapAnywhere" = "Set up autofill on all your devices to login with a single tap anywhere."; "GotIt" = "Got it"; +"AllowAuthenticatorSyncing" = "Allow authenticator syncing"; +"AuthenticatorSync" = "Authenticator sync"; diff --git a/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityEffect.swift b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityEffect.swift index 436aac006..0b5076c65 100644 --- a/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityEffect.swift +++ b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityEffect.swift @@ -22,6 +22,9 @@ enum AccountSecurityEffect: Equatable { /// Stream the state of the badges in the settings tab. case streamSettingsBadge + /// Sync with Authenticator was toggled. + case toggleSyncWithAuthenticator(Bool) + /// Unlock with Biometrics was toggled. case toggleUnlockWithBiometrics(Bool) diff --git a/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityProcessor.swift b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityProcessor.swift index f424abca8..910b67f0b 100644 --- a/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityProcessor.swift +++ b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/AccountSecurityProcessor.swift @@ -5,7 +5,7 @@ import OSLog /// The processor used to manage state and handle actions for the account security screen. /// -final class AccountSecurityProcessor: StateProcessor< +final class AccountSecurityProcessor: StateProcessor! @@ -41,6 +41,33 @@ class AccountSecurityViewTests: BitwardenTestCase { task.cancel() } + /// The view hides the authenticator sync section when appropriate. + @MainActor + func test_authenticatorSync_hidden() throws { + processor.state.shouldShowAuthenticatorSyncSection = false + XCTAssertNil( + try? subject.inspect().find( + toggleWithAccessibilityLabel: Localizations.allowAuthenticatorSyncing + ) + ) + } + + /// Tapping the sync with authenticator switch should send `.toggleSyncWithAuthenticator(enabled)` with the + /// new value of enabled. + @MainActor + func test_authenticatorSync_tap() throws { + processor.state.shouldShowAuthenticatorSyncSection = true + processor.state.isAuthenticatorSyncEnabled = false + let toggle = try subject.inspect().find(toggleWithAccessibilityLabel: Localizations.allowAuthenticatorSyncing) + XCTAssertFalse(try toggle.isOn()) + + let task = Task { + try toggle.tap() + } + defer { task.cancel() } + waitFor(processor.effects.last == .toggleSyncWithAuthenticator(true)) + } + /// The action card is hidden if the vault unlock setup progress is complete. @MainActor func test_setUpUnlockActionCard_hidden() { @@ -239,6 +266,19 @@ class AccountSecurityViewTests: BitwardenTestCase { assertSnapshot(of: subject, as: .defaultPortrait) } + /// The view renders correctly when the `shouldShowAuthenticatorSyncSection` is `true`. + @MainActor + func test_snapshot_shouldShowAuthenticatorSyncSection() { + let subject = AccountSecurityView( + store: Store( + processor: StateProcessor( + state: AccountSecurityState(shouldShowAuthenticatorSyncSection: true) + ) + ) + ) + assertSnapshot(of: subject, as: .defaultPortrait) + } + /// The view renders correctly when the timeout policy is enabled. @MainActor func test_snapshot_timeoutPolicy() { diff --git a/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/__Snapshots__/AccountSecurityViewTests/test_snapshot_shouldShowAuthenticatorSyncSection.1.png b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/__Snapshots__/AccountSecurityViewTests/test_snapshot_shouldShowAuthenticatorSyncSection.1.png new file mode 100644 index 000000000..b0ce05cc9 Binary files /dev/null and b/BitwardenShared/UI/Platform/Settings/Settings/AccountSecurity/__Snapshots__/AccountSecurityViewTests/test_snapshot_shouldShowAuthenticatorSyncSection.1.png differ