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

Migrate group block tests to Playwright #42801

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

78 changes: 0 additions & 78 deletions packages/e2e-tests/specs/editor/blocks/group.test.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:group -->
<div class="wp-block-group"></div>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:group -->
<div class="wp-block-group"></div>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:group -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Group Block with a Paragraph</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
61 changes: 61 additions & 0 deletions test/e2e/specs/editor/blocks/group.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Group', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test( 'can be created using the block inserter', async ( {
editor,
page,
} ) => {
// Search for the group block and insert it.
const inserterButton = page.locator(
'role=button[name="Toggle block inserter"i]'
);

await inserterButton.click();

await page.type(
'role=searchbox[name="Search for blocks and patterns"i]',
'Group'
);

await page.click(
'role=listbox[name="Blocks"i] >> role=option[name="Group"i]'
);

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );

test( 'can be created using the slash inserter', async ( {
editor,
page,
} ) => {
await page.click( 'role=button[name="Add default block"i]' );
await page.keyboard.type( '/group' );
await expect(
page.locator( 'role=option[name="Group"i][selected]' )
).toBeVisible();
await page.keyboard.press( 'Enter' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );

test( 'can have other blocks appended to it using the button appender', async ( {
editor,
page,
} ) => {
await editor.insertBlock( { name: 'core/group' } );
await page.click( 'role=button[name="Add block"i]' );
await page.click(
'role=listbox[name="Blocks"i] >> role=option[name="Paragraph"i]'
);
await page.keyboard.type( 'Group Block with a Paragraph' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );
} );