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 c2ef4c0 commit 98fe801
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( [

Check failure on line 54 in test/e2e/specs/editor/plugins/block-hooks.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 2

[chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor

1) [chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 17 Array [ Object { + "attributes": Object { + "content": "This is a test paragraph.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, Object { "attributes": Object { "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, }, + "innerBlocks": Array [], + "name": "core/paragraph", + }, + Object { + "attributes": Object { + "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 52 | } ) => { 53 | await admin.editPost( post.id ); > 54 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 55 | { name: 'core/paragraph' }, 56 | { 57 | name: 'core/paragraph', at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/block-hooks.spec.js:54:3

Check failure on line 54 in test/e2e/specs/editor/plugins/block-hooks.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 2

[chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor

1) [chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 17 Array [ Object { + "attributes": Object { + "content": "This is a test paragraph.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, Object { "attributes": Object { "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, }, + "innerBlocks": Array [], + "name": "core/paragraph", + }, + Object { + "attributes": Object { + "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 52 | } ) => { 53 | await admin.editPost( post.id ); > 54 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 55 | { name: 'core/paragraph' }, 56 | { 57 | name: 'core/paragraph', at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/block-hooks.spec.js:54:3

Check failure on line 54 in test/e2e/specs/editor/plugins/block-hooks.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 2

[chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor

1) [chromium] › editor/plugins/block-hooks.spec.js:49:2 › Block Hooks API › should insert hooked block as last child of Post Content block in editor Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toMatchObject(expected) - Expected - 0 + Received + 17 Array [ Object { + "attributes": Object { + "content": "This is a test paragraph.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, Object { "attributes": Object { "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, }, + "innerBlocks": Array [], + "name": "core/paragraph", + }, + Object { + "attributes": Object { + "className": "hooked-block-last_child-post-content", + "content": "This block was inserted by the Block Hooks API in the <code>last_child</code> position next to the <code>core/post-content</code> anchor block.", + "dropCap": false, + }, + "innerBlocks": Array [], "name": "core/paragraph", }, ] Call Log: - Timeout 5000ms exceeded while waiting on the predicate 52 | } ) => { 53 | await admin.editPost( post.id ); > 54 | await expect.poll( editor.getBlocks ).toMatchObject( [ | ^ 55 | { name: 'core/paragraph' }, 56 | { 57 | name: 'core/paragraph', at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/block-hooks.spec.js:54:3
{ name: 'core/paragraph' },
{
name: 'core/paragraph',
attributes: {
className: getHookedBlockClassName(
'last_child',
'core/post-content'
),
},
},
] );
} );
} );

0 comments on commit 98fe801

Please sign in to comment.