Skip to content

Commit bda4164

Browse files
committed
Add a test case for the alert when IAP is enabled but not supported for the user.
1 parent 3474449 commit bda4164

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

WooCommerce/WooCommerceTests/Authentication/Store Creation/StoreCreationCoordinatorTests.swift

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ final class StoreCreationCoordinatorTests: XCTestCase {
9292

9393
// Then
9494
waitUntil {
95-
self.navigationController.presentedViewController is UINavigationController
95+
(self.navigationController.presentedViewController as? UINavigationController)?.topViewController is StoreNameFormHostingController
9696
}
97-
let storeCreationNavigationController = try XCTUnwrap(navigationController.presentedViewController as? UINavigationController)
98-
assertThat(storeCreationNavigationController.topViewController, isAnInstanceOf: StoreNameFormHostingController.self)
9997
}
10098

10199
func test_StoreNameFormHostingController_is_presented_when_navigationController_is_showing_another_view_with_iap_enabled() throws {
@@ -115,10 +113,32 @@ final class StoreCreationCoordinatorTests: XCTestCase {
115113

116114
// Then
117115
waitUntil {
118-
self.navigationController.presentedViewController is UINavigationController
116+
(self.navigationController.presentedViewController as? UINavigationController)?.topViewController is StoreNameFormHostingController
117+
}
118+
}
119+
120+
func test_UIAlertController_is_presented_when_iap_is_not_supported_with_iap_enabled() throws {
121+
// Given
122+
let featureFlagService = MockFeatureFlagService(isStoreCreationM2Enabled: true,
123+
isStoreCreationM2WithInAppPurchasesEnabled: true)
124+
let coordinator = StoreCreationCoordinator(source: .storePicker,
125+
navigationController: navigationController,
126+
featureFlagService: featureFlagService,
127+
purchasesManager: MockInAppPurchases(fetchProductsDuration: 0, isIAPSupported: false))
128+
waitFor { promise in
129+
self.navigationController.present(.init(), animated: false) {
130+
promise(())
131+
}
132+
}
133+
XCTAssertNotNil(navigationController.presentedViewController)
134+
135+
// When
136+
coordinator.start()
137+
138+
// Then
139+
waitUntil {
140+
self.navigationController.presentedViewController is UIAlertController
119141
}
120-
let storeCreationNavigationController = try XCTUnwrap(navigationController.presentedViewController as? UINavigationController)
121-
assertThat(storeCreationNavigationController.topViewController, isAnInstanceOf: StoreNameFormHostingController.self)
122142
}
123143

124144
func test_StoreNameFormHostingController_is_presented_when_navigationController_is_presenting_another_view_with_iap_disabled() throws {

0 commit comments

Comments
 (0)