Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot authored and cbravobernal committed Sep 25, 2024
1 parent ef88c3f commit 47f8040
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/e2e-tests/plugins/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ function gutenberg_test_block_bindings_registration() {
'post',
'_protected_field',
array(
'type' => 'string',
'single' => true,
'default' => 'protected field value',
'type' => 'string',
'show_in_rest' => true,
'single' => true,
'default' => 'protected field value',
)
);
register_meta(
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/specs/editor/various/block-bindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,33 @@ test.describe( 'Block bindings', () => {
previewPage.locator( '#image-alt-binding img' )
).toHaveAttribute( 'alt', 'new value' );
} );

test( 'should not be possible to edit the value of the protected custom fields', async ( {
editor,
} ) => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: {
content: 'paragraph default content',
metadata: {
bindings: {
content: {
source: 'core/post-meta',
args: { key: '_protected_field' },
},
},
},
},
} );
const paragraphBlock = editor.canvas.getByRole( 'document', {
name: 'Block: Paragraph',
} );

await expect( paragraphBlock ).toHaveAttribute(
'contenteditable',
'false'
);
} );
} );
} );

Expand Down

0 comments on commit 47f8040

Please sign in to comment.