Skip to content

Commit 9176e6c

Browse files
Unit test REST API AB test variant tracking code.
1 parent 8105cef commit 9176e6c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

WooCommerce/WooCommerceTests/AppCoordinatorTests.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,25 @@ final class AppCoordinatorTests: XCTestCase {
318318
appCoordinator.start()
319319

320320
// Then
321-
XCTAssertEqual(analytics.receivedEvents, [WooAnalyticsStat.loginOnboardingShown.rawValue])
321+
_ = try XCTUnwrap(analytics.receivedEvents.firstIndex(where: { $0 == WooAnalyticsStat.loginOnboardingShown.rawValue}))
322+
}
323+
324+
func test_trackRestAPILoginExperimentVariation_is_tracked_after_presenting_onboarding() throws {
325+
// Given
326+
stores.deauthenticate()
327+
let analytics = MockAnalyticsProvider()
328+
let appCoordinator = makeCoordinator(window: window,
329+
stores: stores,
330+
authenticationManager: authenticationManager,
331+
analytics: WooAnalytics(analyticsProvider: analytics))
332+
333+
// When
334+
appCoordinator.start()
335+
336+
// Then
337+
let indexOfEvent = try XCTUnwrap(analytics.receivedEvents.firstIndex(where: { $0 == "rest_api_login_experiment" }))
338+
let eventProperties = try XCTUnwrap(analytics.receivedProperties[indexOfEvent])
339+
XCTAssertNotNil(eventProperties["experiment_variant"] as? String)
322340
}
323341

324342
// MARK: - Login reminder analytics

0 commit comments

Comments
 (0)