Skip to content
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

[MBL-1120] Post Campaign Pledge Feature Flag #1917

Merged
merged 3 commits into from
Jan 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ final class RemoteConfigFeatureFlagToolsViewControllerTests: TestCase {
RemoteConfigFeature.darkModeEnabled.rawValue: false,
RemoteConfigFeature.facebookLoginInterstitialEnabled
.rawValue: false,
RemoteConfigFeature.postCampaignPledgeEnabled.rawValue: false,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: false
]

Expand Down
Loading
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public func featureFacebookLoginInterstitialEnabled() -> Bool {
.isFeatureEnabled(featureKey: RemoteConfigFeature.facebookLoginInterstitialEnabled) ?? false)
}

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

public func featureReportThisProjectEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue] ??
Expand Down
18 changes: 18 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ final class RemoteConfigFeatureHelpersTests: TestCase {
}
}

func testPostCampaignPledge_RemoteConfig_FeatureFlag_True() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.postCampaignPledgeEnabled.rawValue: true]

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
XCTAssertTrue(featurePostCampaignPledgeEnabled())
}
}

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

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
XCTAssertFalse(featurePostCampaignPledgeEnabled())
}
}

func testReportThisProject_RemoteConfig_FeatureFlag_True() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.reportThisProjectEnabled.rawValue: true]
Expand Down
2 changes: 2 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum RemoteConfigFeature: String, CaseIterable {
case consentManagementDialogEnabled = "consent_management_dialog"
case darkModeEnabled = "dark_mode"
case facebookLoginInterstitialEnabled = "facebook_interstitial"
case postCampaignPledgeEnabled = "post_campaign_pledge"
case reportThisProjectEnabled = "report_this_project"
case useOfAIProjectTab = "use_of_ai_project_tab"
}
Expand All @@ -16,6 +17,7 @@ extension RemoteConfigFeature: CustomStringConvertible {
case .consentManagementDialogEnabled: return "Consent Management Dialog"
case .darkModeEnabled: return "Dark Mode"
case .facebookLoginInterstitialEnabled: return "Facebook Login Interstitial"
case .postCampaignPledgeEnabled: return "Post Campaign Pledging"
case .reportThisProjectEnabled: return "Report This Project"
case .useOfAIProjectTab: return "Use of AI Project Tab"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ private func isFeatureEnabled(_ feature: RemoteConfigFeature) -> Bool {
return featureDarkModeEnabled()
case .facebookLoginInterstitialEnabled:
return featureFacebookLoginInterstitialEnabled()
case .postCampaignPledgeEnabled:
return featurePostCampaignPledgeEnabled()
case .reportThisProjectEnabled:
return featureReportThisProjectEnabled()
case .useOfAIProjectTab:
Expand All @@ -116,6 +118,9 @@ private func getValueFromUserDefaults(for feature: RemoteConfigFeature) -> Bool?
case .facebookLoginInterstitialEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue]
case .postCampaignPledgeEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.postCampaignPledgeEnabled.rawValue]
case .reportThisProjectEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue]
Expand All @@ -141,6 +146,9 @@ private func setValueInUserDefaults(for feature: RemoteConfigFeature, and value:
case .facebookLoginInterstitialEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue] = value
case .postCampaignPledgeEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.postCampaignPledgeEnabled.rawValue] = value
case .reportThisProjectEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue] = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase {
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true,
RemoteConfigFeature.darkModeEnabled.rawValue: true,
RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true,
RemoteConfigFeature.postCampaignPledgeEnabled.rawValue: true,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: true,
RemoteConfigFeature.useOfAIProjectTab.rawValue: true
]
Expand All @@ -50,6 +51,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase {
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true,
RemoteConfigFeature.darkModeEnabled.rawValue: false,
RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true,
RemoteConfigFeature.postCampaignPledgeEnabled.rawValue: false,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: false,
RemoteConfigFeature.useOfAIProjectTab.rawValue: false
]
Expand Down