Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions e2e/blueprints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { E2ESession } from './e2e-helpers';
import MainSidebar from './page-objects/main-sidebar';
import Onboarding from './page-objects/onboarding';
import SiteContent from './page-objects/site-content';
import WhatsNewModal from './page-objects/whats-new-modal';
import { getUrlWithAutoLogin } from './utils';

test.describe( 'Blueprints', () => {
Expand All @@ -14,14 +13,9 @@ test.describe( 'Blueprints', () => {
test.beforeAll( async () => {
await session.launch();

// Complete onboarding before tests
const onboarding = new Onboarding( session.mainWindow );
await onboarding.completeOnboarding();

const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, DEFAULT_SITE_NAME );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down
8 changes: 1 addition & 7 deletions e2e/import-export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test';
import { E2ESession } from './e2e-helpers';
import Onboarding from './page-objects/onboarding';
import SiteContent from './page-objects/site-content';
import WhatsNewModal from './page-objects/whats-new-modal';
import type { MessageBoxOptions } from 'electron';

const global = globalThis as unknown as {
Expand All @@ -17,14 +16,9 @@ test.describe( 'Import / Export', () => {
test.beforeAll( async () => {
await session.launch();

// Complete onboarding before tests
const onboarding = new Onboarding( session.mainWindow );
await onboarding.completeOnboarding();

const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, defaultSiteName );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down
8 changes: 1 addition & 7 deletions e2e/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { E2ESession } from './e2e-helpers';
import MainSidebar from './page-objects/main-sidebar';
import Onboarding from './page-objects/onboarding';
import SiteContent from './page-objects/site-content';
import WhatsNewModal from './page-objects/whats-new-modal';

/**
* Import Tests
Expand All @@ -29,14 +28,9 @@ test.describe( 'Import', () => {
test.beforeAll( async () => {
await session.launch();

// Complete onboarding before tests
const onboarding = new Onboarding( session.mainWindow );
await onboarding.completeOnboarding();

const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, defaultSiteName );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down
17 changes: 2 additions & 15 deletions e2e/localization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ test.describe( 'Localization', () => {
test.beforeAll( async () => {
await session.launch();

// Complete onboarding before tests
const onboarding = new Onboarding( session.mainWindow );
await onboarding.completeOnboarding();

const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, 'My WordPress Website' );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down Expand Up @@ -101,15 +96,7 @@ test.describe( 'Localization', () => {
// Onboarding not visible, continue with test
}

const whatsNewModal = new WhatsNewModal( session.mainWindow );
try {
const visible = await whatsNewModal.locator.isVisible( { timeout: 2000 } );
if ( visible ) {
await whatsNewModal.closeButton.click();
}
} catch ( error ) {
// What's New modal not visible, continue with test
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, 'My WordPress Website' );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down
6 changes: 1 addition & 5 deletions e2e/overview-customize-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ test.describe( 'Overview customize links', () => {

const onboarding = new Onboarding( session.mainWindow );
await onboarding.completeOnboarding( { customSiteName: siteName } );

const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.close();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, siteName );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand Down
5 changes: 5 additions & 0 deletions e2e/page-objects/add-site-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import SiteForm from './site-form';
export default class AddSiteModal {
constructor( private page: Page ) {}

async open() {
await this.page.getByTestId( 'add-site-button' ).click();
await expect( this.locator ).toBeVisible();
}

get locator() {
return this.page.getByRole( 'dialog' );
}
Expand Down
16 changes: 7 additions & 9 deletions e2e/page-objects/main-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class MainSidebar {
}

get addSiteButton() {
return this.page.getByTestId( 'add-site-button' );
return this.locator.getByTestId( 'add-site-button' );
}

getSiteNavButton( siteName: string ) {
Expand All @@ -20,15 +20,13 @@ export default class MainSidebar {
async openAddSiteModal() {
const isButtonVisible = await this.addSiteButton.isVisible().catch( () => false );

if ( isButtonVisible ) {
// Sites exist - need to open the modal
await this.addSiteButton.click();
const dialog = new AddSiteModal( this.page );
await expect( dialog.locator ).toBeVisible();
return dialog;
if ( ! isButtonVisible ) {
throw new Error( 'Add Site button not found on the main sidebar' );
Copy link
Contributor Author

@nightnei nightnei Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to keep this function more specific, since if it's not available in UI then we can mute an error

Also, with the current use case - there is no such thing as "sidebar" inside onboarding, so it's a bit misleading to create MainSidebar and running openAddSiteModal, instead of directly running new AddSiteModal.

}

// No Add Site button visible means we're on empty screen - content is directly on page (no dialog wrapper)
return new AddSiteModal( this.page );
await this.addSiteButton.click();
const dialog = new AddSiteModal( this.page );
await expect( dialog.locator ).toBeVisible();
return dialog;
}
}
14 changes: 11 additions & 3 deletions e2e/page-objects/onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type Page } from '@playwright/test';
import { expect } from '@playwright/test';
import MainSidebar from './main-sidebar';
import AddSiteModal from './add-site-modal';
import WhatsNewModal from './whats-new-modal';

export default class Onboarding {
constructor( private page: Page ) {}
Expand All @@ -20,8 +21,8 @@ export default class Onboarding {

await expect( this.heading ).toBeVisible();
await this.locator.getByRole( 'button', { name: 'Skip →' } ).click();
const sidebar = new MainSidebar( this.page );
const modal = await sidebar.openAddSiteModal();
const modal = new AddSiteModal( this.page );
await modal.open();
await modal.createSiteButton.click();

if ( customSiteName ) {
Expand All @@ -42,4 +43,11 @@ export default class Onboarding {
localPath,
};
}

async closeWhatsNew() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved closeWhatsNew to onboarding to avoid duplications and keep consistency

const whatsNewModal = new WhatsNewModal( this.page );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
}
}
4 changes: 0 additions & 4 deletions e2e/page-objects/whats-new-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@ export default class WhatsNewModal {
get closeButton() {
return this.locator.getByRole( 'button', { name: 'Close' } );
}

async close() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it

await this.closeButton.click();
}
}
10 changes: 1 addition & 9 deletions e2e/sites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { E2ESession } from './e2e-helpers';
import MainSidebar from './page-objects/main-sidebar';
import Onboarding from './page-objects/onboarding';
import SiteContent from './page-objects/site-content';
import WhatsNewModal from './page-objects/whats-new-modal';
import { getUrlWithAutoLogin } from './utils';

const skipTestOnWindows = process.platform === 'win32' ? test.skip : test;
Expand All @@ -35,7 +34,7 @@ test.describe( 'Servers', () => {
customFolderName,
} );

await closeWhatsNew();
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, siteName );
await expect( siteContent.siteNameHeading ).toBeVisible( { timeout: 120_000 } );
Expand All @@ -46,13 +45,6 @@ test.describe( 'Servers', () => {
};
}

async function closeWhatsNew() {
const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
}

test.afterEach( async () => {
await session.cleanup();
} );
Expand Down
7 changes: 1 addition & 6 deletions metrics/tests/site-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ test.describe( 'Site Editor Load Metrics', () => {
// Wait for store initialization to complete (provider constants loading)
await new Promise( ( resolve ) => setTimeout( resolve, 500 ) );
await onboarding.completeOnboarding( { customSiteName: siteName } );

// Handle the What's New modal if it appears
const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

const siteContent = new SiteContent( session.mainWindow, siteName );

Expand Down
7 changes: 1 addition & 6 deletions metrics/tests/site-startup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ test.describe( 'Startup Metrics', () => {
await expect( onboarding.heading ).toBeVisible();
const startTime = Date.now();
await onboarding.completeOnboarding();

// Handle the What's New modal if it appears
const whatsNewModal = new WhatsNewModal( session.mainWindow );
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
await whatsNewModal.closeButton.click();
}
await onboarding.closeWhatsNew();

siteContent = new SiteContent( session.mainWindow, siteName );
await expect( siteContent.runningButton ).toBeAttached();
Expand Down
Loading