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

Adds focus management test for entity undo #49236

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Changes from 3 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
46 changes: 46 additions & 0 deletions test/e2e/specs/site-editor/template-part.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,50 @@ test.describe( 'Template Part', () => {
page.getByRole( 'combobox', { name: 'Import widget area' } )
).not.toBeVisible();
} );

test( 'Keeps focus in place on undo in template parts', async ( {
admin,
editor,
page,
pageUtils,
} ) => {
await admin.visitSiteEditor( {
postId: 'emptytheme//header',
postType: 'wp_template_part',
} );
await editor.canvas.click( 'body' );

// Select the site title block.
const siteTitle = editor.canvas.getByRole( 'document', {
name: 'Site title',
} );
await editor.selectBlocks( siteTitle );

await pageUtils.pressKeys( 'access+z' );
draganescu marked this conversation as resolved.
Show resolved Hide resolved
draganescu marked this conversation as resolved.
Show resolved Hide resolved

// Insert a group block
await editor.insertBlock( {
name: 'core/group',
innerBlocks: [ { name: 'core/site-title' } ],
} );

// Select the site title block.
const siteTitleInGroup = editor.canvas.getByRole( 'document', {
name: 'Site title',
} );
await editor.selectBlocks( siteTitleInGroup );

// Change heading level.
await editor.clickBlockToolbarButton( 'Change heading level' );
const Heading3Button = page.locator(
'role=menuitemradio[name="Heading 3"i]'
);
draganescu marked this conversation as resolved.
Show resolved Hide resolved
await Heading3Button.click();

await pageUtils.pressKeys( 'primary+z' );
draganescu marked this conversation as resolved.
Show resolved Hide resolved
draganescu marked this conversation as resolved.
Show resolved Hide resolved

await expect(
page.locator( 'role=button[name="Change heading level"i]' )
).toBeFocused();
draganescu marked this conversation as resolved.
Show resolved Hide resolved
} );
} );