Skip to content

Commit

Permalink
test: Delete site E2E case supports native dialogs
Browse files Browse the repository at this point in the history
Playwright lacks support for interacting with native dialogs, so we mock
the dialog module to simulate the user clicking the "Delete site"
confirmation button with "Delete site files from my computer" checked.

See: microsoft/playwright#2143
See: microsoft/playwright#8278 (comment)
  • Loading branch information
dcalhoun committed May 29, 2024
1 parent 547c532 commit 97a822e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
23 changes: 0 additions & 23 deletions e2e/page-objects/delete-site-modal.ts

This file was deleted.

4 changes: 0 additions & 4 deletions e2e/page-objects/settings-tab.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type Page, type ElectronApplication, expect } from '@playwright/test';
import DeleteSiteModal from './delete-site-modal';

export default class SettingsTab {
constructor(
Expand Down Expand Up @@ -39,8 +38,5 @@ export default class SettingsTab {

async openDeleteSiteModal() {
await this.deleteButton.click();
const modal = new DeleteSiteModal( this.page, this.siteName );
await expect( modal.locator ).toBeVisible();
return modal;
}
}
18 changes: 11 additions & 7 deletions e2e/sites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,20 @@ test.describe( 'Servers', () => {
expect( await page.title() ).toBe( 'testing site title' );
} );

test.fixme( 'delete site', async () => {
// Test doesn't work currently as we migrated from the in-app modal
// to native dialog, and native dialogs can't be tested by Playwright.
// See: https://github.com/microsoft/playwright/issues/21432
test( 'delete site', async () => {
const siteContent = new SiteContent( mainWindow, siteName );
const settingsTab = await siteContent.navigateToTab( 'Settings' );

const modal = await settingsTab.openDeleteSiteModal();
await modal.deleteFilesCheckbox.check();
modal.deleteSiteButton.click();
// Playwright lacks support for interacting with native dialogs, so we mock
// the dialog module to simulate the user clicking the "Delete site"
// confirmation button with "Delete site files from my computer" checked.
// See: https://github.com/microsoft/playwright/issues/21432
await electronApp.evaluate( ( { dialog } ) => {
dialog.showMessageBox = async () => {
return { response: 0, checkboxChecked: true };
};
} );
await settingsTab.openDeleteSiteModal();

await mainWindow.waitForTimeout( 200 ); // Short pause for site to delete.

Expand Down

0 comments on commit 97a822e

Please sign in to comment.