@@ -96,24 +96,26 @@ export async function runSharingChecks({
9696 const browser = page . context ( ) . browser ( )
9797 assert ( browser )
9898 const anonymous = await browser . newContext ( { viewport : { width : 1200 , height : 900 } } )
99- await anonymous . tracing . start ( { screenshots : true , snapshots : true , sources : false } )
100- const publicGet = ( path : string ) =>
101- anonymous . request . get ( new URL ( path , baseUrl ) . href , { timeout : 180_000 } )
102- const visitor = await anonymous . newPage ( )
103- visitor . setDefaultTimeout ( 60_000 )
104- visitor . setDefaultNavigationTimeout ( 180_000 )
105- const browserErrors : string [ ] = [ ]
106- visitor . on ( 'pageerror' , ( error ) => browserErrors . push ( error . message ) )
107- let token = ''
108- let shareId = ''
109- const publicPath = ( ) => `/api/files/public/${ token } `
110- const folderPath = ( ) => `${ publicPath ( ) } /folder`
111- const contentPath = ( fileId : string ) => `${ publicPath ( ) } /content?fileId=${ fileId } `
112- const anonymousJson = ( path : string , expected = 200 ) =>
113- json ( path , { authenticated : false , expected } )
114- const updateShare = ( body : Record < string , unknown > ) => json ( sharePath , { method : 'PUT' , body } )
115-
99+ let tracingStarted = false
116100 try {
101+ await anonymous . tracing . start ( { screenshots : true , snapshots : true , sources : false } )
102+ tracingStarted = true
103+ const publicGet = ( path : string ) =>
104+ anonymous . request . get ( new URL ( path , baseUrl ) . href , { timeout : 180_000 } )
105+ const visitor = await anonymous . newPage ( )
106+ visitor . setDefaultTimeout ( 60_000 )
107+ visitor . setDefaultNavigationTimeout ( 180_000 )
108+ const browserErrors : string [ ] = [ ]
109+ visitor . on ( 'pageerror' , ( error ) => browserErrors . push ( error . message ) )
110+ let token = ''
111+ let shareId = ''
112+ const publicPath = ( ) => `/api/files/public/${ token } `
113+ const folderPath = ( ) => `${ publicPath ( ) } /folder`
114+ const contentPath = ( fileId : string ) => `${ publicPath ( ) } /content?fileId=${ fileId } `
115+ const anonymousJson = ( path : string , expected = 200 ) =>
116+ json ( path , { authenticated : false , expected } )
117+ const updateShare = ( body : Record < string , unknown > ) => json ( sharePath , { method : 'PUT' , body } )
118+
117119 await sql . begin ( async ( tx ) => {
118120 const readerEmail = `files-reader-${ readerId } @files-e2e.test`
119121 await tx `insert into "user" (id, name, email, normalized_email, email_verified, created_at, updated_at)
@@ -613,9 +615,11 @@ export async function runSharingChecks({
613615 )
614616 } finally {
615617 try {
616- await anonymous . tracing . stop ( {
617- path : join ( reportDirectory , 'public-folder-browser-trace.zip' ) ,
618- } )
618+ if ( tracingStarted ) {
619+ await anonymous . tracing . stop ( {
620+ path : join ( reportDirectory , 'public-folder-browser-trace.zip' ) ,
621+ } )
622+ }
619623 } finally {
620624 try {
621625 await anonymous . close ( )
0 commit comments