@@ -35,6 +35,7 @@ export type TestFixtures = {
3535 testDir : string ;
3636 skipRouteHandler ?: boolean ;
3737 skipDsnRouteHandler ?: boolean ;
38+ handleLazyLoadedFeedback ?: boolean ;
3839 } ) => Promise < string > ;
3940 forceFlushReplay : ( ) => Promise < string > ;
4041 enableConsole : ( ) => void ;
@@ -58,55 +59,59 @@ const sentryTest = base.extend<TestFixtures>({
5859 ] ,
5960
6061 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` ;
6365
64- const tmpDir = path . join ( testDir , 'dist' , crypto . randomUUID ( ) ) ;
66+ const tmpDir = path . join ( testDir , 'dist' , crypto . randomUUID ( ) ) ;
6567
66- await build ( testDir , tmpDir ) ;
68+ await build ( testDir , tmpDir ) ;
6769
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+ }
7375
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+ } ) ;
8083 } ) ;
81- } ) ;
82- }
84+ }
8385
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 } ` ) ;
8789
88- return fs . existsSync ( filePath ) ? route . fulfill ( { path : filePath } ) : route . continue ( ) ;
89- } ) ;
90+ return fs . existsSync ( filePath ) ? route . fulfill ( { path : filePath } ) : route . continue ( ) ;
91+ } ) ;
9092
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+ } ) ;
99102
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+ } ) ;
104110 }
105- return route . fulfill ( { path : filePath } ) ;
106- } ) ;
107111
108- return pagePath ;
109- } ) ;
112+ return pagePath ;
113+ } ,
114+ ) ;
110115 } ,
111116 runInChromium : ( { runInSingleBrowser } , use ) => {
112117 return use ( ( fn , args ) => runInSingleBrowser ( 'chromium' , fn , args ) ) ;
0 commit comments