From 6cf3a0aea4b7f9c19b417e67687f523bdb1d91be Mon Sep 17 00:00:00 2001 From: Pooja Killekar Date: Mon, 23 May 2022 15:54:14 +0530 Subject: [PATCH 1/3] Migrate html spec test case --- .../blocks/__snapshots__/html.test.js.snap | 8 ----- .../specs/editor/blocks/html.test.js | 31 ------------------- test/e2e/specs/editor/blocks/html.spec.js | 31 +++++++++++++++++++ 3 files changed, 31 insertions(+), 39 deletions(-) delete mode 100644 packages/e2e-tests/specs/editor/blocks/__snapshots__/html.test.js.snap delete mode 100644 packages/e2e-tests/specs/editor/blocks/html.test.js create mode 100644 test/e2e/specs/editor/blocks/html.spec.js diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/html.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/html.test.js.snap deleted file mode 100644 index b72664d0212768..00000000000000 --- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/html.test.js.snap +++ /dev/null @@ -1,8 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`HTML block can be created by typing "/html" 1`] = ` -" -

Pythagorean theorem: -a2 + b2 = c2

-" -`; diff --git a/packages/e2e-tests/specs/editor/blocks/html.test.js b/packages/e2e-tests/specs/editor/blocks/html.test.js deleted file mode 100644 index df2492aaa51bb0..00000000000000 --- a/packages/e2e-tests/specs/editor/blocks/html.test.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * WordPress dependencies - */ -import { - clickBlockAppender, - getEditedPostContent, - createNewPost, -} from '@wordpress/e2e-test-utils'; - -describe( 'HTML block', () => { - beforeEach( async () => { - await createNewPost(); - } ); - - it( 'can be created by typing "/html"', async () => { - // Create a Custom HTML block with the slash shortcut. - await clickBlockAppender(); - await page.keyboard.type( '/html' ); - await page.waitForXPath( - `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Custom HTML')]` - ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( '

Pythagorean theorem: ' ); - await page.keyboard.press( 'Enter' ); - await page.keyboard.type( - 'a2 + b2 = c2

' - ); - - expect( await getEditedPostContent() ).toMatchSnapshot(); - } ); -} ); diff --git a/test/e2e/specs/editor/blocks/html.spec.js b/test/e2e/specs/editor/blocks/html.spec.js new file mode 100644 index 00000000000000..6c1e62ab71cc15 --- /dev/null +++ b/test/e2e/specs/editor/blocks/html.spec.js @@ -0,0 +1,31 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); +test.describe( 'HTML block', () => { + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + test( 'can be created by typing "/html"', async ( { editor, page } ) => { + // Create a Custom HTML block with the slash shortcut. + await page.click( 'role=button[name="Add default block"i]' ); + await page.keyboard.type( '/html' ); + await page.locator( + `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Custom HTML')]` + ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '

Pythagorean theorem: ' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( + 'a2 + b2 = c2

' + ); + // Check the content + const content = await editor.getEditedPostContent(); + expect( content ).toBe( + ` +

Pythagorean theorem: +a2 + b2 = c2

+` + ); + } ); +} ); From 704e46861582ff441cbb4c67344105622876f240 Mon Sep 17 00:00:00 2001 From: Pooja Killekar Date: Tue, 24 May 2022 10:32:53 +0530 Subject: [PATCH 2/3] Address Review Feedbacks --- test/e2e/specs/editor/blocks/html.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/editor/blocks/html.spec.js b/test/e2e/specs/editor/blocks/html.spec.js index 6c1e62ab71cc15..67f6be4701656b 100644 --- a/test/e2e/specs/editor/blocks/html.spec.js +++ b/test/e2e/specs/editor/blocks/html.spec.js @@ -10,9 +10,9 @@ test.describe( 'HTML block', () => { // Create a Custom HTML block with the slash shortcut. await page.click( 'role=button[name="Add default block"i]' ); await page.keyboard.type( '/html' ); - await page.locator( - `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Custom HTML')]` - ); + await expect( + page.locator( 'role=option[name="Custom HTML"i][selected]' ) + ).toBeVisible(); await page.keyboard.press( 'Enter' ); await page.keyboard.type( '

Pythagorean theorem: ' ); await page.keyboard.press( 'Enter' ); From 8b15bf4d774ad76be17c280873607580714619b4 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Tue, 24 May 2022 16:40:14 +0800 Subject: [PATCH 3/3] Apply suggestions from code review --- test/e2e/specs/editor/blocks/html.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/specs/editor/blocks/html.spec.js b/test/e2e/specs/editor/blocks/html.spec.js index 67f6be4701656b..dedb9197984fc5 100644 --- a/test/e2e/specs/editor/blocks/html.spec.js +++ b/test/e2e/specs/editor/blocks/html.spec.js @@ -2,10 +2,12 @@ * WordPress dependencies */ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + test.describe( 'HTML block', () => { test.beforeEach( async ( { admin } ) => { await admin.createNewPost(); } ); + test( 'can be created by typing "/html"', async ( { editor, page } ) => { // Create a Custom HTML block with the slash shortcut. await page.click( 'role=button[name="Add default block"i]' ); @@ -19,7 +21,7 @@ test.describe( 'HTML block', () => { await page.keyboard.type( 'a2 + b2 = c2

' ); - // Check the content + // Check the content. const content = await editor.getEditedPostContent(); expect( content ).toBe( `