Skip to content

Commit

Permalink
Add e2e tests for block locking and template lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jun 15, 2023
1 parent 6ce4fe8 commit 8bad90c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/e2e/specs/editor/various/block-locking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,62 @@ test.describe( 'Block Locking', () => {
<p>Some paragraph</p>
<!-- /wp:paragraph -->` );
} );

test( 'block locking supersedes template locking', async ( {
editor,
page,
pageUtils,
} ) => {
await editor.insertBlock( {
name: 'core/group',
attributes: {
layout: { type: 'constrained' },
templateLock: 'all',
},
innerBlocks: [
{
name: 'core/heading',
attributes: { content: 'Hello, hello' },
},
{
name: 'core/paragraph',
attributes: { content: 'WordPress' },
},
],
} );

const paragraph = editor.canvas.getByRole( 'document', {
name: 'Paragraph block',
} );
await paragraph.click();

await editor.clickBlockToolbarButton( 'Unlock' );
await page.click( 'role=checkbox[name="Lock all"]' );
await page.click( 'role=button[name="Apply"]' );

await expect(
page
.getByRole( 'toolbar', { name: 'Block tools' } )
.getByRole( 'button', { name: 'Move up' } )
).toBeVisible();

await paragraph.click();
await pageUtils.pressKeys( 'access+z' );

await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/group',
attributes: {
layout: { type: 'constrained' },
templateLock: 'all',
},
innerBlocks: [
{
name: 'core/heading',
attributes: { content: 'Hello, hello' },
},
],
},
] );
} );
} );

0 comments on commit 8bad90c

Please sign in to comment.