@@ -96,9 +96,6 @@ describe('Integration | errorSampleRate', () => {
96
96
] ) ,
97
97
} ) ;
98
98
99
- jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
100
- await new Promise ( process . nextTick ) ;
101
-
102
99
// This is from when we stop recording and start a session recording
103
100
expect ( replay ) . toHaveLastSentReplay ( {
104
101
recordingPayloadHeader : { segment_id : 1 } ,
@@ -110,6 +107,20 @@ describe('Integration | errorSampleRate', () => {
110
107
] ) ,
111
108
} ) ;
112
109
110
+ jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
111
+
112
+ // New checkout when we call `startRecording` again after uploading segment
113
+ // after an error occurs
114
+ expect ( replay ) . toHaveLastSentReplay ( {
115
+ recordingData : JSON . stringify ( [
116
+ {
117
+ data : { isCheckout : true } ,
118
+ timestamp : BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + 40 ,
119
+ type : 2 ,
120
+ } ,
121
+ ] ) ,
122
+ } ) ;
123
+
113
124
// Check that click will get captured
114
125
domHandler ( {
115
126
name : 'click' ,
@@ -119,15 +130,14 @@ describe('Integration | errorSampleRate', () => {
119
130
await new Promise ( process . nextTick ) ;
120
131
121
132
expect ( replay ) . toHaveLastSentReplay ( {
122
- recordingPayloadHeader : { segment_id : 2 } ,
123
133
recordingData : JSON . stringify ( [
124
134
{
125
135
type : 5 ,
126
- timestamp : BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80 ,
136
+ timestamp : BASE_TIMESTAMP + 10000 + 60 ,
127
137
data : {
128
138
tag : 'breadcrumb' ,
129
139
payload : {
130
- timestamp : ( BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80 ) / 1000 ,
140
+ timestamp : ( BASE_TIMESTAMP + 10000 + 60 ) / 1000 ,
131
141
type : 'default' ,
132
142
category : 'ui.click' ,
133
143
message : '<unknown>' ,
@@ -620,10 +630,6 @@ describe('Integration | errorSampleRate', () => {
620
630
621
631
expect ( replay ) . toHaveLastSentReplay ( ) ;
622
632
623
- // Flush from calling `stopRecording`
624
- jest . runAllTimers ( )
625
- await new Promise ( process . nextTick ) ;
626
-
627
633
// Now wait after session expires - should stop recording
628
634
mockRecord . takeFullSnapshot . mockClear ( ) ;
629
635
( getCurrentHub ( ) . getClient ( ) ! . getTransport ( ) ! . send as unknown as jest . SpyInstance < any > ) . mockClear ( ) ;
@@ -730,9 +736,10 @@ it('sends a replay after loading the session multiple times', async () => {
730
736
captureException ( new Error ( 'testing' ) ) ;
731
737
732
738
await new Promise ( process . nextTick ) ;
733
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
739
+ jest . advanceTimersByTime ( DEFAULT_FLUSH_MIN_DELAY ) ;
740
+ await new Promise ( process . nextTick ) ;
734
741
735
- expect ( replay ) . toHaveLastSentReplay ( {
742
+ expect ( replay ) . toHaveSentReplay ( {
736
743
recordingPayloadHeader : { segment_id : 0 } ,
737
744
recordingData : JSON . stringify ( [
738
745
{ data : { isCheckout : true } , timestamp : BASE_TIMESTAMP , type : 2 } ,
@@ -741,11 +748,10 @@ it('sends a replay after loading the session multiple times', async () => {
741
748
] ) ,
742
749
} ) ;
743
750
744
- await advanceTimers ( DEFAULT_FLUSH_MIN_DELAY ) ;
745
751
// Latest checkout when we call `startRecording` again after uploading segment
746
752
// after an error occurs (e.g. when we switch to session replay recording)
747
753
expect ( replay ) . toHaveLastSentReplay ( {
748
754
recordingPayloadHeader : { segment_id : 1 } ,
749
- recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 10040 , type : 2 } ] ) ,
755
+ recordingData : JSON . stringify ( [ { data : { isCheckout : true } , timestamp : BASE_TIMESTAMP + 5040 , type : 2 } ] ) ,
750
756
} ) ;
751
757
} ) ;
0 commit comments