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 patterns' e2e tests to Playwright #57399

Merged
merged 3 commits into from
Dec 29, 2023
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.

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

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

test.afterAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deactivatePlugin( 'gutenberg-test-allowed-patterns' ),
requestUtils.deactivatePlugin(
'gutenberg-test-allowed-patterns-disable-blocks'
),
] );
} );

test( 'should show all patterns when blocks are not disabled', async ( {
admin,
page,
} ) => {
await admin.createNewPost();
await page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Toggle block inserter' } )
.click();

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

await expect(
page
.getByRole( 'listbox', { name: 'Block patterns' } )
.getByRole( 'option' )
).toHaveText( [
'Test: Single heading',
'Test: Single paragraph',
'Test: Paragraph inside group',
] );
} );

test( 'should show only allowed patterns when blocks are disabled', async ( {
admin,
page,
requestUtils,
} ) => {
await requestUtils.activatePlugin(
'gutenberg-test-allowed-patterns-disable-blocks'
);
await admin.createNewPost();
await page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Toggle block inserter' } )
.click();

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

await expect(
page
.getByRole( 'listbox', { name: 'Block patterns' } )
.getByRole( 'option' )
).toHaveText( [ 'Test: Single heading' ] );
} );
} );
Loading