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 Allowed Block Test to Playwright #53171

Merged
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
59 changes: 0 additions & 59 deletions packages/e2e-tests/specs/editor/plugins/allowed-blocks.test.js

This file was deleted.

70 changes: 70 additions & 0 deletions test/e2e/specs/editor/plugins/allowed-blocks.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

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

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

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

test( 'should restrict the allowed blocks in the inserter', async ( {
page,
} ) => {
// The paragraph block is available.
await page
.getByRole( 'button', { name: 'Toggle block inserter' } )
.click();

const searchbox = page
.getByRole( 'region', { name: 'Block Library' } )
.getByRole( 'searchbox', {
name: 'Search for blocks and patterns',
} );

await searchbox.fill( 'Paragraph' );

await expect(
page.getByRole( 'option', { name: 'Paragraph' } )
).toBeVisible();

// The gallery block is not available.
await searchbox.click( {
clickCount: 3,
} );
await page.keyboard.press( 'Backspace' );

await searchbox.fill( 'Gallery' );

await expect(
page.getByRole( 'option', { name: 'Gallery' } )
).toBeHidden();
} );

test( 'should remove not allowed blocks from the block manager', async ( {
page,
} ) => {
await page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Options' } )
.click();

await page.getByRole( 'menuitem', { name: 'Preferences' } ).click();

await page.getByRole( 'tab', { name: 'Blocks' } ).click();

await expect(
page
.getByRole( 'region', { name: 'Available block types' } )
.getByRole( 'listitem' )
).toHaveText( [ 'Paragraph', 'Image' ] );
} );
} );