@@ -29,7 +29,7 @@ sentryTest(
2929 let errorEventId : string | undefined ;
3030 const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
3131 const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
32- // const reqPromise2 = waitForReplayRequest(page, 2);
32+ const reqPromise2 = waitForReplayRequest ( page , 2 ) ;
3333 const reqErrorPromise = waitForErrorRequest ( page ) ;
3434
3535 await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
@@ -100,18 +100,21 @@ sentryTest(
100100
101101 await page . click ( '#log' ) ;
102102 await page . click ( '#go-background' ) ;
103- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
104103
105- // Switches to session mode
106- expect ( callsToSentry ) . toEqual ( 4 ) ;
104+ // Switches to session mode and then goes to background
107105 const req1 = await reqPromise1 ;
106+ const req2 = await reqPromise2 ;
107+ expect ( callsToSentry ) . toEqual ( 5 ) ;
108108
109109 const event0 = getReplayEvent ( req0 ) ;
110110 const content0 = getReplayRecordingContent ( req0 ) ;
111111
112112 const event1 = getReplayEvent ( req1 ) ;
113113 const content1 = getReplayRecordingContent ( req1 ) ;
114114
115+ const event2 = getReplayEvent ( req2 ) ;
116+ const content2 = getReplayRecordingContent ( req2 ) ;
117+
115118 expect ( event0 ) . toEqual (
116119 getExpectedReplayEvent ( {
117120 contexts : { replay : { error_sample_rate : 0 , session_sample_rate : 0 } } ,
@@ -150,31 +153,30 @@ sentryTest(
150153 expect ( event1 ) . toEqual (
151154 getExpectedReplayEvent ( {
152155 contexts : { replay : { error_sample_rate : 0 , session_sample_rate : 0 } } ,
156+ replay_start_timestamp : undefined ,
153157 replay_type : 'buffer' , // although we're in session mode, we still send 'buffer' as replay_type
154158 segment_id : 1 ,
155159 urls : [ ] ,
156160 } ) ,
157161 ) ;
158162
159- //
160- expect ( content1 . fullSnapshots ) . toHaveLength ( 0 ) ;
163+ // From switching to session mode
164+ expect ( content1 . fullSnapshots ) . toHaveLength ( 1 ) ;
165+
166+ expect ( event2 ) . toEqual (
167+ getExpectedReplayEvent ( {
168+ contexts : { replay : { error_sample_rate : 0 , session_sample_rate : 0 } } ,
169+ replay_start_timestamp : undefined ,
170+ replay_type : 'buffer' , // although we're in session mode, we still send 'buffer' as replay_type
171+ segment_id : 2 ,
172+ urls : [ ] ,
173+ } ) ,
174+ ) ;
161175
162- expect ( content1 . breadcrumbs ) . toEqual (
176+ expect ( content2 . fullSnapshots ) . toHaveLength ( 0 ) ;
177+ expect ( content2 . breadcrumbs ) . toEqual (
163178 expect . arrayContaining ( [
164- {
165- ...expectedClickBreadcrumb ,
166- message : 'body > button#log' ,
167- data : {
168- node : {
169- attributes : { id : 'log' } ,
170- id : expect . any ( Number ) ,
171- tagName : 'button' ,
172- textContent : '*** ***** ** *** *******' ,
173- } ,
174- nodeId : expect . any ( Number ) ,
175- } ,
176- } ,
177- { ...expectedConsoleBreadcrumb , level : 'log' , message : 'Some message' } ,
179+ expectedClickBreadcrumb ,
178180 ] ) ,
179181 ) ;
180182 } ,
0 commit comments