@@ -59,14 +59,14 @@ final class E2EEventTests: XCTestCase {
5959 }
6060
6161 // getVariationValue() is logging events using another dispatch queue, we need to wait a few secs
62- try await Task . sleep ( nanoseconds: 10_000_000 )
62+ try await Task . sleep ( nanoseconds: 2_000_000_000 ) // 2 seconds
6363 let events = try component. dataModule. eventSQLDao. getEvents ( )
6464 // It includes the Latency and ResponseSize metrics
6565 XCTAssertTrue ( events. count >= 5 )
6666 XCTAssertTrue ( events. contains { event in
6767 if case . evaluation = event. type,
68- case . evaluation( let data) = event. event,
69- case . ` default` = data. reason. type {
68+ case . evaluation( let data) = event. event,
69+ case . default = data. reason. type {
7070 return true
7171 }
7272 return false
@@ -97,6 +97,17 @@ final class E2EEventTests: XCTestCase {
9797 }
9898 }
9999 } )
100+
101+ // Wait for the event to be added
102+ try await Task . sleep ( nanoseconds: 2_000_000_000 ) // 2 seconds
103+
104+ // After clearing evaluations, we expect 2 metrics events (Latency and ResponseSize)
105+ client. assert ( expectedEventCount: 2 )
106+
107+ // Wait for the clear operation to complete
108+ try await Task . sleep ( nanoseconds: 300_000_000 ) // 300 milliseconds
109+
110+ // Make variation calls to generate default evaluation events
100111 XCTAssertEqual ( client. stringVariation ( featureId: FEATURE_ID_STRING, defaultValue: " value-default " ) , " value-default " )
101112 XCTAssertEqual ( client. intVariation ( featureId: FEATURE_ID_INT, defaultValue: 100 ) , 100 )
102113 XCTAssertEqual ( client. doubleVariation ( featureId: FEATURE_ID_DOUBLE, defaultValue: 3.0 ) , 3.0 )
@@ -108,15 +119,16 @@ final class E2EEventTests: XCTestCase {
108119 return
109120 }
110121
111- // getVariationValue() is logging events using another dispatch queue, we need to wait a few secs
112- try await Task . sleep ( nanoseconds: 10_000_000 )
122+ // Wait for events to be processed
123+ try await Task . sleep ( nanoseconds: 2_000_000_000 ) // 2 seconds
124+
113125 let events = try component. dataModule. eventSQLDao. getEvents ( )
114126 // It includes the Latency and ResponseSize metrics
115- XCTAssertTrue ( events. count >= 5 )
127+ XCTAssertTrue ( events. count >= 7 , " Expected at least 7 events but got \( events . count ) " )
116128 XCTAssertTrue ( events. contains { event in
117129 if case . evaluation = event. type,
118- case . evaluation( let data) = event. event,
119- case . client = data. reason. type {
130+ case . evaluation( let data) = event. event,
131+ case . client = data. reason. type {
120132 return true
121133 }
122134 return false
0 commit comments