Skip to content

Commit

Permalink
Adds focus management test for entity undo (#49236)
Browse files Browse the repository at this point in the history
* Adds focus management test for entity undo

* removes the extra user story group and adds the test as a case to the existing template part grouping

* undo edit in grouping name

* Adds some comments and a small readability fix

Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: Kai Hao <[email protected]>

---------

Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: Kai Hao <[email protected]>
  • Loading branch information
3 people committed Mar 27, 2023
1 parent 98020a4 commit 169251a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 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,52 @@ 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 );

// Remove the default site title block.
await pageUtils.pressKeys( 'access+z' );

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

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

// Change heading level of the Site Title block.
await editor.clickBlockToolbarButton( 'Change heading level' );
const Heading3Button = page.getByRole( 'menuitemradio', {
name: 'Heading 3',
} );
await Heading3Button.click();

// Undo the change.
await pageUtils.pressKeys( 'primary+z' );

await expect(
page.locator( 'role=button[name="Change heading level"i]' )
).toBeFocused();
} );
} );

1 comment on commit 169251a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 169251a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4533536220
📝 Reported issues:

Please sign in to comment.