Skip to content

Commit

Permalink
[MBL-853] Create Feature Flag To Hide Creator Dashboard (#1827)
Browse files Browse the repository at this point in the history
* add enum case to RemoteConfigFeature

* add helper to RemoteConfigFeature+Helpers

* update RemoteConfigFeatureFlagToolsViewControllerTests and snapshot

* Update testRemoteConfigFeatureFlagToolsViewController.1.png

* remove "hidden" text and update snapshot
  • Loading branch information
scottkicks committed Jun 15, 2023
1 parent 7015f3b commit 2c5ef89
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
Expand Up @@ -24,6 +24,8 @@ final class RemoteConfigFeatureFlagToolsViewControllerTests: TestCase {
|> \.features .~ [
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: false,
RemoteConfigFeature.facebookLoginInterstitialEnabled
.rawValue: false,
RemoteConfigFeature.creatorDashboardEnabled
.rawValue: false
]

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature+Helpers.swift
Expand Up @@ -7,6 +7,13 @@ public func featureConsentManagementDialogEnabled() -> Bool {
.isFeatureEnabled(featureKey: RemoteConfigFeature.consentManagementDialogEnabled) ?? false)
}

public func featureCreatorDashboardEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.creatorDashboardEnabled.rawValue] ??
(AppEnvironment.current.remoteConfigClient?
.isFeatureEnabled(featureKey: RemoteConfigFeature.creatorDashboardEnabled) ?? false)
}

public func featureFacebookLoginInterstitialEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] ??
Expand Down
9 changes: 9 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift
Expand Up @@ -40,4 +40,13 @@ final class RemoteConfigFeatureHelpersTests: TestCase {
XCTAssertFalse(featureFacebookLoginInterstitialEnabled())
}
}

func testCreatorDashboard_RemoteConfig_FeatureFlag_False() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.creatorDashboardEnabled.rawValue: false]

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
XCTAssertFalse(featureCreatorDashboardEnabled())
}
}
}
2 changes: 2 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature.swift
Expand Up @@ -2,13 +2,15 @@ import Foundation

public enum RemoteConfigFeature: String, CaseIterable {
case consentManagementDialogEnabled = "consent_management_dialog"
case creatorDashboardEnabled = "creator_dashboard"
case facebookLoginInterstitialEnabled = "facebook_interstitial"
}

extension RemoteConfigFeature: CustomStringConvertible {
public var description: String {
switch self {
case .consentManagementDialogEnabled: return "Consent Management Dialog"
case .creatorDashboardEnabled: return "Creator Dashboard"
case .facebookLoginInterstitialEnabled: return "Facebook Login Interstitial"
}
}
Expand Down
Expand Up @@ -89,6 +89,8 @@ private func isFeatureEnabled(_ feature: RemoteConfigFeature) -> Bool {
return featureConsentManagementDialogEnabled()
case .facebookLoginInterstitialEnabled:
return featureFacebookLoginInterstitialEnabled()
case .creatorDashboardEnabled:
return featureCreatorDashboardEnabled()
}
}

Expand All @@ -102,6 +104,9 @@ private func getValueFromUserDefaults(for feature: RemoteConfigFeature) -> Bool?
case .facebookLoginInterstitialEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue]
case .creatorDashboardEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.creatorDashboardEnabled.rawValue]
}
}

Expand All @@ -115,5 +120,8 @@ private func setValueInUserDefaults(for feature: RemoteConfigFeature, and value:
case .facebookLoginInterstitialEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] = value
case .creatorDashboardEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.creatorDashboardEnabled.rawValue] = value
}
}

0 comments on commit 2c5ef89

Please sign in to comment.