@@ -99,9 +99,6 @@ describe('Integration | errorSampleRate', () => {
99
99
] ) ,
100
100
} ) ;
101
101
102
- jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
103
- await new Promise ( process . nextTick ) ;
104
-
105
102
// This is from when we stop recording and start a session recording
106
103
expect ( replay ) . toHaveLastSentReplay ( {
107
104
recordingPayloadHeader : { segment_id : 1 } ,
@@ -119,6 +116,20 @@ describe('Integration | errorSampleRate', () => {
119
116
] ) ,
120
117
} ) ;
121
118
119
+ jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
120
+
121
+ // New checkout when we call `startRecording` again after uploading segment
122
+ // after an error occurs
123
+ expect ( replay ) . toHaveLastSentReplay ( {
124
+ recordingData : JSON . stringify ( [
125
+ {
126
+ data : { isCheckout : true } ,
127
+ timestamp : BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + 40 ,
128
+ type : 2 ,
129
+ } ,
130
+ ] ) ,
131
+ } ) ;
132
+
122
133
// Check that click will get captured
123
134
domHandler ( {
124
135
name : 'click' ,
@@ -128,15 +139,14 @@ describe('Integration | errorSampleRate', () => {
128
139
await new Promise ( process . nextTick ) ;
129
140
130
141
expect ( replay ) . toHaveLastSentReplay ( {
131
- recordingPayloadHeader : { segment_id : 2 } ,
132
142
recordingData : JSON . stringify ( [
133
143
{
134
144
type : 5 ,
135
- timestamp : BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80 ,
145
+ timestamp : BASE_TIMESTAMP + 10000 + 60 ,
136
146
data : {
137
147
tag : 'breadcrumb' ,
138
148
payload : {
139
- timestamp : ( BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80 ) / 1000 ,
149
+ timestamp : ( BASE_TIMESTAMP + 10000 + 60 ) / 1000 ,
140
150
type : 'default' ,
141
151
category : 'ui.click' ,
142
152
message : '<unknown>' ,
@@ -527,10 +537,6 @@ describe('Integration | errorSampleRate', () => {
527
537
528
538
expect ( replay ) . toHaveLastSentReplay ( ) ;
529
539
530
- // Flush from calling `stopRecording`
531
- jest . runAllTimers ( )
532
- await new Promise ( process . nextTick ) ;
533
-
534
540
// Now wait after session expires - should stop recording
535
541
mockRecord . takeFullSnapshot . mockClear ( ) ;
536
542
( getCurrentHub ( ) . getClient ( ) ! . getTransport ( ) ! . send as unknown as jest . SpyInstance < any > ) . mockClear ( ) ;
@@ -632,16 +638,16 @@ it('sends a replay after loading the session multiple times', async () => {
632
638
captureException ( new Error ( 'testing' ) ) ;
633
639
634
640
await new Promise ( process . nextTick ) ;
635
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
641
+ jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
642
+ await new Promise ( process . nextTick ) ;
636
643
637
- expect ( replay ) . toHaveLastSentReplay ( {
644
+ expect ( replay ) . toHaveSentReplay ( {
638
645
recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP , type : 2 } , TEST_EVENT ] ) ,
639
646
} ) ;
640
647
641
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
642
648
// Latest checkout when we call `startRecording` again after uploading segment
643
649
// after an error occurs (e.g. when we switch to session replay recording)
644
650
expect ( replay ) . toHaveLastSentReplay ( {
645
- recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 10040 , type : 2 } ] ) ,
651
+ recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 5040 , type : 2 } ] ) ,
646
652
} ) ;
647
653
} ) ;
0 commit comments