From 4a6190ba6a972129c728867df63b29981d8ce1ed Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 22 May 2023 10:33:49 +0100 Subject: [PATCH 1/3] Command center: Enable e2e tests --- .../specs/site-editor/command-center.spec.js | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/test/e2e/specs/site-editor/command-center.spec.js b/test/e2e/specs/site-editor/command-center.spec.js index 936c8838db426e..117a247de02ba6 100644 --- a/test/e2e/specs/site-editor/command-center.spec.js +++ b/test/e2e/specs/site-editor/command-center.spec.js @@ -17,34 +17,29 @@ test.describe( 'Site editor command center', () => { await admin.visitSiteEditor(); } ); - test.skip( 'Open the command center and navigate to the page create page', async ( { + test( 'Open the command center and navigate to the page create page', async ( { page, } ) => { + await page.focus( 'role=button[name="Open command center"i]' ); await page.keyboard.press( 'Meta+k' ); + await page.keyboard.type( 'new page' ); const newPageButton = page.locator( - 'role=option[name="Create a new page"i]' + 'role=option[name="Add new page"i]' ); await expect( newPageButton ).toBeVisible(); - - // Type a random post title - await page.keyboard.type( 'E2E Test Post' ); - await page.click( - 'role=option[name="Create a new post \\"E2E Test Post\\""i]' - ); + await newPageButton.click(); await page.waitForSelector( 'iframe[name="editor-canvas"]' ); const frame = page.frame( 'editor-canvas' ); - const postTitleInput = frame.locator( - 'role=textbox[name=/Add title/i]' - ); - await expect( postTitleInput ).toHaveText( 'E2E Test Post' ); + await expect( + frame.locator( 'role=textbox[name=/Add title/i]' ) + ).toBeVisible(); } ); - test.skip( 'Open the command center and navigate to a template', async ( { + test( 'Open the command center and navigate to a template', async ( { page, } ) => { - await page.keyboard.press( 'Meta+k' ); - + await page.click( 'role=button[name="Open command center"i]' ); await page.keyboard.type( 'index' ); await page.click( 'role=option[name="index"i]' ); await expect( page.locator( 'h2' ) ).toHaveText( 'Index' ); From 4f2c6fda99fa2f71f433da0344046fa7ab47861d Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 22 May 2023 10:49:33 +0100 Subject: [PATCH 2/3] Changes per review --- .../specs/site-editor/command-center.spec.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/e2e/specs/site-editor/command-center.spec.js b/test/e2e/specs/site-editor/command-center.spec.js index 117a247de02ba6..a259aa60a6ab58 100644 --- a/test/e2e/specs/site-editor/command-center.spec.js +++ b/test/e2e/specs/site-editor/command-center.spec.js @@ -20,28 +20,27 @@ test.describe( 'Site editor command center', () => { test( 'Open the command center and navigate to the page create page', async ( { page, } ) => { - await page.focus( 'role=button[name="Open command center"i]' ); + await page + .getByRole( 'button', { name: 'Open command center' } ) + .focus(); await page.keyboard.press( 'Meta+k' ); await page.keyboard.type( 'new page' ); - const newPageButton = page.locator( - 'role=option[name="Add new page"i]' - ); - await expect( newPageButton ).toBeVisible(); - await newPageButton.click(); - + await page.getByRole( 'option', { name: 'Add new page' } ).click(); await page.waitForSelector( 'iframe[name="editor-canvas"]' ); const frame = page.frame( 'editor-canvas' ); await expect( - frame.locator( 'role=textbox[name=/Add title/i]' ) + frame.getByRole( 'textbox', { name: 'Add title' } ) ).toBeVisible(); } ); test( 'Open the command center and navigate to a template', async ( { page, } ) => { - await page.click( 'role=button[name="Open command center"i]' ); + await page + .getByRole( 'button', { name: 'Open command center' } ) + .click(); await page.keyboard.type( 'index' ); - await page.click( 'role=option[name="index"i]' ); + await page.getByRole( 'option', { name: 'index' } ).click(); await expect( page.locator( 'h2' ) ).toHaveText( 'Index' ); } ); } ); From 950091885c2968ff9c5c5b81d97573ae65d2dfe2 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 22 May 2023 11:00:11 +0100 Subject: [PATCH 3/3] Tweaks --- test/e2e/specs/site-editor/command-center.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/site-editor/command-center.spec.js b/test/e2e/specs/site-editor/command-center.spec.js index a259aa60a6ab58..9661a91a6abc78 100644 --- a/test/e2e/specs/site-editor/command-center.spec.js +++ b/test/e2e/specs/site-editor/command-center.spec.js @@ -41,6 +41,8 @@ test.describe( 'Site editor command center', () => { .click(); await page.keyboard.type( 'index' ); await page.getByRole( 'option', { name: 'index' } ).click(); - await expect( page.locator( 'h2' ) ).toHaveText( 'Index' ); + await expect( page.getByRole( 'heading', { level: 2 } ) ).toHaveText( + 'Index' + ); } ); } );