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

Escape as Select/Edit mode Toggle #58637

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Prev Previous commit
Next Next commit
Replace deselect block test with toggle navigation and edit mode test
  • Loading branch information
jeryj committed Feb 5, 2024
commit c667abeab01d012e57ce0a7103fec11b681e33a6
20 changes: 12 additions & 8 deletions test/e2e/specs/editor/various/writing-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,28 +927,32 @@ test.describe( 'Writing Flow (@firefox, @webkit)', () => {
<!-- /wp:table -->` );
} );

test( 'should unselect all blocks when hitting double escape', async ( {
test( 'escape should toggle between edit and navigation modes', async ( {
page,
writingFlowUtils,
} ) => {
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'Random Paragraph' );

await expect
.poll( writingFlowUtils.getActiveBlockName )
.toBe( 'core/paragraph' );

// First escape enters navigaiton mode.
// First escape enters navigation mode.
await page.keyboard.press( 'Escape' );
const navigationButton = page.getByLabel(
'Paragraph Block. Row 1. Random Paragraph'
);
await expect( navigationButton ).toBeVisible();
await expect
.poll( writingFlowUtils.getActiveBlockName )
.toBe( 'core/paragraph' );

// Second escape unselects the blocks.
// Second escape Toggles back to Edit Mode
await page.keyboard.press( 'Escape' );
await expect( navigationButton ).toBeHidden();
const blockToolbar = page.getByLabel( 'Block tools' );

await expect( blockToolbar ).toBeVisible();
await expect
.poll( writingFlowUtils.getActiveBlockName )
.toBe( undefined );
.toBe( 'core/paragraph' );
} );

// Checks for regressions of https://github.com/WordPress/gutenberg/issues/40091.
Expand Down