@@ -166,21 +166,7 @@ test.describe( 'Import backup formats', () => {
166166 // The tab's import flow asks for confirmation via a native dialog.
167167 // Record every dialog so a failed import surfaces its message below
168168 // instead of silently timing out on the completion banner.
169- await session . electronApp . evaluate ( ( { dialog } ) => {
170- const dialogGlobal = globalThis as typeof globalThis & { __e2eDialogs ?: string [ ] } ;
171- dialogGlobal . __e2eDialogs = [ ] ;
172- dialog . showMessageBox = ( async ( ...args : unknown [ ] ) => {
173- const options = ( args . length > 1 ? args [ 1 ] : args [ 0 ] ) as {
174- title ?: string ;
175- message ?: string ;
176- detail ?: string ;
177- } ;
178- dialogGlobal . __e2eDialogs ?. push (
179- [ options ?. title , options ?. message , options ?. detail ] . filter ( Boolean ) . join ( ' — ' )
180- ) ;
181- return { response : 0 , checkboxChecked : false } ;
182- } ) as typeof dialog . showMessageBox ;
183- } ) ;
169+ await session . stubMessageBox ( ) ;
184170
185171 const tab = await siteContent . navigateToTab ( 'import-export' ) ;
186172 if ( ! ( 'uploadFile' in tab ) ) {
@@ -190,19 +176,16 @@ test.describe( 'Import backup formats', () => {
190176 // Unlike the new-site flow, the tab's import UI reports completion with
191177 // "Import complete!". Errors are reported via a (stubbed) native dialog,
192178 // so fail fast with the dialog's message rather than timing out.
193- const completeBanner = session . mainWindow . getByText ( 'Import complete!' ) ;
194179 await expect
195180 . poll (
196181 async ( ) => {
197- const dialogs = await session . electronApp . evaluate (
198- ( ) =>
199- ( globalThis as typeof globalThis & { __e2eDialogs ?: string [ ] } ) . __e2eDialogs ?? [ ]
182+ const failure = ( await session . getRecordedDialogs ( ) ) . find ( ( entry ) =>
183+ entry . includes ( 'Failed importing site' )
200184 ) ;
201- const failure = dialogs . find ( ( entry ) => entry . includes ( 'Failed importing site' ) ) ;
202185 if ( failure ) {
203186 throw new Error ( `Import failed: ${ failure } ` ) ;
204187 }
205- return completeBanner . isVisible ( ) ;
188+ return tab . importCompleteBanner . isVisible ( ) ;
206189 } ,
207190 { timeout : 120_000 }
208191 )
0 commit comments