@@ -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>' ,
@@ -631,10 +641,6 @@ describe('Integration | errorSampleRate', () => {
631
641
632
642
expect ( replay ) . toHaveLastSentReplay ( ) ;
633
643
634
- // Flush from calling `stopRecording`
635
- jest . runAllTimers ( )
636
- await new Promise ( process . nextTick ) ;
637
-
638
644
// Now wait after session expires - should stop recording
639
645
mockRecord . takeFullSnapshot . mockClear ( ) ;
640
646
( getCurrentHub ( ) . getClient ( ) ! . getTransport ( ) ! . send as unknown as jest . SpyInstance < any > ) . mockClear ( ) ;
@@ -740,16 +746,16 @@ it('sends a replay after loading the session multiple times', async () => {
740
746
captureException ( new Error ( 'testing' ) ) ;
741
747
742
748
await new Promise ( process . nextTick ) ;
743
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
749
+ jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
750
+ await new Promise ( process . nextTick ) ;
744
751
745
- expect ( replay ) . toHaveLastSentReplay ( {
752
+ expect ( replay ) . toHaveSentReplay ( {
746
753
recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP , type : 2 } , TEST_EVENT ] ) ,
747
754
} ) ;
748
755
749
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
750
756
// Latest checkout when we call `startRecording` again after uploading segment
751
757
// after an error occurs (e.g. when we switch to session replay recording)
752
758
expect ( replay ) . toHaveLastSentReplay ( {
753
- recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 10040 , type : 2 } ] ) ,
759
+ recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 5040 , type : 2 } ] ) ,
754
760
} ) ;
755
761
} ) ;
0 commit comments