Skip to content

Commit 2e81b4c

Browse files
authored
Bookings: Support new bookable product type (#16362)
2 parents 2d05c6b + f68c411 commit 2e81b4c

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

Modules/Sources/Networking/Model/Product/ProductType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ private enum Keys {
105105
static let variableSubscription = "variable-subscription"
106106
static let bundle = "bundle"
107107
static let composite = "composite"
108-
static let booking = "booking"
108+
static let booking = "bookable-service"
109109
}

WooCommerce/WooCommerceTests/Routing/ProductDetail/ProductDetailNavigatorTests.swift

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,57 @@ import Yosemite
55
@MainActor
66
final class ProductDetailNavigatorTests {
77
private static let aNonBookingProduct = Product.fake().copy(productTypeKey: "simple")
8-
private static let aBookingProduct = Product.fake().copy(productTypeKey: "booking")
8+
private static let aBookingProduct = Product.fake().copy(productTypeKey: "bookable-service")
99
private lazy var coordinatorFactory = MockProductDetailCoordinatorFactory()
1010

1111
@Test(arguments: [
1212
(isCIABSite: true, product: aNonBookingProduct),
13-
(isCIABSite: false, product: aBookingProduct),
1413
(isCIABSite: false, product: aNonBookingProduct),
1514
])
16-
private func regardlessOfCIABSiteWeShouldDirectToNative(isCIABSite: Bool, product: Product) {
15+
func non_bookable_product_directs_to_native_view_regardless_of_CIAB(isCIABSite: Bool, product: Product) {
16+
// Given
1717
let navigator = ProductDetailNavigator(
1818
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: isCIABSite),
1919
coordinatorFactory: coordinatorFactory
2020
)
21+
22+
// When
2123
_ = navigator.makeDestination(product: product, isReadOnly: false)
24+
25+
// Then
2226
#expect(coordinatorFactory.createdNativeCoordiantor)
2327
#expect(!coordinatorFactory.createdWebCoordiantor)
2428
}
2529

2630
@Test
27-
private func bookableProductOnCIABSiteWeShouldDirectToWeb() {
31+
func bookable_product_on_CIAB_site_directs_to_web_view() {
32+
// Given
2833
let navigator = ProductDetailNavigator(
2934
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: true),
3035
coordinatorFactory: coordinatorFactory
3136
)
37+
38+
// When
3239
_ = navigator.makeDestination(product: Self.aBookingProduct, isReadOnly: false)
40+
41+
// Then
3342
#expect(coordinatorFactory.createdWebCoordiantor)
3443
#expect(!coordinatorFactory.createdNativeCoordiantor)
3544
}
45+
46+
@Test
47+
func bookable_product_on_non_CIAB_site_directs_to_native_view() {
48+
// Given
49+
let navigator = ProductDetailNavigator(
50+
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: false),
51+
coordinatorFactory: coordinatorFactory
52+
)
53+
54+
// When
55+
_ = navigator.makeDestination(product: Self.aBookingProduct, isReadOnly: false)
56+
57+
// Then
58+
#expect(coordinatorFactory.createdNativeCoordiantor)
59+
#expect(!coordinatorFactory.createdWebCoordiantor)
60+
}
3661
}

0 commit comments

Comments
 (0)