@@ -3,6 +3,7 @@ import { Event, Scope } from '@sentry/types';
33import { EventType } from 'rrweb' ;
44
55import {
6+ DEFAULT_FLUSH_MIN_DELAY ,
67 MASK_ALL_TEXT_SELECTOR ,
78 MAX_SESSION_LIFE ,
89 REPLAY_SESSION_KEY ,
@@ -336,7 +337,7 @@ describe('Replay', () => {
336337
337338 // There should also not be another attempt at an upload 5 seconds after the last replay event
338339 mockTransportSend . mockClear ( ) ;
339- await advanceTimers ( 5000 ) ;
340+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
340341
341342 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
342343
@@ -348,7 +349,7 @@ describe('Replay', () => {
348349 // Let's make sure it continues to work
349350 mockTransportSend . mockClear ( ) ;
350351 mockRecord . _emitter ( TEST_EVENT ) ;
351- await advanceTimers ( 5000 ) ;
352+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
352353 expect ( replay ) . toHaveLastSentReplay ( { events : JSON . stringify ( [ TEST_EVENT ] ) } ) ;
353354 } ) ;
354355
@@ -402,7 +403,7 @@ describe('Replay', () => {
402403 name : 'click' ,
403404 } ) ;
404405
405- await advanceTimers ( 5000 ) ;
406+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
406407
407408 const newTimestamp = BASE_TIMESTAMP + FIFTEEN_MINUTES ;
408409 const breadcrumbTimestamp = newTimestamp + 20 ; // I don't know where this 20ms comes from
@@ -479,7 +480,7 @@ describe('Replay', () => {
479480 } ) ;
480481
481482 WINDOW . dispatchEvent ( new Event ( 'blur' ) ) ;
482- await advanceTimers ( 5000 ) ;
483+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
483484
484485 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
485486 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
@@ -498,7 +499,7 @@ describe('Replay', () => {
498499
499500 const NEW_TEST_EVENT = {
500501 data : { name : 'test' } ,
501- timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + 5000 + 20 ,
502+ timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + DEFAULT_FLUSH_MIN_DELAY + 20 ,
502503 type : 3 ,
503504 } ;
504505
@@ -509,9 +510,9 @@ describe('Replay', () => {
509510 await new Promise ( process . nextTick ) ;
510511
511512 expect ( replay ) . not . toHaveSameSession ( initialSession ) ;
512- await advanceTimers ( 5000 ) ;
513+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
513514
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
515516 const breadcrumbTimestamp = newTimestamp ;
516517
517518 jest . runAllTimers ( ) ;
@@ -591,13 +592,13 @@ describe('Replay', () => {
591592 throw new Error ( 'Something bad happened' ) ;
592593 } ) ;
593594 mockRecord . _emitter ( TEST_EVENT ) ;
594- await advanceTimers ( 5000 ) ;
595+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
595596
596597 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
597598 mockTransportSend . mockImplementationOnce ( ( ) => {
598599 throw new Error ( 'Something bad happened' ) ;
599600 } ) ;
600- await advanceTimers ( 5000 ) ;
601+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
601602
602603 // next tick should retry and succeed
603604 mockConsole . mockRestore ( ) ;
@@ -625,7 +626,7 @@ describe('Replay', () => {
625626 expect ( replay . session ?. segmentId ) . toBe ( 1 ) ;
626627
627628 // next tick should do nothing
628- await advanceTimers ( 5000 ) ;
629+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
629630 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
630631 } ) ;
631632
@@ -648,12 +649,12 @@ describe('Replay', () => {
648649 } ) ;
649650 mockRecord . _emitter ( TEST_EVENT ) ;
650651
651- await advanceTimers ( 5000 ) ;
652+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
652653
653654 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
654655 expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 1 ) ;
655656
656- await advanceTimers ( 5000 ) ;
657+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
657658 expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 2 ) ;
658659
659660 await advanceTimers ( 10000 ) ;
@@ -865,11 +866,11 @@ describe('Replay', () => {
865866 const TEST_EVENT = { data : { } , timestamp : BASE_TIMESTAMP , type : 2 } ;
866867 mockRecord . _emitter ( TEST_EVENT ) ;
867868
868- await advanceTimers ( 5000 ) ;
869+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
869870 expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
870871
871872 // Make sure there's nothing queued up after
872- await advanceTimers ( 5000 ) ;
873+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
873874 expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
874875 } ) ;
875876} ) ;
0 commit comments