Skip to content

Commit

Permalink
Migrate html block test case to Playwright (#41231)
Browse files Browse the repository at this point in the history
* Migrate html spec test case

* Address Review Feedbacks

* Apply suggestions from code review

Co-authored-by: Pooja Killekar <poojakillekar@Poojas-MacBook-Air.local>
Co-authored-by: Kai Hao <kevin830726@gmail.com>
  • Loading branch information
3 people authored May 24, 2022
1 parent 161e5e4 commit 9f1ca90
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.

This file was deleted.

31 changes: 0 additions & 31 deletions packages/e2e-tests/specs/editor/blocks/html.test.js

This file was deleted.

33 changes: 33 additions & 0 deletions test/e2e/specs/editor/blocks/html.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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 expect(
page.locator( 'role=option[name="Custom HTML"i][selected]' )
).toBeVisible();
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '<p>Pythagorean theorem: ' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type(
'<var>a</var><sup>2</sup> + <var>b</var><sup>2</sup> = <var>c</var><sup>2</sup> </p>'
);
// Check the content.
const content = await editor.getEditedPostContent();
expect( content ).toBe(
`<!-- wp:html -->
<p>Pythagorean theorem:
<var>a</var><sup>2</sup> + <var>b</var><sup>2</sup> = <var>c</var><sup>2</sup> </p>
<!-- /wp:html -->`
);
} );
} );

0 comments on commit 9f1ca90

Please sign in to comment.