@@ -2,6 +2,7 @@ import { getCurrentHub } from '@sentry/core';
22import { EventType } from 'rrweb' ;
33
44import {
5+ DEFAULT_FLUSH_MIN_DELAY ,
56 MASK_ALL_TEXT_SELECTOR ,
67 MAX_SESSION_LIFE ,
78 REPLAY_SESSION_KEY ,
@@ -335,7 +336,7 @@ describe('Replay', () => {
335336
336337 // There should also not be another attempt at an upload 5 seconds after the last replay event
337338 mockTransportSend . mockClear ( ) ;
338- await advanceTimers ( 5000 ) ;
339+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
339340
340341 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
341342
@@ -347,7 +348,7 @@ describe('Replay', () => {
347348 // Let's make sure it continues to work
348349 mockTransportSend . mockClear ( ) ;
349350 mockRecord . _emitter ( TEST_EVENT ) ;
350- await advanceTimers ( 5000 ) ;
351+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
351352 expect ( replay ) . toHaveLastSentReplay ( { events : JSON . stringify ( [ TEST_EVENT ] ) } ) ;
352353 } ) ;
353354
@@ -401,7 +402,7 @@ describe('Replay', () => {
401402 name : 'click' ,
402403 } ) ;
403404
404- await advanceTimers ( 5000 ) ;
405+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
405406
406407 const newTimestamp = BASE_TIMESTAMP + FIFTEEN_MINUTES ;
407408 const breadcrumbTimestamp = newTimestamp + 20 ; // I don't know where this 20ms comes from
@@ -478,7 +479,7 @@ describe('Replay', () => {
478479 } ) ;
479480
480481 WINDOW . dispatchEvent ( new Event ( 'blur' ) ) ;
481- await advanceTimers ( 5000 ) ;
482+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
482483
483484 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
484485 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
@@ -497,7 +498,7 @@ describe('Replay', () => {
497498
498499 const NEW_TEST_EVENT = {
499500 data : { name : 'test' } ,
500- timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + 5000 + 20 ,
501+ timestamp : BASE_TIMESTAMP + MAX_SESSION_LIFE + DEFAULT_FLUSH_MIN_DELAY + 20 ,
501502 type : 3 ,
502503 } ;
503504
@@ -508,9 +509,9 @@ describe('Replay', () => {
508509 await new Promise ( process . nextTick ) ;
509510
510511 expect ( replay ) . not . toHaveSameSession ( initialSession ) ;
511- await advanceTimers ( 5000 ) ;
512+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
512513
513- const newTimestamp = BASE_TIMESTAMP + MAX_SESSION_LIFE + 5000 + 20 ; // I don't know where this 20ms comes from
514+ const newTimestamp = BASE_TIMESTAMP + MAX_SESSION_LIFE + DEFAULT_FLUSH_MIN_DELAY + 20 ; // I don't know where this 20ms comes from
514515 const breadcrumbTimestamp = newTimestamp ;
515516
516517 jest . runAllTimers ( ) ;
@@ -590,13 +591,13 @@ describe('Replay', () => {
590591 throw new Error ( 'Something bad happened' ) ;
591592 } ) ;
592593 mockRecord . _emitter ( TEST_EVENT ) ;
593- await advanceTimers ( 5000 ) ;
594+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
594595
595596 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
596597 mockTransportSend . mockImplementationOnce ( ( ) => {
597598 throw new Error ( 'Something bad happened' ) ;
598599 } ) ;
599- await advanceTimers ( 5000 ) ;
600+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
600601
601602 // next tick should retry and succeed
602603 mockConsole . mockRestore ( ) ;
@@ -624,7 +625,7 @@ describe('Replay', () => {
624625 expect ( replay . session ?. segmentId ) . toBe ( 1 ) ;
625626
626627 // next tick should do nothing
627- await advanceTimers ( 5000 ) ;
628+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
628629 expect ( replay ) . not . toHaveLastSentReplay ( ) ;
629630 } ) ;
630631
@@ -647,12 +648,12 @@ describe('Replay', () => {
647648 } ) ;
648649 mockRecord . _emitter ( TEST_EVENT ) ;
649650
650- await advanceTimers ( 5000 ) ;
651+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
651652
652653 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
653654 expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 1 ) ;
654655
655- await advanceTimers ( 5000 ) ;
656+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
656657 expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 2 ) ;
657658
658659 await advanceTimers ( 10000 ) ;
@@ -758,7 +759,7 @@ describe('Replay', () => {
758759 } ) ;
759760 mockRecord . _emitter ( TEST_EVENT ) ;
760761
761- await advanceTimers ( 5000 ) ;
762+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
762763
763764 expect ( mockRecord . takeFullSnapshot ) . not . toHaveBeenCalled ( ) ;
764765
@@ -770,7 +771,7 @@ describe('Replay', () => {
770771 mockSendReplayRequest . mockImplementationOnce ( ( ) => {
771772 throw new Error ( 'Something bad happened' ) ;
772773 } ) ;
773- await advanceTimers ( 5000 ) ;
774+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
774775 expect ( replay . sendReplayRequest ) . toHaveBeenCalledTimes ( 2 ) ;
775776
776777 // next tick should retry and fail
@@ -912,11 +913,11 @@ describe('Replay', () => {
912913 const TEST_EVENT = { data : { } , timestamp : BASE_TIMESTAMP , type : 2 } ;
913914 mockRecord . _emitter ( TEST_EVENT ) ;
914915
915- await advanceTimers ( 5000 ) ;
916+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
916917 expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
917918
918919 // Make sure there's nothing queued up after
919- await advanceTimers ( 5000 ) ;
920+ await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
920921 expect ( replay . flush ) . toHaveBeenCalledTimes ( 1 ) ;
921922 } ) ;
922923} ) ;
0 commit comments