@@ -4,6 +4,11 @@ import { E2ESession } from './e2e-helpers';
44import Onboarding from './page-objects/onboarding' ;
55import SiteContent from './page-objects/site-content' ;
66import WhatsNewModal from './page-objects/whats-new-modal' ;
7+ import type { MessageBoxOptions } from 'electron' ;
8+
9+ const global = globalThis as unknown as {
10+ testDialogCalls ?: MessageBoxOptions [ ] ;
11+ } ;
712
813test . describe ( 'Import / Export' , ( ) => {
914 const session = new E2ESession ( ) ;
@@ -54,13 +59,13 @@ test.describe( 'Import / Export', () => {
5459 // See: https://github.com/microsoft/playwright/issues/21432
5560 await session . electronApp . evaluate ( ( { dialog } ) => {
5661 // Create storage for dialog calls
57- ( global as any ) . testDialogCalls = [ ] ;
62+ global . testDialogCalls = [ ] ;
5863
5964 // Mock the function to track calls
60- dialog . showMessageBox = async ( ...args : any [ ] ) => {
65+ dialog . showMessageBox = async ( ...args : unknown [ ] ) => {
6166 // Store the call details
62- const options = args . length === 2 ? args [ 1 ] : args [ 0 ] ;
63- ( global as any ) . testDialogCalls . push ( options ) ;
67+ const options = ( args . length === 2 ? args [ 1 ] : args [ 0 ] ) as MessageBoxOptions ;
68+ global . testDialogCalls ? .push ( options ) ;
6469
6570 // Auto-confirm by clicking the first button
6671 return { response : 0 , checkboxChecked : false } ;
@@ -74,30 +79,31 @@ test.describe( 'Import / Export', () => {
7479 await importExportTab . uploadFile ( invalidSqlPath ) ;
7580
7681 // Wait for the error dialog to be shown (after the confirmation dialog)
77- let dialogCalls : any [ ] = [ ] ;
78- let errorDialog : any ;
79- await expect . poll (
80- async ( ) => {
81- dialogCalls = await session . electronApp . evaluate ( ( ) => {
82- return ( global as any ) . testDialogCalls || [ ] ;
83- } ) ;
84- // Look for the error dialog specifically
85- errorDialog = dialogCalls . find (
86- ( call : any ) =>
87- call . type === 'error' &&
88- ( call . title ?. includes ( 'Failed importing site' ) ||
89- call . message ?. includes ( 'Failed importing site' ) )
90- ) ;
91- return errorDialog ;
92- } ,
93- {
94- timeout : 15000 ,
95- message : 'Expected error dialog to be shown' ,
96- }
97- ) . toBeDefined ( ) ;
82+ let errorDialog : MessageBoxOptions | undefined ;
83+ await expect
84+ . poll (
85+ async ( ) => {
86+ const dialogCalls : MessageBoxOptions [ ] = await session . electronApp . evaluate (
87+ ( ) => global . testDialogCalls || [ ]
88+ ) ;
89+ // Look for the error dialog specifically
90+ errorDialog = dialogCalls . find (
91+ ( call ) =>
92+ call . type === 'error' &&
93+ ( call . title ?. includes ( 'Failed importing site' ) ||
94+ call . message ?. includes ( 'Failed importing site' ) )
95+ ) ;
96+ return errorDialog ;
97+ } ,
98+ {
99+ timeout : 15000 ,
100+ message : 'Expected error dialog to be shown' ,
101+ }
102+ )
103+ . toBeDefined ( ) ;
98104
99105 expect ( errorDialog ) . toBeDefined ( ) ;
100- expect ( errorDialog . type ) . toBe ( 'error' ) ;
101- expect ( errorDialog . title || errorDialog . message ) . toContain ( 'Failed importing site' ) ;
106+ expect ( errorDialog ? .type ) . toBe ( 'error' ) ;
107+ expect ( errorDialog ? .title || errorDialog ? .message ) . toContain ( 'Failed importing site' ) ;
102108 } ) ;
103109} ) ;
0 commit comments