-
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 'block-locking' to Playwright (#41050)
* Migrate 'block-locking' to Playwright * Use correct utility method
- Loading branch information
Showing
2 changed files
with
86 additions
and
120 deletions.
There are no files selected for viewing
120 changes: 0 additions & 120 deletions
120
packages/e2e-tests/specs/editor/various/block-locking.test.js
This file was deleted.
Oops, something went wrong.
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,86 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Block Locking', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test.describe( 'General', () => { | ||
test( 'can prevent removal', async ( { editor, page } ) => { | ||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
await page.keyboard.type( 'Some paragraph' ); | ||
|
||
await editor.clickBlockOptionsMenuItem( 'Lock' ); | ||
|
||
await page.click( 'role=checkbox[name="Prevent removal"]' ); | ||
await page.click( 'role=button[name="Apply"]' ); | ||
|
||
await expect( | ||
page.locator( 'role=menuitem[name="Remove Paragraph"]' ) | ||
).not.toBeVisible(); | ||
} ); | ||
|
||
test( 'can disable movement', async ( { editor, page } ) => { | ||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
await page.keyboard.type( 'First paragraph' ); | ||
|
||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
await page.keyboard.type( 'Second paragraph' ); | ||
|
||
await editor.clickBlockOptionsMenuItem( 'Lock' ); | ||
|
||
await page.click( 'role=checkbox[name="Disable movement"]' ); | ||
await page.click( 'role=button[name="Apply"]' ); | ||
|
||
// Hide options. | ||
await editor.clickBlockToolbarButton( 'Options' ); | ||
|
||
// Drag handle is hidden. | ||
await expect( | ||
page.locator( 'role=button[name="Drag"]' ) | ||
).not.toBeVisible(); | ||
|
||
// Movers are hidden. No need to check for both. | ||
await expect( | ||
page.locator( 'role=button[name="Move up"]' ) | ||
).not.toBeVisible(); | ||
} ); | ||
|
||
test( 'can lock everything', async ( { editor, page } ) => { | ||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
await page.keyboard.type( 'Some paragraph' ); | ||
|
||
await editor.clickBlockOptionsMenuItem( 'Lock' ); | ||
|
||
await page.click( 'role=checkbox[name="Lock all"]' ); | ||
await page.click( 'role=button[name="Apply"]' ); | ||
|
||
expect( await editor.getEditedPostContent() ) | ||
.toBe( `<!-- wp:paragraph {"lock":{"move":true,"remove":true}} --> | ||
<p>Some paragraph</p> | ||
<!-- /wp:paragraph -->` ); | ||
} ); | ||
|
||
test( 'can unlock from toolbar', async ( { editor, page } ) => { | ||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
await page.keyboard.type( 'Some paragraph' ); | ||
|
||
await editor.clickBlockOptionsMenuItem( 'Lock' ); | ||
|
||
await page.click( 'role=checkbox[name="Lock all"]' ); | ||
await page.click( 'role=button[name="Apply"]' ); | ||
|
||
await editor.clickBlockToolbarButton( 'Unlock Paragraph' ); | ||
await page.click( 'role=checkbox[name="Lock all"]' ); | ||
await page.click( 'role=button[name="Apply"]' ); | ||
|
||
expect( await editor.getEditedPostContent() ) | ||
.toBe( `<!-- wp:paragraph {"lock":{"move":false,"remove":false}} --> | ||
<p>Some paragraph</p> | ||
<!-- /wp:paragraph -->` ); | ||
} ); | ||
} ); | ||
} ); |