Skip to content

Commit

Permalink
[WEB-697] Adds new Facebook Login Deprecation feature flag (#1715)
Browse files Browse the repository at this point in the history
* Adds new Facebook Login Deprecation feature flag

* Updates snapshot reference image for tests
  • Loading branch information
scottkicks committed Aug 31, 2022
1 parent faa5d78 commit 31562b1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 4 deletions.
Expand Up @@ -23,7 +23,8 @@ final class OptimizelyFeatureFlagToolsViewControllerTests: TestCase {
|> \.features .~ [
OptimizelyFeature.commentFlaggingEnabled.rawValue: false,
OptimizelyFeature.projectPageStoryTabEnabled.rawValue: false,
OptimizelyFeature.rewardLocalPickupEnabled.rawValue: false
OptimizelyFeature.rewardLocalPickupEnabled.rawValue: false,
OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue: false
]

withEnvironment(language: .en, mainBundle: MockBundle(), optimizelyClient: mockOptimizelyClient) {
Expand Down
2 changes: 1 addition & 1 deletion Library/OptimizelyClientTypeTests.swift
Expand Up @@ -24,7 +24,7 @@ final class OptimizelyClientTypeTests: TestCase {
OptimizelyFeature.commentFlaggingEnabled.rawValue: true
]

XCTAssert(mockOptimizelyClient.allFeatures().count == 4)
XCTAssert(mockOptimizelyClient.allFeatures().count == 5)
}

func testVariantForExperiment_NoError() {
Expand Down
7 changes: 7 additions & 0 deletions Library/OptimizelyFeature+Helpers.swift
Expand Up @@ -27,3 +27,10 @@ public func featurePaymentSheetEnabled() -> Bool {
(AppEnvironment.current.optimizelyClient?
.isFeatureEnabled(featureKey: OptimizelyFeature.paymentSheetEnabled.rawValue) ?? false)
}

public func facebookLoginDeprecationEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.optimizelyFeatureFlags[OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue] ??
(AppEnvironment.current.optimizelyClient?
.isFeatureEnabled(featureKey: OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue) ?? false)
}
9 changes: 9 additions & 0 deletions Library/OptimizelyFeature+HelpersTests.swift
Expand Up @@ -74,4 +74,13 @@ final class OptimizelyFeatureHelpersTests: TestCase {
XCTAssertFalse(featurePaymentSheetEnabled())
}
}

func testFacebookDeprecation_Optimizely_FeatureFlag_False() {
let mockOptimizelyClient = MockOptimizelyClient()
|> \.features .~ [OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue: false]

withEnvironment(optimizelyClient: mockOptimizelyClient) {
XCTAssertFalse(facebookLoginDeprecationEnabled())
}
}
}
2 changes: 2 additions & 0 deletions Library/OptimizelyFeature.swift
Expand Up @@ -5,6 +5,7 @@ public enum OptimizelyFeature: String, CaseIterable {
case projectPageStoryTabEnabled = "project_page_v2_story"
case rewardLocalPickupEnabled = "ios_local_pickup"
case paymentSheetEnabled = "ios_payment_sheet"
case facebookLoginDeprecationEnabled = "ios_facebook_deprecation"
}

extension OptimizelyFeature: CustomStringConvertible {
Expand All @@ -14,6 +15,7 @@ extension OptimizelyFeature: CustomStringConvertible {
case .projectPageStoryTabEnabled: return "Project Page Story Tab"
case .rewardLocalPickupEnabled: return "Local Pickup Rewards"
case .paymentSheetEnabled: return "Payment Sheet"
case .facebookLoginDeprecationEnabled: return "Facebook Login Deprecation"
}
}
}
6 changes: 6 additions & 0 deletions Library/ViewModels/OptimizelyFeatureFlagToolsViewModel.swift
Expand Up @@ -104,6 +104,9 @@ private func getValueFromUserDefaults(for feature: OptimizelyFeature) -> Bool? {
case .paymentSheetEnabled:
return AppEnvironment.current.userDefaults
.optimizelyFeatureFlags[OptimizelyFeature.paymentSheetEnabled.rawValue]
case .facebookLoginDeprecationEnabled:
return AppEnvironment.current.userDefaults
.optimizelyFeatureFlags[OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue]
}
}

Expand All @@ -123,5 +126,8 @@ private func setValueInUserDefaults(for feature: OptimizelyFeature, and value: B
case .paymentSheetEnabled:
return AppEnvironment.current.userDefaults
.optimizelyFeatureFlags[OptimizelyFeature.paymentSheetEnabled.rawValue] = value
case .facebookLoginDeprecationEnabled:
return AppEnvironment.current.userDefaults
.optimizelyFeatureFlags[OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue] = value
}
}
Expand Up @@ -25,7 +25,8 @@ final class OptimizelyFlagToolsViewModelTests: TestCase {
OptimizelyFeature.commentFlaggingEnabled.rawValue: true,
OptimizelyFeature.projectPageStoryTabEnabled.rawValue: true,
OptimizelyFeature.rewardLocalPickupEnabled.rawValue: true,
OptimizelyFeature.paymentSheetEnabled.rawValue: true
OptimizelyFeature.paymentSheetEnabled.rawValue: true,
OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue: true
]

withEnvironment(optimizelyClient: mockOptimizelyClient) {
Expand All @@ -47,7 +48,8 @@ final class OptimizelyFlagToolsViewModelTests: TestCase {
OptimizelyFeature.commentFlaggingEnabled.rawValue: false,
OptimizelyFeature.projectPageStoryTabEnabled.rawValue: false,
OptimizelyFeature.rewardLocalPickupEnabled.rawValue: false,
OptimizelyFeature.paymentSheetEnabled.rawValue: false
OptimizelyFeature.paymentSheetEnabled.rawValue: false,
OptimizelyFeature.facebookLoginDeprecationEnabled.rawValue: false
]

withEnvironment(optimizelyClient: mockOptimizelyClient) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31562b1

Please sign in to comment.