1
1
import { expect } from '@playwright/test' ;
2
2
3
- import { sentryTest } from '../../../utils/fixtures' ;
3
+ import { TEST_HOST , sentryTest } from '../../../utils/fixtures' ;
4
4
import {
5
5
expectedCLSPerformanceSpan ,
6
6
expectedClickBreadcrumb ,
@@ -30,7 +30,7 @@ well as the correct DOM snapshots and updates are recorded and sent.
30
30
*/
31
31
sentryTest (
32
32
'record page navigations and performance entries across multiple pages' ,
33
- async ( { getLocalTestPath , page, browserName } ) => {
33
+ async ( { getLocalTestUrl , page, browserName } ) => {
34
34
// We only test this against the NPM package and replay bundles
35
35
// and only on chromium as most performance entries are only available in chromium
36
36
if ( shouldSkipReplayTest ( ) || browserName !== 'chromium' ) {
@@ -48,7 +48,7 @@ sentryTest(
48
48
const reqPromise8 = waitForReplayRequest ( page , 8 ) ;
49
49
const reqPromise9 = waitForReplayRequest ( page , 9 ) ;
50
50
51
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
51
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
52
52
53
53
const [ req0 ] = await Promise . all ( [ reqPromise0 , page . goto ( url ) ] ) ;
54
54
const replayEvent0 = getReplayEvent ( req0 ) ;
@@ -72,7 +72,7 @@ sentryTest(
72
72
const collectedPerformanceSpans = [ ...recording0 . performanceSpans , ...recording1 . performanceSpans ] ;
73
73
const collectedBreadcrumbs = [ ...recording0 . breadcrumbs , ...recording1 . breadcrumbs ] ;
74
74
75
- expect ( collectedPerformanceSpans . length ) . toEqual ( 8 ) ;
75
+ expect ( collectedPerformanceSpans . length ) . toBeGreaterThanOrEqual ( 6 ) ;
76
76
expect ( collectedPerformanceSpans ) . toEqual (
77
77
expect . arrayContaining ( [
78
78
expectedNavigationPerformanceSpan ,
@@ -112,7 +112,7 @@ sentryTest(
112
112
const collectedPerformanceSpansAfterReload = [ ...recording2 . performanceSpans , ...recording3 . performanceSpans ] ;
113
113
const collectedBreadcrumbsAdterReload = [ ...recording2 . breadcrumbs , ...recording3 . breadcrumbs ] ;
114
114
115
- expect ( collectedPerformanceSpansAfterReload . length ) . toEqual ( 8 ) ;
115
+ expect ( collectedPerformanceSpansAfterReload . length ) . toBeGreaterThanOrEqual ( 6 ) ;
116
116
expect ( collectedPerformanceSpansAfterReload ) . toEqual (
117
117
expect . arrayContaining ( [
118
118
expectedReloadPerformanceSpan ,
@@ -146,7 +146,8 @@ sentryTest(
146
146
url : expect . stringContaining ( 'page-0.html' ) ,
147
147
headers : {
148
148
// @ts -expect-error this is fine
149
- 'User-Agent' : expect . stringContaining ( '' ) ,
149
+ 'User-Agent' : expect . any ( String ) ,
150
+ Referer : `${ TEST_HOST } /index.html` ,
150
151
} ,
151
152
} ,
152
153
} ) ,
@@ -168,7 +169,8 @@ sentryTest(
168
169
url : expect . stringContaining ( 'page-0.html' ) ,
169
170
headers : {
170
171
// @ts -expect-error this is fine
171
- 'User-Agent' : expect . stringContaining ( '' ) ,
172
+ 'User-Agent' : expect . any ( String ) ,
173
+ Referer : `${ TEST_HOST } /index.html` ,
172
174
} ,
173
175
} ,
174
176
} ) ,
@@ -210,13 +212,12 @@ sentryTest(
210
212
getExpectedReplayEvent ( {
211
213
segment_id : 6 ,
212
214
urls : [ '/spa' ] ,
213
-
214
215
request : {
215
- // @ts -expect-error this is fine
216
- url : expect . stringContaining ( 'page-0.html' ) ,
216
+ url : `${ TEST_HOST } /spa` ,
217
217
headers : {
218
218
// @ts -expect-error this is fine
219
- 'User-Agent' : expect . stringContaining ( '' ) ,
219
+ 'User-Agent' : expect . any ( String ) ,
220
+ Referer : `${ TEST_HOST } /index.html` ,
220
221
} ,
221
222
} ,
222
223
} ) ,
@@ -235,11 +236,11 @@ sentryTest(
235
236
urls : [ ] ,
236
237
237
238
request : {
238
- // @ts -expect-error this is fine
239
- url : expect . stringContaining ( 'page-0.html' ) ,
239
+ url : `${ TEST_HOST } /spa` ,
240
240
headers : {
241
241
// @ts -expect-error this is fine
242
- 'User-Agent' : expect . stringContaining ( '' ) ,
242
+ 'User-Agent' : expect . any ( String ) ,
243
+ Referer : `${ TEST_HOST } /index.html` ,
243
244
} ,
244
245
} ,
245
246
} ) ,
@@ -279,6 +280,14 @@ sentryTest(
279
280
expect ( replayEvent8 ) . toEqual (
280
281
getExpectedReplayEvent ( {
281
282
segment_id : 8 ,
283
+ request : {
284
+ url : `${ TEST_HOST } /index.html` ,
285
+ headers : {
286
+ // @ts -expect-error this is fine
287
+ 'User-Agent' : expect . any ( String ) ,
288
+ Referer : `${ TEST_HOST } /spa` ,
289
+ } ,
290
+ } ,
282
291
} ) ,
283
292
) ;
284
293
expect ( normalize ( recording8 . fullSnapshots ) ) . toMatchSnapshot ( 'seg-8-snap-full' ) ;
@@ -293,6 +302,14 @@ sentryTest(
293
302
getExpectedReplayEvent ( {
294
303
segment_id : 9 ,
295
304
urls : [ ] ,
305
+ request : {
306
+ url : `${ TEST_HOST } /index.html` ,
307
+ headers : {
308
+ // @ts -expect-error this is fine
309
+ 'User-Agent' : expect . any ( String ) ,
310
+ Referer : `${ TEST_HOST } /spa` ,
311
+ } ,
312
+ } ,
296
313
} ) ,
297
314
) ;
298
315
expect ( recording9 . fullSnapshots . length ) . toEqual ( 0 ) ;
@@ -304,7 +321,7 @@ sentryTest(
304
321
] ;
305
322
const collectedBreadcrumbsAfterIndexNavigation = [ ...recording8 . breadcrumbs , ...recording9 . breadcrumbs ] ;
306
323
307
- expect ( collectedPerformanceSpansAfterIndexNavigation . length ) . toEqual ( 8 ) ;
324
+ expect ( collectedPerformanceSpansAfterIndexNavigation . length ) . toBeGreaterThanOrEqual ( 6 ) ;
308
325
expect ( collectedPerformanceSpansAfterIndexNavigation ) . toEqual (
309
326
expect . arrayContaining ( [
310
327
expectedNavigationPerformanceSpan ,
0 commit comments