@@ -9,12 +9,12 @@ import {
99 shouldSkipTracingTest ,
1010} from '../../../../utils/helpers' ;
1111
12- sentryTest ( 'creates a new trace on each navigation' , async ( { getLocalTestPath , page } ) => {
12+ sentryTest ( 'creates a new trace on each navigation' , async ( { getLocalTestUrl , page } ) => {
1313 if ( shouldSkipTracingTest ( ) ) {
1414 sentryTest . skip ( ) ;
1515 }
1616
17- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
17+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
1818
1919 await getFirstSentryEnvelopeRequest ( page , url ) ;
2020
@@ -32,6 +32,9 @@ sentryTest('creates a new trace on each navigation', async ({ getLocalTestPath,
3232 const navigation1TraceContext = navigation1Event . contexts ?. trace ;
3333 const navigation2TraceContext = navigation2Event . contexts ?. trace ;
3434
35+ expect ( navigation1Event . type ) . toEqual ( 'transaction' ) ;
36+ expect ( navigation2Event . type ) . toEqual ( 'transaction' ) ;
37+
3538 expect ( navigation1TraceContext ) . toMatchObject ( {
3639 op : 'navigation' ,
3740 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -65,12 +68,12 @@ sentryTest('creates a new trace on each navigation', async ({ getLocalTestPath,
6568 expect ( navigation1TraceContext ?. trace_id ) . not . toEqual ( navigation2TraceContext ?. trace_id ) ;
6669} ) ;
6770
68- sentryTest ( 'error after navigation has navigation traceId' , async ( { getLocalTestPath , page } ) => {
71+ sentryTest ( 'error after navigation has navigation traceId' , async ( { getLocalTestUrl , page } ) => {
6972 if ( shouldSkipTracingTest ( ) ) {
7073 sentryTest . skip ( ) ;
7174 }
7275
73- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
76+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
7477
7578 // ensure pageload transaction is finished
7679 await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -82,6 +85,8 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
8285 ) ;
8386 const navigationTraceContext = navigationEvent . contexts ?. trace ;
8487
88+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
89+
8590 expect ( navigationTraceContext ) . toMatchObject ( {
8691 op : 'navigation' ,
8792 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -105,6 +110,8 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
105110 await page . locator ( '#errorBtn' ) . click ( ) ;
106111 const [ errorEvent , errorTraceHeader ] = await errorEventPromise ;
107112
113+ expect ( errorEvent . type ) . toEqual ( undefined ) ;
114+
108115 const errorTraceContext = errorEvent . contexts ?. trace ;
109116 expect ( errorTraceContext ) . toEqual ( {
110117 trace_id : navigationTraceContext ?. trace_id ,
@@ -119,12 +126,12 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes
119126 } ) ;
120127} ) ;
121128
122- sentryTest ( 'error during navigation has new navigation traceId' , async ( { getLocalTestPath , page } ) => {
129+ sentryTest ( 'error during navigation has new navigation traceId' , async ( { getLocalTestUrl , page } ) => {
123130 if ( shouldSkipTracingTest ( ) ) {
124131 sentryTest . skip ( ) ;
125132 }
126133
127- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
134+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
128135
129136 // ensure navigation transaction is finished
130137 await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -143,6 +150,9 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
143150 const [ navigationEvent , navigationTraceHeader ] = envelopes . find ( envelope => envelope [ 0 ] . type === 'transaction' ) ! ;
144151 const [ errorEvent , errorTraceHeader ] = envelopes . find ( envelope => ! envelope [ 0 ] . type ) ! ;
145152
153+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
154+ expect ( errorEvent . type ) . toEqual ( undefined ) ;
155+
146156 const navigationTraceContext = navigationEvent ?. contexts ?. trace ;
147157 expect ( navigationTraceContext ) . toMatchObject ( {
148158 op : 'navigation' ,
@@ -161,14 +171,6 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
161171
162172 const errorTraceContext = errorEvent ?. contexts ?. trace ;
163173 expect ( errorTraceContext ) . toEqual ( {
164- data : {
165- 'sentry.op' : 'navigation' ,
166- 'sentry.origin' : 'auto.navigation.browser' ,
167- 'sentry.sample_rate' : 1 ,
168- 'sentry.source' : 'url' ,
169- } ,
170- op : 'navigation' ,
171- origin : 'auto.navigation.browser' ,
172174 trace_id : navigationTraceContext ?. trace_id ,
173175 span_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 16 } $ / ) ,
174176 } ) ;
@@ -184,12 +186,20 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc
184186
185187sentryTest (
186188 'outgoing fetch request after navigation has navigation traceId in headers' ,
187- async ( { getLocalTestPath , page } ) => {
189+ async ( { getLocalTestUrl , page } ) => {
188190 if ( shouldSkipTracingTest ( ) ) {
189191 sentryTest . skip ( ) ;
190192 }
191193
192- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
194+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
195+
196+ await page . route ( 'http://example.com/**' , route => {
197+ return route . fulfill ( {
198+ status : 200 ,
199+ contentType : 'application/json' ,
200+ body : JSON . stringify ( { } ) ,
201+ } ) ;
202+ } ) ;
193203
194204 // ensure navigation transaction is finished
195205 await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -201,6 +211,8 @@ sentryTest(
201211 ) ;
202212
203213 const navigationTraceContext = navigationEvent . contexts ?. trace ;
214+
215+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
204216 expect ( navigationTraceContext ) . toMatchObject ( {
205217 op : 'navigation' ,
206218 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -232,12 +244,20 @@ sentryTest(
232244
233245sentryTest (
234246 'outgoing fetch request during navigation has navigation traceId in headers' ,
235- async ( { getLocalTestPath , page } ) => {
247+ async ( { getLocalTestUrl , page } ) => {
236248 if ( shouldSkipTracingTest ( ) ) {
237249 sentryTest . skip ( ) ;
238250 }
239251
240- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
252+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
253+
254+ await page . route ( 'http://example.com/**' , route => {
255+ return route . fulfill ( {
256+ status : 200 ,
257+ contentType : 'application/json' ,
258+ body : JSON . stringify ( { } ) ,
259+ } ) ;
260+ } ) ;
241261
242262 // ensure navigation transaction is finished
243263 await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
@@ -256,6 +276,8 @@ sentryTest(
256276 ] ) ;
257277
258278 const navigationTraceContext = navigationEvent . contexts ?. trace ;
279+
280+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
259281 expect ( navigationTraceContext ) . toMatchObject ( {
260282 op : 'navigation' ,
261283 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -284,12 +306,20 @@ sentryTest(
284306
285307sentryTest (
286308 'outgoing XHR request after navigation has navigation traceId in headers' ,
287- async ( { getLocalTestPath , page } ) => {
309+ async ( { getLocalTestUrl , page } ) => {
288310 if ( shouldSkipTracingTest ( ) ) {
289311 sentryTest . skip ( ) ;
290312 }
291313
292- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
314+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
315+
316+ await page . route ( 'http://example.com/**' , route => {
317+ return route . fulfill ( {
318+ status : 200 ,
319+ contentType : 'application/json' ,
320+ body : JSON . stringify ( { } ) ,
321+ } ) ;
322+ } ) ;
293323
294324 // ensure navigation transaction is finished
295325 await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -301,6 +331,8 @@ sentryTest(
301331 ) ;
302332
303333 const navigationTraceContext = navigationEvent . contexts ?. trace ;
334+
335+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
304336 expect ( navigationTraceContext ) . toMatchObject ( {
305337 op : 'navigation' ,
306338 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
@@ -332,12 +364,20 @@ sentryTest(
332364
333365sentryTest (
334366 'outgoing XHR request during navigation has navigation traceId in headers' ,
335- async ( { getLocalTestPath , page } ) => {
367+ async ( { getLocalTestUrl , page } ) => {
336368 if ( shouldSkipTracingTest ( ) ) {
337369 sentryTest . skip ( ) ;
338370 }
339371
340- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
372+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
373+
374+ await page . route ( 'http://example.com/**' , route => {
375+ return route . fulfill ( {
376+ status : 200 ,
377+ contentType : 'application/json' ,
378+ body : JSON . stringify ( { } ) ,
379+ } ) ;
380+ } ) ;
341381
342382 // ensure navigation transaction is finished
343383 await getFirstSentryEnvelopeRequest ( page , url ) ;
@@ -356,6 +396,8 @@ sentryTest(
356396 ] ) ;
357397
358398 const navigationTraceContext = navigationEvent . contexts ?. trace ;
399+
400+ expect ( navigationEvent . type ) . toEqual ( 'transaction' ) ;
359401 expect ( navigationTraceContext ) . toMatchObject ( {
360402 op : 'navigation' ,
361403 trace_id : expect . stringMatching ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ,
0 commit comments