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 Child Block Test to Playwright #55199

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 0 additions & 66 deletions packages/e2e-tests/specs/editor/plugins/child-blocks.test.js

This file was deleted.

100 changes: 100 additions & 0 deletions test/e2e/specs/editor/plugins/child-blocks.spec.js
@@ -0,0 +1,100 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Child Blocks', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin( 'gutenberg-test-child-blocks' );
} );

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

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin( 'gutenberg-test-child-blocks' );
} );

test( 'are hidden from the global block inserter', async ( { page } ) => {
const blockInserter = page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Toggle block inserter' } );
const blockLibrary = page.getByRole( 'region', {
name: 'Block Library',
} );

await blockInserter.click();
await expect( blockLibrary ).toBeVisible();
expect( blockLibrary.getByRole( 'option' ) ).not.toContain( [
'Child Blocks Child',
] );
expect(
await blockLibrary.getByRole( 'option' ).count()
).toBeGreaterThan( 10 );
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
} );

test( 'shows up in a parent block', async ( { page, editor } ) => {
await editor.insertBlock( {
name: 'test/child-blocks-unrestricted-parent',
} );

await page
.getByRole( 'document', {
name: 'Block: Child Blocks Unrestricted Parent',
} )
.getByRole( 'button', {
name: 'Add default block',
} )
.click();

const blockInserter = page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Toggle block inserter' } );
const blockLibrary = page.getByRole( 'region', {
name: 'Block Library',
} );

await blockInserter.click();
await expect( blockLibrary ).toBeVisible();
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
await expect( blockLibrary.getByRole( 'option' ) ).toContainText( [
'Child Blocks Child',
] );
expect(
await blockLibrary.getByRole( 'option' ).count()
).toBeGreaterThan( 10 );
} );

test( 'display in a parent block with allowedItems', async ( {
page,
editor,
} ) => {
await editor.insertBlock( {
name: 'test/child-blocks-restricted-parent',
} );

await page
.getByRole( 'document', {
name: 'Block: Child Blocks Restricted Parent',
} )
.getByRole( 'button', {
name: 'Add default block',
} )
.click();

const blockInserter = page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Toggle block inserter' } );
const blockLibrary = page.getByRole( 'region', {
name: 'Block Library',
} );

await blockInserter.click();
await expect( blockLibrary ).toBeVisible();
await expect( blockLibrary.getByRole( 'option' ) ).toHaveText( [
'Paragraph',
'Child Blocks Child',
'Image',
] );
} );
} );