8000 PM-10517: Add feature flag for intro carousel by matt-livefront · Pull Request #800 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PM-10517: Add feature flag for intro carousel #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BitwardenShared/Core/Platform/Models/Enum/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import Foundation
/// An enum to represent a feature flag sent by the server
///
enum FeatureFlag: String, Codable {
/// A feature flag for the intro carousel flow.
case nativeCarouselFlow = "native-carousel-flow"

/// A feature flag for showing the unassigned items banner.
case unassignedItemsBanner = "unassigned-items-banner"
}
1 change: 1 addition & 0 deletions BitwardenShared/UI/Auth/AuthRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ final class AuthRouter: NSObject, Router {

typealias Services = HasAuthRepository
& HasClientService
& HasConfigService
& HasErrorReporter
& HasStateService
& HasVaultTimeoutService
Expand Down
15 changes: 15 additions & 0 deletions BitwardenShared/UI/Auth/AuthRouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_
// MARK: Properties

var authRepository: MockAuthRepository!
var configService: MockConfigService!
var errorReporter: MockErrorReporter!
var stateService: MockStateService!
var subject: AuthRouter!
Expand All @@ -19,13 +20,15 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_
super.setUp()

authRepository = MockAuthRepository()
configService = MockConfigService()
errorReporter = MockErrorReporter()
stateService = MockStateService()
vaultTimeoutService = MockVaultTimeoutService()

subject = AuthRouter(
services: ServiceContainer.withMocks(
authRepository: authRepository,
configService: configService,
errorReporter: errorReporter,
stateService: stateService,
vaultTimeoutService: vaultTimeoutService
Expand All @@ -36,6 +39,8 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_
override func tearDown() {
super.tearDown()

authRepository = nil
configService = nil
errorReporter = nil
stateService = nil
subject = nil
Expand Down Expand Up @@ -767,6 +772,16 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_
XCTAssertTrue(authRepository.logoutCalled)
}

/// `handleAndRoute(_ :)` redirects `.didStart` to `.introCarousel` if there's no accounts and
/// the carousel flow is enabled.
func test_handleAndRoute_didStart_createAccountFlow() async {
configService.featureFlagsBool[.nativeCarouselFlow] = true

let route = await subject.handleAndRoute(.didStart)

XCTAssertEqual(route, .introCarousel)
}

/// `handleAndRoute(_ :)` redirects `.didTimeout` to `.complete`
/// if the account has never lock enabled.
func test_handleAndRoute_didTimeout_neverLock() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ extension AuthRouter {
///
func preparedStartRoute() async -> AuthRoute {
guard let activeAccount = try? await configureActiveAccount(shouldSwitchAutomatically: true) else {
// If no account can be set to active, go to the landing screen.
return .landing
// If no account can be set to active, go to the landing or carousel screen.
let isCarouselEnabled: Bool = await services.configService.getFeatureFlag(.nativeCarouselFlow)
return isCarouselEnabled ? .introCarousel : .landing
}

// Check for a `logout` timeout action.
Expand Down
Loading
0