Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Sep 22, 2021
1 parent e92ec8a commit 6822b95
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/e2e-tests/specs/editor/various/inserting-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
searchForBlock,
setBrowserViewport,
showBlockToolbar,
pressKeyWithModifier,
} from '@wordpress/e2e-test-utils';

/** @typedef {import('puppeteer').ElementHandle} ElementHandle */
Expand Down Expand Up @@ -354,6 +355,28 @@ describe( 'Inserting blocks', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'passes the search value in the main inserter when clicking `Browse all`', async () => {
const INSERTER_SEARCH_SELECTOR =
'.block-editor-inserter__search input,.block-editor-inserter__search-input,input.block-editor-inserter__search';
await insertBlock( 'Group' );
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Text' );
await page.click( '[data-type="core/group"] [aria-label="Add block"]' );
await page.waitForSelector( INSERTER_SEARCH_SELECTOR );
await page.focus( INSERTER_SEARCH_SELECTOR );
await pressKeyWithModifier( 'primary', 'a' );
const searchTerm = 'Heading';
await page.keyboard.type( searchTerm );
const browseAll = await page.waitForXPath(
'//button[text()="Browse all"]'
);
await browseAll.click();
const availableBlocks = await page.$$(
'.block-editor-block-types-list__list-item'
);
expect( availableBlocks ).toHaveLength( 1 );
} );

// Check for regression of https://github.com/WordPress/gutenberg/issues/27586
it( 'closes the main inserter after inserting a single-use block, like the More block', async () => {
await insertBlock( 'More' );
Expand Down

0 comments on commit 6822b95

Please sign in to comment.