@@ -59,10 +59,9 @@ describe("TelemetryRetryManager", () => {
5959 it ( "should start retry timer" , async ( ) => {
6060 retryManager . start ( )
6161
62- // Should process immediately on start
63- await vi . waitFor ( ( ) => {
64- expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
65- } )
62+ // Should process immediately on start (after setTimeout)
63+ await vi . advanceTimersByTimeAsync ( 0 )
64+ expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
6665
6766 // Advance timer and run pending timers
6867 await vi . advanceTimersByTimeAsync ( 30000 )
@@ -77,10 +76,9 @@ describe("TelemetryRetryManager", () => {
7776 retryManager . start ( )
7877 retryManager . start ( )
7978
80- // Should only process once on start
81- await vi . waitFor ( ( ) => {
82- expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
83- } )
79+ // Should only process once on start (after setTimeout)
80+ await vi . advanceTimersByTimeAsync ( 0 )
81+ expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
8482
8583 // Advance timer
8684 await vi . advanceTimersByTimeAsync ( 30000 )
@@ -94,10 +92,9 @@ describe("TelemetryRetryManager", () => {
9492 it ( "should stop retry timer" , async ( ) => {
9593 retryManager . start ( )
9694
97- // Should process immediately on start
98- await vi . waitFor ( ( ) => {
99- expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
100- } )
95+ // Should process immediately on start (after setTimeout)
96+ await vi . advanceTimersByTimeAsync ( 0 )
97+ expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalledTimes ( 1 )
10198
10299 // Advance timer once
103100 await vi . advanceTimersByTimeAsync ( 30000 )
@@ -168,7 +165,8 @@ describe("TelemetryRetryManager", () => {
168165
169166 retryManager . start ( )
170167
171- // Wait for immediate processing to complete
168+ // Wait for immediate processing to complete (after setTimeout)
169+ await vi . advanceTimersByTimeAsync ( 0 )
172170 await vi . waitFor ( ( ) => {
173171 expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalled ( )
174172 } )
@@ -198,7 +196,8 @@ describe("TelemetryRetryManager", () => {
198196
199197 retryManager . start ( )
200198
201- // Wait for immediate processing to complete
199+ // Wait for immediate processing to complete (after setTimeout)
200+ await vi . advanceTimersByTimeAsync ( 0 )
202201 await vi . waitFor ( ( ) => {
203202 expect ( mockQueue . updateEventAfterRetry ) . toHaveBeenCalled ( )
204203 } )
@@ -222,7 +221,8 @@ describe("TelemetryRetryManager", () => {
222221
223222 retryManager . start ( )
224223
225- // Wait for immediate processing to complete
224+ // Wait for immediate processing to complete (after setTimeout)
225+ await vi . advanceTimersByTimeAsync ( 0 )
226226 await vi . waitFor ( ( ) => {
227227 expect ( mockQueue . updateEventAfterRetry ) . toHaveBeenCalled ( )
228228 } )
@@ -250,7 +250,8 @@ describe("TelemetryRetryManager", () => {
250250
251251 retryManager . start ( )
252252
253- // Wait for immediate processing to complete
253+ // Wait for immediate processing to complete (after setTimeout)
254+ await vi . advanceTimersByTimeAsync ( 0 )
254255 await vi . waitFor ( ( ) => {
255256 expect ( connectionStatusCallback ) . toHaveBeenCalled ( )
256257 } )
@@ -285,7 +286,8 @@ describe("TelemetryRetryManager", () => {
285286
286287 retryManager . start ( )
287288
288- // Wait for immediate processing to complete
289+ // Wait for immediate processing to complete (after setTimeout)
290+ await vi . advanceTimersByTimeAsync ( 0 )
289291 await vi . waitFor ( ( ) => {
290292 expect ( mockQueue . pruneFailedEvents ) . toHaveBeenCalled ( )
291293 } )
@@ -334,7 +336,8 @@ describe("TelemetryRetryManager", () => {
334336
335337 retryManager . start ( )
336338
337- // Wait for immediate processing to complete
339+ // Wait for immediate processing to complete (after setTimeout)
340+ await vi . advanceTimersByTimeAsync ( 0 )
338341 await vi . waitFor ( ( ) => {
339342 expect ( mockQueue . getEventsForRetry ) . toHaveBeenCalled ( )
340343 } )
@@ -373,7 +376,8 @@ describe("TelemetryRetryManager", () => {
373376
374377 retryManager . start ( )
375378
376- // Wait for immediate processing to complete
379+ // Wait for immediate processing to complete (after setTimeout)
380+ await vi . advanceTimersByTimeAsync ( 0 )
377381 await vi . waitFor ( ( ) => {
378382 expect ( connectionStatusCallback ) . toHaveBeenCalled ( )
379383 } )
0 commit comments