-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate spacer test to playwright (#41590)
* WIP * migrate / spacer test to playwright * env / reset to the original value * remove puppeter files * Remove unneeded comments * Update spacer.spec.js * feature / Update spacer test * docs / Add comment for spacer e2e test * docs / Update comment for spacer e2e test * Update test/e2e/specs/editor/blocks/spacer.spec.js Co-authored-by: Kai Hao <[email protected]> Co-authored-by: Kai Hao <[email protected]>
- Loading branch information
1 parent
7f07d8b
commit aadaab5
Showing
5 changed files
with
51 additions
and
61 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
packages/e2e-tests/specs/editor/blocks/__snapshots__/spacer.test.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...e/specs/editor/blocks/__snapshots__/Spacer-can-be-created-by-typing-spacer-1-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- wp:spacer --> | ||
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div> | ||
<!-- /wp:spacer --> |
3 changes: 3 additions & 0 deletions
3
...-be-resized-using-the-drag-handle-and-remains-selected-after-being-dragged-1-chromium.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- wp:spacer {"height":"150px"} --> | ||
<div style="height:150px" aria-hidden="true" class="wp-block-spacer"></div> | ||
<!-- /wp:spacer --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Spacer', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test( 'can be created by typing "/spacer"', async ( { editor, page } ) => { | ||
// Create a spacer with the slash block shortcut. | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( '/spacer' ); | ||
await page.keyboard.press( 'Enter' ); | ||
|
||
expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
|
||
test( 'can be resized using the drag handle and remains selected after being dragged', async ( { | ||
page, | ||
editor, | ||
} ) => { | ||
// Create a spacer with the slash block shortcut. | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( '/spacer' ); | ||
await page.keyboard.press( 'Enter' ); | ||
|
||
const resizableHandle = page.locator( | ||
// Use class name selector until we have `data-testid` for the resize handles. | ||
'role=document[name="Block: Spacer"i] >> css=.components-resizable-box__handle' | ||
); | ||
const elementPoint = await resizableHandle.boundingBox(); | ||
await page.mouse.move( elementPoint.x, elementPoint.y ); | ||
await page.mouse.down(); | ||
await page.mouse.move( elementPoint.x + 0, elementPoint.y + 50 ); | ||
await page.mouse.up(); | ||
|
||
expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await expect( | ||
page.locator( 'role=document[name="Block: Spacer"i]' ) | ||
).toBeFocused(); | ||
} ); | ||
} ); |