-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate 'inner-blocks-prioritized-inserter-blocks' e2e tests to Playw…
…right (#55828) * Migrate 'inner-blocks-prioritized-inserter-blocks' e2e tests to Playwright * Remove old test file * Feedback
- Loading branch information
Showing
2 changed files
with
146 additions
and
132 deletions.
There are no files selected for viewing
132 changes: 0 additions & 132 deletions
132
packages/e2e-tests/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js
This file was deleted.
Oops, something went wrong.
146 changes: 146 additions & 0 deletions
146
test/e2e/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Prioritized Inserter Blocks Setting on InnerBlocks', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await requestUtils.activatePlugin( | ||
'gutenberg-test-innerblocks-prioritized-inserter-blocks' | ||
); | ||
} ); | ||
|
||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( | ||
'gutenberg-test-innerblocks-prioritized-inserter-blocks' | ||
); | ||
} ); | ||
|
||
test.describe( 'Quick Inserter', () => { | ||
test( 'uses defaulting ordering if prioritzed blocks setting was not set', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'test/prioritized-inserter-blocks-unset', | ||
} ); | ||
|
||
const block = page.getByRole( 'document', { | ||
name: 'Block: Prioritized Inserter Blocks Unset', | ||
} ); | ||
|
||
await block | ||
.getByRole( 'button', { | ||
name: 'Add block', | ||
} ) | ||
.click(); | ||
|
||
const blockListBox = page.getByRole( 'listbox', { | ||
name: 'Blocks', | ||
} ); | ||
await expect( blockListBox ).toBeVisible(); | ||
await expect( blockListBox.getByRole( 'option' ) ).toHaveCount( 6 ); | ||
} ); | ||
|
||
test( 'uses the priority ordering if prioritzed blocks setting is set', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'test/prioritized-inserter-blocks-set', | ||
} ); | ||
|
||
const block = page.getByRole( 'document', { | ||
name: 'Block: Prioritized Inserter Blocks Set', | ||
} ); | ||
|
||
await block | ||
.getByRole( 'button', { | ||
name: 'Add block', | ||
} ) | ||
.click(); | ||
|
||
const blockListBox = page.getByRole( 'listbox', { | ||
name: 'Blocks', | ||
} ); | ||
await expect( blockListBox ).toBeVisible(); | ||
|
||
// Should still be only 6 results regardless of the priority ordering. | ||
await expect( blockListBox.getByRole( 'option' ) ).toHaveCount( 6 ); | ||
await expect( blockListBox.getByRole( 'option' ) ).toContainText( [ | ||
'Audio', | ||
'Spacer', | ||
'Code', | ||
] ); | ||
} ); | ||
|
||
test( 'obeys allowed blocks over prioritzed blocks setting if conflicted', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks', | ||
} ); | ||
|
||
const block = page.getByRole( 'document', { | ||
name: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks', | ||
} ); | ||
|
||
await block | ||
.getByRole( 'button', { | ||
name: 'Add block', | ||
} ) | ||
.click(); | ||
|
||
const blockListBox = page.getByRole( 'listbox', { | ||
name: 'Blocks', | ||
} ); | ||
await expect( blockListBox ).toBeVisible(); | ||
|
||
await expect( blockListBox.getByRole( 'option' ) ).toContainText( [ | ||
'Spacer', | ||
'Code', | ||
'Paragraph', | ||
] ); | ||
await expect( | ||
blockListBox.getByRole( 'option' ) | ||
).not.toContainText( [ 'Audio' ] ); | ||
} ); | ||
} ); | ||
|
||
test.describe( 'Slash inserter', () => { | ||
test( 'uses the priority ordering if prioritzed blocks setting is set', async ( { | ||
editor, | ||
page, | ||
} ) => { | ||
await editor.insertBlock( { | ||
name: 'test/prioritized-inserter-blocks-set', | ||
} ); | ||
|
||
const imageBlock = page | ||
.getByRole( 'document', { | ||
name: 'Block: Prioritized Inserter Blocks Set', | ||
} ) | ||
.getByRole( 'document', { name: 'Block: Image' } ); | ||
|
||
await imageBlock.click(); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( '/' ); | ||
|
||
const blockAutocompleter = page.getByRole( 'listbox' ); | ||
await expect( blockAutocompleter ).toBeVisible(); | ||
|
||
// Default suggested blocks number. | ||
await expect( | ||
blockAutocompleter.getByRole( 'option' ) | ||
).toHaveCount( 9 ); | ||
await expect( | ||
blockAutocompleter.getByRole( 'option' ) | ||
).toContainText( [ 'Audio', 'Spacer', 'Code' ] ); | ||
} ); | ||
} ); | ||
} ); |