@@ -35,6 +35,7 @@ export type TestFixtures = {
35
35
testDir : string ;
36
36
skipRouteHandler ?: boolean ;
37
37
skipDsnRouteHandler ?: boolean ;
38
+ handleLazyLoadedFeedback ?: boolean ;
38
39
} ) => Promise < string > ;
39
40
forceFlushReplay : ( ) => Promise < string > ;
40
41
enableConsole : ( ) => void ;
@@ -58,55 +59,59 @@ const sentryTest = base.extend<TestFixtures>({
58
59
] ,
59
60
60
61
getLocalTestUrl : ( { page } , use ) => {
61
- return use ( async ( { testDir, skipRouteHandler = false , skipDsnRouteHandler = false } ) => {
62
- const pagePath = `${ TEST_HOST } /index.html` ;
62
+ return use (
63
+ async ( { testDir, skipRouteHandler = false , skipDsnRouteHandler = false , handleLazyLoadedFeedback = false } ) => {
64
+ const pagePath = `${ TEST_HOST } /index.html` ;
63
65
64
- const tmpDir = path . join ( testDir , 'dist' , crypto . randomUUID ( ) ) ;
66
+ const tmpDir = path . join ( testDir , 'dist' , crypto . randomUUID ( ) ) ;
65
67
66
- await build ( testDir , tmpDir ) ;
68
+ await build ( testDir , tmpDir ) ;
67
69
68
- // If skipping route handlers we return the tmp dir instead of adding the handler
69
- // This way, this can be handled by the caller manually
70
- if ( skipRouteHandler ) {
71
- return tmpDir ;
72
- }
70
+ // If skipping route handlers we return the tmp dir instead of adding the handler
71
+ // This way, this can be handled by the caller manually
72
+ if ( skipRouteHandler ) {
73
+ return tmpDir ;
74
+ }
73
75
74
- if ( ! skipDsnRouteHandler ) {
75
- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
76
- return route . fulfill ( {
77
- status : 200 ,
78
- contentType : 'application/json' ,
79
- body : JSON . stringify ( { id : 'test-id' } ) ,
76
+ if ( ! skipDsnRouteHandler ) {
77
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
78
+ return route . fulfill ( {
79
+ status : 200 ,
80
+ contentType : 'application/json' ,
81
+ body : JSON . stringify ( { id : 'test-id' } ) ,
82
+ } ) ;
80
83
} ) ;
81
- } ) ;
82
- }
84
+ }
83
85
84
- await page . route ( `${ TEST_HOST } /*.*` , route => {
85
- const file = route . request ( ) . url ( ) . split ( '/' ) . pop ( ) ;
86
- const filePath = path . resolve ( tmpDir , `./${ file } ` ) ;
86
+ await page . route ( `${ TEST_HOST } /*.*` , route => {
87
+ const file = route . request ( ) . url ( ) . split ( '/' ) . pop ( ) ;
88
+ const filePath = path . resolve ( tmpDir , `./${ file } ` ) ;
87
89
88
- return fs . existsSync ( filePath ) ? route . fulfill ( { path : filePath } ) : route . continue ( ) ;
89
- } ) ;
90
+ return fs . existsSync ( filePath ) ? route . fulfill ( { path : filePath } ) : route . continue ( ) ;
91
+ } ) ;
90
92
91
- // Ensure feedback can be lazy loaded
92
- await page . route ( `https://browser.sentry-cdn.com/${ SDK_VERSION } /feedback-modal.min.js` , route => {
93
- const filePath = path . resolve ( tmpDir , './feedback-modal.bundle.js' ) ;
94
- if ( ! fs . existsSync ( filePath ) ) {
95
- throw new Error ( `Feedback modal bundle (${ filePath } ) not found` ) ;
96
- }
97
- return route . fulfill ( { path : filePath } ) ;
98
- } ) ;
93
+ if ( handleLazyLoadedFeedback ) {
94
+ // Ensure feedback can be lazy loaded
95
+ await page . route ( `https://browser.sentry-cdn.com/${ SDK_VERSION } /feedback-modal.min.js` , route => {
96
+ const filePath = path . resolve ( tmpDir , './feedback-modal.bundle.js' ) ;
97
+ if ( ! fs . existsSync ( filePath ) ) {
98
+ throw new Error ( `Feedback modal bundle (${ filePath } ) not found` ) ;
99
+ }
100
+ return route . fulfill ( { path : filePath } ) ;
101
+ } ) ;
99
102
100
- await page . route ( `https://browser.sentry-cdn.com/${ SDK_VERSION } /feedback-screenshot.min.js` , route => {
101
- const filePath = path . resolve ( tmpDir , './feedback-screenshot.bundle.js' ) ;
102
- if ( ! fs . existsSync ( filePath ) ) {
103
- throw new Error ( `Feedback screenshot bundle (${ filePath } ) not found` ) ;
103
+ await page . route ( `https://browser.sentry-cdn.com/${ SDK_VERSION } /feedback-screenshot.min.js` , route => {
104
+ const filePath = path . resolve ( tmpDir , './feedback-screenshot.bundle.js' ) ;
105
+ if ( ! fs . existsSync ( filePath ) ) {
106
+ throw new Error ( `Feedback screenshot bundle (${ filePath } ) not found` ) ;
107
+ }
108
+ return route . fulfill ( { path : filePath } ) ;
109
+ } ) ;
104
110
}
105
- return route . fulfill ( { path : filePath } ) ;
106
- } ) ;
107
111
108
- return pagePath ;
109
- } ) ;
112
+ return pagePath ;
113
+ } ,
114
+ ) ;
110
115
} ,
111
116
runInChromium : ( { runInSingleBrowser } , use ) => {
112
117
return use ( ( fn , args ) => runInSingleBrowser ( 'chromium' , fn , args ) ) ;
0 commit comments