Skip to content

Commit

Permalink
Add assertions about element order
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 12, 2025
1 parent c095f14 commit a38665b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/e2e/specs/editor/plugins/block-hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Block Hooks API', () => {
const anchorBlockMarkup = `<!-- wp:paragraph -->
<p>This is a test paragraph.</p>
const anchorBlockMarkup = `<!-- wp:paragraph {"className":"test-paragraph"} -->
<p class="test-paragraph">This is a test paragraph.</p>
<!-- /wp:paragraph -->`;

const getHookedBlockClassName = ( relativePosition, anchorBlock ) =>
Expand Down Expand Up @@ -47,7 +47,11 @@ test.describe( 'Block Hooks API', () => {
getHookedBlockSelector( 'last_child', 'core/post-content' )
)
).toHaveCount( 1 );
// TODO: Verify that it's after the test paragraph.
// Verify that the hook block is inserted after the test paragraph.
await expect( page.locator( '.entry-content p' ) ).toHaveClass( [
'test-paragraph',
getHookedBlockClassName( 'last_child', 'core/post-content' ),
] );
} );

test( 'should insert hooked block as last child of Post Content block in editor', async ( {
Expand Down Expand Up @@ -105,6 +109,10 @@ test.describe( 'Block Hooks API', () => {
getHookedBlockSelector( 'last_child', 'core/post-content' )
)
).toHaveCount( 1 );
// TODO: Verify that it's before the test paragraph.
// Verify that the hooked block is now before the test paragraph.
await expect( page.locator( '.entry-content p' ) ).toHaveClass( [
getHookedBlockClassName( 'last_child', 'core/post-content' ),
'test-paragraph',
] );
} );
} );

0 comments on commit a38665b

Please sign in to comment.