@@ -84,45 +84,37 @@ class UserMergeScenariosTests: XCTestCase, AuthProvider {
84
84
}
85
85
86
86
func testCriteriaNotMetUserIdDefault( ) { // criteria not met with merge default with setUserId
87
- // Setup
88
87
let config = IterableConfig ( )
89
88
config. enableAnonActivation = true
90
89
IterableAPI . initializeForTesting ( apiKey: UserMergeScenariosTests . apiKey,
91
90
config: config,
92
91
networkSession: mockSession,
93
92
localStorage: localStorage)
94
93
IterableAPI . logoutUser ( )
95
-
96
94
guard let jsonData = mockData. data ( using: . utf8) else { return }
97
95
localStorage. criteriaData = jsonData
98
-
99
- // trigger custom event
100
96
IterableAPI . track ( event: " testEvent123 " )
101
97
102
- waitForDuration ( seconds: 1 )
103
-
104
- // Verify no purchase or anon session requests were made initially
105
- XCTAssertNil ( mockSession. getRequest ( withEndPoint: Const . Path. trackAnonSession) ,
106
- " There should not be an anon session request " )
107
- XCTAssertNil ( mockSession. getRequest ( withEndPoint: Const . Path. trackPurchase) ,
108
- " There should not be a purchase request " )
109
-
98
+ if let events = localStorage. anonymousUserEvents {
99
+ XCTAssertFalse ( events. isEmpty, " Expected events to be logged " )
100
+ } else {
101
+ XCTFail ( " Expected events to be logged but found nil " )
102
+ }
110
103
104
+ waitForDuration ( seconds: 1 )
105
+
111
106
IterableAPI . setUserId ( " testuser123 " )
112
-
113
107
if let userId = IterableAPI . userId {
114
108
XCTAssertEqual ( userId, " testuser123 " , " Expected userId to be 'testuser123' " )
115
109
} else {
116
110
XCTFail ( " Expected userId but found nil " )
117
111
}
118
112
waitForDuration ( seconds: 5 )
119
113
120
- // Verify purchase request was made after setting user ID
121
- if let purchaseRequest = mockSession. getRequest ( withEndPoint: Const . Path. trackPurchase) {
122
- XCTAssertNotNil ( purchaseRequest, " Expected purchase request on event replay " )
123
- // Optional: Verify request details if needed
114
+ if localStorage. anonymousUserEvents != nil {
115
+ XCTFail ( " Events are not replayed " )
124
116
} else {
125
- XCTFail ( " No purchase request was made after setting user ID " )
117
+ XCTAssertNil ( localStorage . anonymousUserEvents , " Expected events to be nil " )
126
118
}
127
119
128
120
// Verify "merge user" API call is not made
0 commit comments