Skip to content

Commit f579b7b

Browse files
authored
Merge d0e1908 into 22d72d8
2 parents 22d72d8 + d0e1908 commit f579b7b

20 files changed

Lines changed: 241 additions & 501 deletions

‎e2e/blueprints.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ test.describe( 'Blueprints', () => {
1616

1717
// Complete onboarding before tests
1818
const onboarding = new Onboarding( session.mainWindow );
19-
await expect( onboarding.heading ).toBeVisible();
20-
await onboarding.continueButton.click();
19+
await onboarding.completeOnboarding();
2120

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

‎e2e/import-export.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ test.describe( 'Import / Export', () => {
1919

2020
// Complete onboarding before tests
2121
const onboarding = new Onboarding( session.mainWindow );
22-
await expect( onboarding.heading ).toBeVisible();
23-
await onboarding.continueButton.click();
22+
await onboarding.completeOnboarding();
2423

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

‎e2e/import.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ test.describe( 'Import', () => {
3131

3232
// Complete onboarding before tests
3333
const onboarding = new Onboarding( session.mainWindow );
34-
await expect( onboarding.heading ).toBeVisible();
35-
await onboarding.continueButton.click();
34+
await onboarding.completeOnboarding();
3635

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

‎e2e/localization.test.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ test.describe( 'Localization', () => {
4545

4646
// Complete onboarding before tests
4747
const onboarding = new Onboarding( session.mainWindow );
48-
await expect( onboarding.heading ).toBeVisible();
49-
await onboarding.continueButton.click();
48+
await onboarding.completeOnboarding();
5049

5150
const whatsNewModal = new WhatsNewModal( session.mainWindow );
5251
if ( await whatsNewModal.locator.isVisible( { timeout: 5000 } ) ) {
@@ -96,7 +95,7 @@ test.describe( 'Localization', () => {
9695
try {
9796
const visible = await onboarding.heading.isVisible( { timeout: 2000 } );
9897
if ( visible ) {
99-
await onboarding.continueButton.click();
98+
await onboarding.completeOnboarding();
10099
}
101100
} catch ( error ) {
102101
// Onboarding not visible, continue with test

‎e2e/overview-customize-links.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ test.describe( 'Overview customize links', () => {
7575
await session.launch();
7676

7777
const onboarding = new Onboarding( session.mainWindow );
78-
await expect( onboarding.heading ).toBeVisible();
79-
await onboarding.siteNameInput.fill( siteName );
80-
await onboarding.continueButton.click();
78+
await onboarding.completeOnboarding( { customSiteName: siteName } );
8179

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

‎e2e/page-objects/add-site-modal.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export default class AddSiteModal {
5050
return this.page.getByTestId( 'stepper-action-button' );
5151
}
5252

53-
async selectLocalPathForTesting() {
54-
await this.siteForm.clickLocalPathButtonAndSelectFromEnv();
53+
async selectLocalPathForTesting( partialExpectedPath: string ) {
54+
await this.siteForm.clickLocalPathButtonAndSelectFromEnv( partialExpectedPath );
5555
}
5656

5757
async selectBlueprintFile( filePath: string ) {

‎e2e/page-objects/onboarding.ts‎

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { type Page } from '@playwright/test';
2-
import SiteForm from './site-form';
2+
import { expect } from '@playwright/test';
3+
import AddSiteModal from './add-site-modal';
4+
import MainSidebar from './main-sidebar';
35

46
export default class Onboarding {
57
constructor( private page: Page ) {}
@@ -8,27 +10,63 @@ export default class Onboarding {
810
return this.page.getByTestId( 'onboarding' );
911
}
1012

11-
private get siteForm() {
12-
return new SiteForm( this.page );
13-
}
14-
1513
get heading() {
16-
return this.locator.getByRole( 'heading', { name: 'Add your first site' } );
14+
return this.locator.getByRole( 'heading', {
15+
name: /Connect to your WordPress.com account|Add your first site/,
16+
} );
1717
}
1818

19-
get siteNameInput() {
20-
return this.siteForm.siteNameInput;
21-
}
19+
async completeOnboarding( options?: { customSiteName?: string; customFolderName?: string } ) {
20+
const { customSiteName, customFolderName } = options ?? {};
2221

23-
get localPathInput() {
24-
return this.siteForm.localPathInput;
25-
}
22+
await expect( this.heading ).toBeVisible();
2623

27-
get continueButton() {
28-
return this.locator.getByRole( 'button', { name: /Continue|Add site/ } );
29-
}
24+
if (
25+
await this.locator
26+
.getByRole( 'heading', { name: 'Connect to your WordPress.com account' } )
27+
.isVisible()
28+
) {
29+
await this.locator.getByRole( 'button', { name: 'Skip →' } ).click();
30+
const sidebar = new MainSidebar( this.page );
31+
const modal = await sidebar.openAddSiteModal();
32+
await modal.createSiteButton.click();
33+
34+
if ( customSiteName ) {
35+
await modal.siteNameInput.fill( customSiteName );
36+
}
37+
await expect( modal.siteNameInput ).toHaveValue( /\S+/, { timeout: 5000 } );
38+
const siteName = await modal.siteNameInput.inputValue();
39+
40+
if ( customFolderName ) {
41+
await modal.selectLocalPathForTesting( customFolderName );
42+
}
43+
const localPath = await modal.localPathInput.inputValue();
44+
45+
await modal.continueButton.click();
46+
47+
return {
48+
siteName,
49+
localPath,
50+
};
51+
} else {
52+
const modal = new AddSiteModal( this.page );
53+
if ( customSiteName ) {
54+
await modal.siteNameInput.fill( customSiteName );
55+
}
56+
await expect( modal.siteNameInput ).toHaveValue( /\S+/, { timeout: 5000 } );
57+
const siteName = await modal.siteNameInput.inputValue();
58+
59+
if ( customFolderName ) {
60+
await modal.selectLocalPathForTesting( customFolderName );
61+
}
62+
const localPath = await modal.localPathInput.inputValue();
63+
64+
await this.page.getByRole( 'button', { name: 'Continue' } ).click();
3065

31-
async selectLocalPathForTesting( partialExpectedPath: string ) {
32-
await this.siteForm.clickLocalPathButtonAndSelectFromEnv( partialExpectedPath );
66+
return {
67+
siteName,
68+
localPath,
69+
};
70+
}
3371
}
3472
}

‎e2e/site-navigation.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ test.describe( 'Site Navigation', () => {
4343

4444
// Complete onboarding before tests
4545
const onboarding = new Onboarding( session.mainWindow );
46-
await expect( onboarding.heading ).toBeVisible();
47-
await onboarding.continueButton.click();
46+
await onboarding.completeOnboarding();
4847

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

‎e2e/sites.test.ts‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,10 @@ test.describe( 'Servers', () => {
3030
await session.launch( env );
3131

3232
const onboarding = new Onboarding( session.mainWindow );
33-
34-
if ( customSiteName ) {
35-
await onboarding.siteNameInput.fill( customSiteName );
36-
}
37-
await expect( onboarding.siteNameInput ).toHaveValue( /\S+/, { timeout: 5000 } );
38-
const siteName = await onboarding.siteNameInput.inputValue();
39-
40-
if ( customFolderName ) {
41-
await onboarding.selectLocalPathForTesting( customFolderName );
42-
}
43-
const localPath = await onboarding.localPathInput.inputValue();
44-
45-
await expect( onboarding.heading ).toBeVisible();
46-
await onboarding.continueButton.click();
33+
const { siteName, localPath } = await onboarding.completeOnboarding( {
34+
customSiteName,
35+
customFolderName,
36+
} );
4737

4838
await closeWhatsNew();
4939

‎metrics/tests/site-editor.test.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ test.describe( 'Site Editor Load Metrics', () => {
3030
test( 'measure site editor load time', async () => {
3131
let wpAdminUrl = '';
3232
await session.launch();
33-
34-
// Setup WordPress site
33+
3534
const onboarding = new Onboarding( session.mainWindow );
36-
await expect( onboarding.heading ).toBeVisible();
35+
expect( onboarding.heading ).toBeVisible();
36+
3737
// Wait for store initialization to complete (provider constants loading)
3838
await new Promise( ( resolve ) => setTimeout( resolve, 500 ) );
39-
await onboarding.siteNameInput.fill( siteName );
40-
await onboarding.continueButton.click();
39+
await onboarding.completeOnboarding( { customSiteName: siteName } );
4140

4241
// Handle the What's New modal if it appears
4342
const whatsNewModal = new WhatsNewModal( session.mainWindow );

0 commit comments

Comments
 (0)