Skip to content

Commit

Permalink
Test protected fields are not editable
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 30, 2024
1 parent 361273a commit 892f501
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/e2e/specs/editor/various/block-bindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,64 @@ test.describe( 'Block bindings', () => {
previewPage.locator( '#paragraph-binding' )
).toHaveText( 'new value' );
} );

test( 'should NOT be possible to edit the value of the custom field when it is protected', async ( {
editor,
} ) => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: {
anchor: 'protected-field-binding',
content: 'fallback value',
metadata: {
bindings: {
content: {
source: 'core/post-meta',
args: { key: '_protected_field' },
},
},
},
},
} );

const protectedFieldBlock = editor.canvas.getByRole(
'document',
{
name: 'Block: Paragraph',
}
);

await expect( protectedFieldBlock ).not.toBeEditable();
} );

test( 'should NOT be possible to edit the value of the custom field when it is not shown in the REST API', async ( {
editor,
} ) => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: {
anchor: 'show-in-rest-false-binding',
content: 'fallback value',
metadata: {
bindings: {
content: {
source: 'core/post-meta',
args: { key: 'show_in_rest_false_field' },
},
},
},
},
} );

const showInRestFalseBlock = editor.canvas.getByRole(
'document',
{
name: 'Block: Paragraph',
}
);

await expect( showInRestFalseBlock ).not.toBeEditable();
} );
} );

test.describe( 'Heading', () => {
Expand Down

0 comments on commit 892f501

Please sign in to comment.