Skip to content
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
2 changes: 1 addition & 1 deletion Modules/Sources/Networking/Model/Product/ProductType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ private enum Keys {
static let variableSubscription = "variable-subscription"
static let bundle = "bundle"
static let composite = "composite"
static let booking = "booking"
static let booking = "bookable-service"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,57 @@ import Yosemite
@MainActor
final class ProductDetailNavigatorTests {
private static let aNonBookingProduct = Product.fake().copy(productTypeKey: "simple")
private static let aBookingProduct = Product.fake().copy(productTypeKey: "booking")
private static let aBookingProduct = Product.fake().copy(productTypeKey: "bookable-service")
private lazy var coordinatorFactory = MockProductDetailCoordinatorFactory()

@Test(arguments: [
(isCIABSite: true, product: aNonBookingProduct),
(isCIABSite: false, product: aBookingProduct),
(isCIABSite: false, product: aNonBookingProduct),
])
private func regardlessOfCIABSiteWeShouldDirectToNative(isCIABSite: Bool, product: Product) {
func non_bookable_product_directs_to_native_view_regardless_of_CIAB(isCIABSite: Bool, product: Product) {
// Given
let navigator = ProductDetailNavigator(
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: isCIABSite),
coordinatorFactory: coordinatorFactory
)

// When
_ = navigator.makeDestination(product: product, isReadOnly: false)

// Then
#expect(coordinatorFactory.createdNativeCoordiantor)
#expect(!coordinatorFactory.createdWebCoordiantor)
}

@Test
private func bookableProductOnCIABSiteWeShouldDirectToWeb() {
func bookable_product_on_CIAB_site_directs_to_web_view() {
// Given
let navigator = ProductDetailNavigator(
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: true),
coordinatorFactory: coordinatorFactory
)

// When
_ = navigator.makeDestination(product: Self.aBookingProduct, isReadOnly: false)

// Then
#expect(coordinatorFactory.createdWebCoordiantor)
#expect(!coordinatorFactory.createdNativeCoordiantor)
}

@Test
func bookable_product_on_non_CIAB_site_directs_to_native_view() {
// Given
let navigator = ProductDetailNavigator(
ciabChecker: MockCIABEligibilityChecker(mockedIsCurrentSiteCIAB: false),
coordinatorFactory: coordinatorFactory
)

// When
_ = navigator.makeDestination(product: Self.aBookingProduct, isReadOnly: false)

// Then
#expect(coordinatorFactory.createdNativeCoordiantor)
#expect(!coordinatorFactory.createdWebCoordiantor)
}
}