@@ -3,6 +3,7 @@ import { Event, Scope } from '@sentry/types';
3
3
import { EventType } from 'rrweb' ;
4
4
5
5
import {
6
+ DEFAULT_FLUSH_MIN_DELAY ,
6
7
MASK_ALL_TEXT_SELECTOR ,
7
8
MAX_SESSION_LIFE ,
8
9
REPLAY_SESSION_KEY ,
@@ -336,7 +337,7 @@ describe('Replay', () => {
336
337
337
338
// There should also not be another attempt at an upload 5 seconds after the last replay event
338
339
mockTransportSend . mockClear ( ) ;
339
- await advanceTimers ( 5000 ) ;
340
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
340
341
341
342
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
342
343
@@ -348,7 +349,7 @@ describe('Replay', () => {
348
349
// Let's make sure it continues to work
349
350
mockTransportSend . mockClear ( ) ;
350
351
mockRecord . _emitter ( TEST_EVENT ) ;
351
- await advanceTimers ( 5000 ) ;
352
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
352
353
expect ( replay ) . toHaveLastSentReplay ( { events : JSON . stringify ( [ TEST_EVENT ] ) } ) ;
353
354
} ) ;
354
355
@@ -402,7 +403,7 @@ describe('Replay', () => {
402
403
name : 'click' ,
403
404
} ) ;
404
405
405
- await advanceTimers ( 5000 ) ;
406
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
406
407
407
408
const newTimestamp = BASE_TIMESTAMP + FIFTEEN_MINUTES ;
408
409
const breadcrumbTimestamp = newTimestamp + 20 ; // I don't know where this 20ms comes from
@@ -479,7 +480,7 @@ describe('Replay', () => {
479
480
} ) ;
480
481
481
482
WINDOW . dispatchEvent ( new Event ( 'blur' ) ) ;
482
- await advanceTimers ( 5000 ) ;
483
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
483
484
484
485
expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
485
486
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
@@ -498,7 +499,7 @@ describe('Replay', () => {
498
499
499
500
const NEW_TEST_EVENT = {
500
501
data : { name : 'test' } ,
501
- timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + 5000 + 20 ,
502
+ timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + DEFAULT_FLUSH_MIN_DELAY + 20 ,
502
503
type : 3 ,
503
504
} ;
504
505
@@ -509,9 +510,9 @@ describe('Replay', () => {
509
510
await new Promise ( process . nextTick ) ;
510
511
511
512
expect ( replay ) . not . toHaveSameSession ( initialSession ) ;
512
- await advanceTimers ( 5000 ) ;
513
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
513
514
514
- const newTimestamp = BASE_TIMESTAMP + MAX_SESSION_LIFE + 5000 + 20 ; // I don't know where this 20ms comes from
515
+ const newTimestamp = BASE_TIMESTAMP + MAX_SESSION_LIFE + DEFAULT_FLUSH_MIN_DELAY + 20 ; // I don't know where this 20ms comes from
515
516
const breadcrumbTimestamp = newTimestamp ;
516
517
517
518
jest . runAllTimers ( ) ;
@@ -591,13 +592,13 @@ describe('Replay', () => {
591
592
throw new Error ( 'Something bad happened' ) ;
592
593
} ) ;
593
594
mockRecord . _emitter ( TEST_EVENT ) ;
594
- await advanceTimers ( 5000 ) ;
595
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
595
596
596
597
expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
597
598
mockTransportSend . mockImplementationOnce ( ( ) => {
598
599
throw new Error ( 'Something bad happened' ) ;
599
600
} ) ;
600
- await advanceTimers ( 5000 ) ;
601
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
601
602
602
603
// next tick should retry and succeed
603
604
mockConsole . mockRestore ( ) ;
@@ -625,7 +626,7 @@ describe('Replay', () => {
625
626
expect ( replay . session ?. segmentId ) . toBe ( 1 ) ;
626
627
627
628
// next tick should do nothing
628
- await advanceTimers ( 5000 ) ;
629
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
629
630
expect ( replay ) . not . toHaveLastSentReplay ( ) ;
630
631
} ) ;
631
632
@@ -648,12 +649,12 @@ describe('Replay', () => {
648
649
} ) ;
649
650
mockRecord . _emitter ( TEST_EVENT ) ;
650
651
651
- await advanceTimers ( 5000 ) ;
652
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
652
653
653
654
expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
654
655
expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 1 ) ;
655
656
656
- await advanceTimers ( 5000 ) ;
657
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
657
658
expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 2 ) ;
658
659
659
660
await advanceTimers ( 10000 ) ;
@@ -865,11 +866,11 @@ describe('Replay', () => {
865
866
const TEST_EVENT = { data : { } , timestamp : BASE_TIMESTAMP , type : 2 } ;
866
867
mockRecord . _emitter ( TEST_EVENT ) ;
867
868
868
- await advanceTimers ( 5000 ) ;
869
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
869
870
expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
870
871
871
872
// Make sure there's nothing queued up after
872
- await advanceTimers ( 5000 ) ;
873
+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
873
874
expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
874
875
} ) ;
875
876
} ) ;
0 commit comments