Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

WIP: Fix broken e2e tests #11043

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ test.describe( 'Shopper → Order Confirmation', () => {
} );
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await editorUtils.transformIntoBlocks();
} );

Expand Down
44 changes: 25 additions & 19 deletions tests/e2e/tests/templates/cart-template.block_theme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,46 @@ const templatePath = 'woocommerce/woocommerce//page-cart';
const templateType = 'wp_template';

test.describe( 'Test the cart template', async () => {
test( 'Template can be opened in the site editor', async ( {
test( 'Page can be accessed from the site editor', async ( {
admin,
editor,
page,
editorUtils,
} ) => {
await admin.visitAdminPage( 'site-editor.php' );
await editorUtils.waitForSiteEditorFinishLoading();
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Cart/i } ).click();
await editor.page.getByRole( 'button', { name: /Pages/i } ).click();
await editor.page.getByRole( 'button', { name: /Cart/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await expect(
page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h2:has-text("Cart")' )
.first()
editor.canvas.locator( 'h1:has-text("Cart block")' ).first()
).toBeVisible();
await editor.openDocumentSettingsSidebar();
await page.getByRole( 'button', { name: 'Edit template' } ).click();
await expect(
editor.canvas.locator( 'h1:has-text("Cart block")' ).first()
).toBeVisible();
} );

test( 'Template can be accessed from the page editor', async ( {
test( 'Template can be opened in the site editor', async ( {
admin,
editor,
page,
editorUtils,
} ) => {
await admin.visitAdminPage( 'site-editor.php' );
await editorUtils.waitForSiteEditorFinishLoading();
await editor.page.getByRole( 'button', { name: /Pages/i } ).click();
await editor.page.getByRole( 'button', { name: /Cart/i } ).click();
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Cart/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await expect(
editor.canvas.locator( 'h2:has-text("Cart")' ).first()
).toBeVisible();
await editor.openDocumentSettingsSidebar();
await page.getByRole( 'button', { name: 'Edit template' } ).click();
await expect(
editor.canvas.locator( 'h2:has-text("Cart")' ).first()
page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h1:has-text("Cart block")' )
.first()
).toBeVisible();
} );

Expand All @@ -53,7 +57,7 @@ test.describe( 'Test the cart template', async () => {
await expect(
admin.page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h2:has-text("Cart")' )
.locator( 'h1:has-text("Cart block")' )
.first()
).toBeVisible();
} );
Expand All @@ -74,8 +78,10 @@ test.describe( 'Test editing the cart template', async () => {
await admin.visitAdminPage( 'site-editor.php' );
await editorUtils.waitForSiteEditorFinishLoading();
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Checkout/i } ).click();
await page.getByRole( 'button', { name: /Page: Cart/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await editor.setContent(
'<!-- wp:woocommerce/classic-shortcode {"shortcode":"cart"} /-->'
);
Expand Down
42 changes: 24 additions & 18 deletions tests/e2e/tests/templates/checkout-template.block_theme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,46 @@ const templatePath = 'woocommerce/woocommerce//page-checkout';
const templateType = 'wp_template';

test.describe( 'Test the checkout template', async () => {
test( 'Template can be opened in the site editor', async ( {
test( 'Page can be accessed from the site editor', async ( {
admin,
editor,
page,
editorUtils,
} ) => {
await admin.visitAdminPage( 'site-editor.php' );
await editorUtils.waitForSiteEditorFinishLoading();
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Checkout/i } ).click();
await editor.page.getByRole( 'button', { name: /Pages/i } ).click();
await editor.page.getByRole( 'button', { name: /Checkout/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await expect(
page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h2:has-text("Checkout")' )
.first()
editor.canvas.locator( 'h1:has-text("Checkout block")' ).first()
).toBeVisible();
await editor.openDocumentSettingsSidebar();
await page.getByRole( 'button', { name: 'Edit template' } ).click();
await expect(
editor.canvas.locator( 'h1:has-text("Checkout block")' ).first()
).toBeVisible();
} );

test( 'Template can be accessed from the page editor', async ( {
test( 'Template can be opened in the site editor', async ( {
admin,
editor,
page,
editorUtils,
} ) => {
await admin.visitAdminPage( 'site-editor.php' );
await editorUtils.waitForSiteEditorFinishLoading();
await editor.page.getByRole( 'button', { name: /Pages/i } ).click();
await editor.page.getByRole( 'button', { name: /Checkout/i } ).click();
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Checkout/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await expect(
editor.canvas.locator( 'h2:has-text("Checkout")' ).first()
).toBeVisible();
await editor.openDocumentSettingsSidebar();
await page.getByRole( 'button', { name: 'Edit template' } ).click();
await expect(
editor.canvas.locator( 'h2:has-text("Checkout")' ).first()
page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h1:has-text("Checkout block")' )
.first()
).toBeVisible();
} );

Expand All @@ -53,7 +57,7 @@ test.describe( 'Test the checkout template', async () => {
await expect(
admin.page
.frameLocator( 'iframe[title="Editor canvas"i]' )
.locator( 'h2:has-text("Checkout")' )
.locator( 'h1:has-text("Checkout block")' )
.first()
).toBeVisible();
} );
Expand All @@ -76,6 +80,8 @@ test.describe( 'Test editing the checkout template', async () => {
await page.getByRole( 'button', { name: /Templates/i } ).click();
await page.getByRole( 'button', { name: /Page: Checkout/i } ).click();
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await editor.setContent(
'<!-- wp:woocommerce/classic-shortcode {"shortcode":"checkout"} /-->'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ test.describe( 'Test the order confirmation template', async () => {
} );
await editorUtils.enterEditMode();
await editorUtils.closeWelcomeGuideModal();
await editorUtils.closePageEditingModal();
await editorUtils.transformIntoBlocks();
await editorUtils.waitForSiteEditorFinishLoading();
await expect(
Expand Down
19 changes: 17 additions & 2 deletions tests/e2e/utils/editor/editor-utils.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ export class EditorUtils {
.getByRole( 'dialog', { name: 'Welcome to the site editor' } )
.locator( 'div' )
.filter( {
hasText:
'Edit your siteDesign everything on your site — from the header right down to the',
hasText: 'Edit your site',
} )
.nth( 2 )
.isVisible();
Expand All @@ -280,6 +279,22 @@ export class EditorUtils {
}
}

async closePageEditingModal() {
const isModalOpen = await this.page
.getByRole( 'dialog', { name: 'Editing a page' } )
.locator( 'div' )
.filter( {
hasText: 'Editing a page',
} )
.nth( 2 )
.isVisible();

// eslint-disable-next-line playwright/no-conditional-in-test
if ( isModalOpen ) {
await this.page.getByRole( 'button', { name: 'Continue' } ).click();
}
}

async transformIntoBlocks() {
const isNotTransformedIntoBlocks = await this.page
.frameLocator( 'iframe[name="editor-canvas"]' )
Expand Down