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

Inserter: Add e2e test to make sure last inserted block is being focused #29187

Merged
merged 2 commits into from
Feb 24, 2021
Merged
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
23 changes: 22 additions & 1 deletion packages/e2e-tests/specs/editor/various/inserter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import {
createNewPost,
openGlobalBlockInserter,
insertBlock,
} from '@wordpress/e2e-test-utils';

describe( 'Inserter', () => {
it( 'shows block preview when hovering over block in inserter', async () => {
beforeEach( async () => {
await createNewPost();
} );

it( 'shows block preview when hovering over block in inserter', async () => {
await openGlobalBlockInserter();
await page.focus( '.editor-block-list-item-paragraph' );
const preview = await page.waitForSelector(
Expand All @@ -20,4 +24,21 @@ describe( 'Inserter', () => {
const isPreviewVisible = await preview.isIntersectingViewport();
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'
);

await insertBlock( 'Image' );

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

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

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