Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns: add a new spec for for adding an unsynced pattern #54892

Merged
merged 10 commits into from
Sep 28, 2023
22 changes: 14 additions & 8 deletions test/e2e/specs/editor/various/patterns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Unsynced pattern', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.deleteAllBlocks();
} );

test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllBlocks();
} );

test( 'create a new unsynced pattern via the block options menu', async ( {
editor,
page,
Expand Down Expand Up @@ -58,13 +66,11 @@ test.describe( 'Unsynced pattern', () => {
await page.getByLabel( 'My unsynced pattern' ).click();

// Just compare the block name and content as the clientIDs will be different.
const existingBlock = before[ 0 ];
const newBlocks = await editor.getBlocks();
newBlocks.forEach( ( block ) =>
expect( block ).toMatchObject( {
name: existingBlock.name,
attributes: { content: existingBlock.attributes.content },
} )
);
before.forEach( ( block ) => {
delete block.clientId;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that is much simpler 🤦

} );
await expect
.poll( editor.getBlocks )
.toMatchObject( [ ...before, ...before ] );
} );
} );
Loading