From 4fa75b0ed90b6f2cf1ac29160f8cbbe25b639ceb Mon Sep 17 00:00:00 2001 From: Matt Czech Date: Mon, 28 Oct 2024 13:46:00 -0500 Subject: [PATCH] PM-13694: Set carousel shown prior to account setup screens (#1085) --- BitwardenShared/UI/Auth/AuthRouterTests.swift | 15 +++++++++++++++ .../UI/Auth/Extensions/AuthRouter+Redirects.swift | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/BitwardenShared/UI/Auth/AuthRouterTests.swift b/BitwardenShared/UI/Auth/AuthRouterTests.swift index 22cbdc9fa..ca17241c4 100644 --- a/BitwardenShared/UI/Auth/AuthRouterTests.swift +++ b/BitwardenShared/UI/Auth/AuthRouterTests.swift @@ -178,6 +178,21 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_ XCTAssertTrue(stateService.introCarouselShown) } + /// `handleAndRoute(_ :)` redirects `.didCompleteAuth` to `.vaultUnlockSetup` and sets the + /// carousel shown flag if the carousel feature flag is on and the carousel hasn't been shown yet. + @MainActor + func test_handleAndRoute_didCompleteAuth_carouselShown_vaultUnlockSetup() async { + authRepository.activeAccount = .fixture() + configService.featureFlagsBool[.nativeCarouselFlow] = true + stateService.activeAccount = .fixture() + stateService.accountSetupVaultUnlock["1"] = .incomplete + + let route = await subject.handleAndRoute(.didCompleteAuth) + + XCTAssertEqual(route, .vaultUnlockSetup(.createAccount)) + XCTAssertTrue(stateService.introCarouselShown) + } + /// `handleAndRoute(_:)` redirects `.didCompleteAuth` to complete the auth flow if the account /// doesn't require an updated password. func test_handleAndRoute_didCompleteAuth_complete() async { diff --git a/BitwardenShared/UI/Auth/Extensions/AuthRouter+Redirects.swift b/BitwardenShared/UI/Auth/Extensions/AuthRouter+Redirects.swift index ffac6ae7f..04d21ee87 100644 --- a/BitwardenShared/UI/Auth/Extensions/AuthRouter+Redirects.swift +++ b/BitwardenShared/UI/Auth/Extensions/AuthRouter+Redirects.swift @@ -29,6 +29,8 @@ extension AuthRouter { return .landing } + await setCarouselShownIfEnabled() + if account.profile.forcePasswordResetReason != nil { return .updateMasterPassword } @@ -41,7 +43,6 @@ extension AuthRouter { } } - await setCarouselShownIfEnabled() return .complete }