Skip to content

Commit

Permalink
Test editing is allowed in paragraph block
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 30, 2024
1 parent 5ac4874 commit 361273a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/e2e/specs/editor/various/block-bindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,45 @@ test.describe( 'Block bindings', () => {
await expect( newEmptyParagraph ).toHaveText( '' );
await expect( newEmptyParagraph ).toBeEditable();
} );

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

await expect( paragraphBlock ).toHaveText(
'Value of the text_custom_field'
);
await expect( paragraphBlock ).toBeEditable();
await paragraphBlock.fill( 'new value' );
// Check that the paragraph content attribute didn't change.
const [ paragraphBlockObject ] = await editor.getBlocks();
expect( paragraphBlockObject.attributes.content ).toBe(
'paragraph default content'
);
// Check the value of the custom field is being updated by visiting the frontend.
const previewPage = await editor.openPreviewPage();
await expect(
previewPage.locator( '#paragraph-binding' )
).toHaveText( 'new value' );
} );
} );

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

0 comments on commit 361273a

Please sign in to comment.