@@ -514,6 +514,50 @@ it.live("preview_open reports its navigation timeout instead of the request budg
514514 ) . pipe ( Effect . provide ( layer ) ) ,
515515) ;
516516
517+ it . live ( "an initial download stays available after preview_open reports the navigation error" , ( ) =>
518+ Effect . scoped (
519+ Effect . gen ( function * ( ) {
520+ const { broker, tabId } = yield * ready ;
521+ const manager = yield * Manager . PreviewManager ;
522+ const released = Promise . withResolvers < void > ( ) ;
523+ initialNavigation = async ( ) => {
524+ contexts [ 1 ] ! . page . emit ( "download" , {
525+ failure : async ( ) => null ,
526+ delete : async ( ) => released . resolve ( ) ,
527+ saveAs : ( path : string ) => NodeFSP . writeFile ( path , "a,b" ) ,
528+ suggestedFilename : ( ) => "report.csv" ,
529+ url : ( ) => "http://localhost:1337/report.csv" ,
530+ } ) ;
531+ throw new Error ( "page.goto: Download is starting" ) ;
532+ } ;
533+ const error = yield * broker
534+ . invoke < PreviewAutomationStatus > ( {
535+ scope,
536+ operation : "open" ,
537+ input : { url : "http://localhost:1337/report.csv" , reuseExistingTab : false , open : false } ,
538+ } )
539+ . pipe ( Effect . flip ) ;
540+ expect ( error . message ) . toContain ( "Download is starting" ) ;
541+ yield * Effect . promise ( ( ) => released . promise ) ;
542+ const { sessions } = yield * manager . list ( { threadId : scope . thread . threadId } ) ;
543+ expect ( sessions ) . toHaveLength ( 2 ) ;
544+ const downloadTabId = PreviewTabId . make ( sessions . find ( ( tab ) => tab . tabId !== tabId ) ! . tabId ) ;
545+ const status = yield * broker . invoke < PreviewAutomationStatus > ( {
546+ scope,
547+ tabId : downloadTabId ,
548+ operation : "status" ,
549+ input : { } ,
550+ } ) ;
551+ expect ( status . downloads ) . toEqual ( [
552+ expect . objectContaining ( { fileName : "report.csv" , sizeBytes : 3 } ) ,
553+ ] ) ;
554+ expect ( yield * ( yield * FileSystem . FileSystem ) . readFileString ( status . downloads ! [ 0 ] ! . path ) ) . toBe (
555+ "a,b" ,
556+ ) ;
557+ } ) ,
558+ ) . pipe ( Effect . provide ( layer ) ) ,
559+ ) ;
560+
517561it . live . each ( [ "desktop" as const , undefined ] ) (
518562 "explicit desktop targets ($0 runtime) fail without creating a server tab" ,
519563 ( runtime ) =>
0 commit comments