-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Woo POS] MVP Analytics: Card payment success event properties (#15148)
- Loading branch information
Showing
12 changed files
with
326 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
WooCommerce/WooCommerceTests/POS/Analytics/POSCollectOrderPaymentAnalyticsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@testable import WooCommerce | ||
import protocol WooFoundation.Analytics | ||
import Testing | ||
|
||
struct POSCollectOrderPaymentAnalyticsTests { | ||
private let analytics: Analytics | ||
private let analyticsProvider: MockAnalyticsProvider | ||
|
||
init() { | ||
analyticsProvider = MockAnalyticsProvider() | ||
analytics = WooAnalytics(analyticsProvider: analyticsProvider) | ||
} | ||
|
||
@Test func POSCollectOrderPaymentAnalyticsTests_when_successful_payment_then_tracks_event_and_properties() { | ||
// Given | ||
let sut = POSCollectOrderPaymentAnalytics(analytics: analytics) | ||
let capturedPaymentData = CardPresentCapturedPaymentData(paymentMethod: .cardPresent(details: .fake()), receiptParameters: nil) | ||
let expectedEvent = "card_present_collect_payment_success" | ||
let expectedProperties = [ | ||
"milliseconds_since_order_creation_success", | ||
"milliseconds_since_reader_ready_to_collect_payment", | ||
"milliseconds_since_card_tapped", | ||
"milliseconds_since_customer_interaction_started", | ||
"checkout_tap_count" | ||
] | ||
|
||
// When | ||
sut.trackSuccessfulPayment(capturedPaymentData: capturedPaymentData) | ||
|
||
// Then | ||
#expect(analyticsProvider.receivedEvents.first(where: { $0 == expectedEvent }) != nil) | ||
#expect(expectedProperties.allSatisfy { key in | ||
analyticsProvider.receivedProperties.contains(where: { $0.keys.contains(key) }) | ||
}) | ||
} | ||
} |
Oops, something went wrong.