Skip to content

Commit 2547549

Browse files
Merge c87551e into 9c75104
2 parents 9c75104 + c87551e commit 2547549

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

e2e/import-export.test.ts

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { E2ESession } from './e2e-helpers';
44
import Onboarding from './page-objects/onboarding';
55
import SiteContent from './page-objects/site-content';
66
import 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

813
test.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
} );

e2e/page-objects/site-content.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { type Page, expect } from '@playwright/test';
2-
import SettingsTab from './settings-tab';
32
import ImportExportTab from './import-export-tab';
4-
5-
type TabMap = {
6-
'Preview': SettingsTab;
7-
'Settings': SettingsTab;
8-
'Import / Export': ImportExportTab;
9-
};
3+
import SettingsTab from './settings-tab';
104

115
export default class SiteContent {
126
constructor(
@@ -48,7 +42,9 @@ export default class SiteContent {
4842

4943
async navigateToTab( tabName: 'Settings' ): Promise< SettingsTab >;
5044
async navigateToTab( tabName: 'Import / Export' ): Promise< ImportExportTab >;
51-
async navigateToTab( tabName: 'Preview' | 'Settings' | 'Import / Export' ): Promise< SettingsTab | ImportExportTab > {
45+
async navigateToTab(
46+
tabName: 'Preview' | 'Settings' | 'Import / Export'
47+
): Promise< SettingsTab | ImportExportTab > {
5248
const tabButton = this.getTabButton( tabName );
5349
await tabButton.click();
5450

0 commit comments

Comments
 (0)