Skip to content

Commit

Permalink
Rewrite editor test
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 11, 2025
1 parent 6c13f5b commit 59b8daf
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions test/e2e/specs/editor/plugins/block-hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ test.describe( 'Block Hooks API', () => {
const getHookedBlockSelector = ( relativePosition, anchorBlock ) =>
'.' + getHookedBlockClassName( relativePosition, anchorBlock );

const getHookedBlockMarkup = ( relativePosition, anchorBlock ) => {
const className = getHookedBlockClassName(
relativePosition,
anchorBlock
);
return `<!-- wp:paragraph {"className":"${ className }"} -->
<p class="${ className }">
This block was inserted by the Block Hooks API in the <code>${ relativePosition }</code> position next to the <code>${ anchorBlock }</code> anchor block.
</p><!-- /wp:paragraph -->`;
};

let post;

test.beforeAll( async ( { requestUtils } ) => {
Expand Down Expand Up @@ -62,11 +51,17 @@ This block was inserted by the Block Hooks API in the <code>${ relativePosition
editor,
} ) => {
await admin.editPost( post.id );
await expect
.poll( editor.getEditedPostContent )
.toBe(
anchorBlockMarkup +
getHookedBlockMarkup( 'last_child', 'core/post-content' )
);
await expect.poll( editor.getBlocks ).toMatchObject( [
{ name: 'core/paragraph' },
{
name: 'core/paragraph',
attributes: {
className: getHookedBlockClassName(
'last_child',
'core/post-content'
),
},
},
] );
} );
} );

0 comments on commit 59b8daf

Please sign in to comment.