Skip to content

Commit

Permalink
Inserter e2e test: Test for focus stealing in small viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 25, 2021
1 parent c04dc00 commit 1ce5088
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/e2e-tests/specs/editor/various/inserter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createNewPost,
openGlobalBlockInserter,
insertBlock,
setBrowserViewport,
} from '@wordpress/e2e-test-utils';

describe( 'Inserter', () => {
Expand All @@ -25,20 +26,25 @@ describe( 'Inserter', () => {
expect( isPreviewVisible ).toBe( true );
} );

it( 'last-inserted block should be given and keep the focus', async () => {
await page.type(
'.block-editor-default-block-appender__content',
'Testing inserted block focus'
);
it.each( [ 'large', 'small' ] )(
'last-inserted block should be given and keep the focus (%s viewport)',
async ( viewport ) => {
await setBrowserViewport( viewport );

await insertBlock( 'Image' );
await page.type(
'.block-editor-default-block-appender__content',
'Testing inserted block focus'
);

await page.waitForSelector( 'figure[data-type="core/image"]' );
await insertBlock( 'Image' );

const selectedBlock = await page.evaluate( () => {
return wp.data.select( 'core/block-editor' ).getSelectedBlock();
} );
await page.waitForSelector( 'figure[data-type="core/image"]' );

expect( selectedBlock.name ).toBe( 'core/image' );
} );
const selectedBlock = await page.evaluate( () => {
return wp.data.select( 'core/block-editor' ).getSelectedBlock();
} );

expect( selectedBlock.name ).toBe( 'core/image' );
}
);
} );

0 comments on commit 1ce5088

Please sign in to comment.