Skip to content

Commit 6060f22

Browse files
committed
Add flag to mock flag service and fix failing tests
1 parent 89f9f4a commit 6060f22

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

WooCommerce/WooCommerceTests/Mocks/MockFeatureFlagService.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ final class MockFeatureFlagService: FeatureFlagService {
2424
var isProductGlobalUniqueIdentifierSupported: Bool
2525
var hideSitesInStorePicker: Bool
2626
var notificationSettings: Bool
27+
var allowMerchantAIAPIKey: Bool
2728

2829
init(isInboxOn: Bool = false,
2930
isShowInboxCTAEnabled: Bool = false,
@@ -46,7 +47,8 @@ final class MockFeatureFlagService: FeatureFlagService {
4647
favoriteProducts: Bool = false,
4748
isProductGlobalUniqueIdentifierSupported: Bool = false,
4849
hideSitesInStorePicker: Bool = false,
49-
notificationSettings: Bool = false) {
50+
notificationSettings: Bool = false,
51+
allowMerchantAIAPIKey: Bool = false) {
5052
self.isInboxOn = isInboxOn
5153
self.isShowInboxCTAEnabled = isShowInboxCTAEnabled
5254
self.isUpdateOrderOptimisticallyOn = isUpdateOrderOptimisticallyOn
@@ -69,6 +71,7 @@ final class MockFeatureFlagService: FeatureFlagService {
6971
self.isProductGlobalUniqueIdentifierSupported = isProductGlobalUniqueIdentifierSupported
7072
self.hideSitesInStorePicker = hideSitesInStorePicker
7173
self.notificationSettings = notificationSettings
74+
self.allowMerchantAIAPIKey = allowMerchantAIAPIKey
7275
}
7376

7477
func isFeatureFlagEnabled(_ featureFlag: FeatureFlag) -> Bool {
@@ -117,6 +120,8 @@ final class MockFeatureFlagService: FeatureFlagService {
117120
return hideSitesInStorePicker
118121
case .notificationSettings:
119122
return notificationSettings
123+
case .allowMerchantAIAPIKey:
124+
return allowMerchantAIAPIKey
120125
default:
121126
return false
122127
}

WooCommerce/WooCommerceTests/ViewRelated/HubMenu/HubMenuViewModelTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@ final class HubMenuViewModelTests: XCTestCase {
206206
stores.updateDefaultStore(storeID: sampleSiteID)
207207
stores.updateDefaultStore(.fake().copy(siteID: sampleSiteID))
208208

209+
let featureFlagService = MockFeatureFlagService(allowMerchantAIAPIKey: false)
209210
let blazeEligibilityChecker = MockBlazeEligibilityChecker(isSiteEligible: true)
210211

211212
// When
212213
let viewModel = HubMenuViewModel(siteID: sampleSiteID,
213214
tapToPayBadgePromotionChecker: TapToPayBadgePromotionChecker(),
215+
featureFlagService: featureFlagService,
214216
stores: stores,
215217
blazeEligibilityChecker: blazeEligibilityChecker)
216218

@@ -267,11 +269,13 @@ final class HubMenuViewModelTests: XCTestCase {
267269
stores.updateDefaultStore(storeID: sampleSiteID)
268270
stores.updateDefaultStore(.fake().copy(siteID: sampleSiteID))
269271

272+
let featureFlagService = MockFeatureFlagService(allowMerchantAIAPIKey: false)
270273
let checker = MockGoogleAdsEligibilityChecker(isEligible: true)
271274

272275
// When
273276
let viewModel = HubMenuViewModel(siteID: sampleSiteID,
274277
tapToPayBadgePromotionChecker: TapToPayBadgePromotionChecker(),
278+
featureFlagService: featureFlagService,
275279
stores: stores,
276280
googleAdsEligibilityChecker: checker)
277281
waitUntil {
@@ -568,6 +572,7 @@ final class HubMenuViewModelTests: XCTestCase {
568572
let blazeEligibilityChecker = MockBlazeEligibilityChecker(isSiteEligible: true)
569573
let googleAdsEligibilityChecker = MockGoogleAdsEligibilityChecker(isEligible: true)
570574
let inboxEligibilityChecker = MockInboxEligibilityChecker()
575+
let featureFlagService = MockFeatureFlagService(allowMerchantAIAPIKey: false)
571576
inboxEligibilityChecker.isEligible = true
572577

573578
let stores = MockStoresManager(sessionManager: .makeForTesting())
@@ -578,6 +583,7 @@ final class HubMenuViewModelTests: XCTestCase {
578583
let navigationPath = NavigationPath(["testPath1", "testPath2"])
579584
let viewModel = HubMenuViewModel(siteID: sampleSiteID,
580585
tapToPayBadgePromotionChecker: TapToPayBadgePromotionChecker(),
586+
featureFlagService: featureFlagService,
581587
stores: stores,
582588
generalAppSettings: generalAppSettings,
583589
inboxEligibilityChecker: inboxEligibilityChecker,

0 commit comments

Comments
 (0)