Skip to content

Commit a48f878

Browse files
committed
Update analytics tests for POS cash payment flow
See 363e0b0 for details – we moved the other event to be for the final step, not starting the flow.
1 parent 928cf93 commit a48f878

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

WooCommerce/WooCommerceTests/POS/Mocks/MockPOSCollectOrderPaymentAnalyticsTracker.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ final class MockPOSCollectOrderPaymentAnalyticsTracker: POSCollectOrderPaymentAn
2828
// no-op
2929
}
3030

31+
var didCallTrackSuccessfulCashPayment = false
3132
func trackSuccessfulCashPayment() {
32-
// no-op
33+
didCallTrackSuccessfulCashPayment = true
3334
}
3435

3536
var connectedReaderModel: String?

WooCommerce/WooCommerceTests/POS/Models/PointOfSaleAggregateModelTests.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,20 @@ struct PointOfSaleAggregateModelTests {
906906
await sut.startCashPayment()
907907

908908
// Then
909-
#expect(mockAnalyticsProvider.receivedEvents.first(where: { $0 == "cash_payment_tapped" }) != nil)
909+
#expect(mockAnalyticsProvider.receivedEvents.first(where: { $0 == "checkout_cash_payment_tapped" }) != nil)
910+
}
911+
912+
@Test func collectCashPayment_when_invoked_tracks_expected_event() async throws {
913+
// Given
914+
let analyticsTracker = MockPOSCollectOrderPaymentAnalyticsTracker()
915+
let sut = makePointOfSaleAggregateModel(orderController: orderController,
916+
collectOrderPaymentAnalyticsTracker: analyticsTracker)
917+
918+
// When
919+
try await sut.collectCashPayment(changeDueAmount: "0.00")
920+
921+
// Then
922+
#expect(analyticsTracker.didCallTrackSuccessfulCashPayment == true)
910923
}
911924
}
912925

0 commit comments

Comments
 (0)