Skip to content

Commit

Permalink
Use :focus locator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Sep 1, 2022
1 parent 1c928c6 commit 4b45e2f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions test/e2e/specs/editor/various/writing-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ test.describe( 'Writing Flow', () => {
// See: https://github.com/WordPress/gutenberg/issues/18928
await writingFlowUtils.addDemoContent();

const activeElementLocator = page.locator( ':focus' );

// Arrow up into nested context focuses last text input.
await page.keyboard.press( 'ArrowUp' );
await expect
.poll( writingFlowUtils.getActiveBlockName )
.toBe( 'core/paragraph' );
await expect
.poll( () =>
page.evaluate( () => document.activeElement.textContent )
)
.toBe( '2nd col' );
await expect( activeElementLocator ).toBeFocused();
await expect( activeElementLocator ).toHaveText( '2nd col' );

// Arrow up in inner blocks should navigate through (1) column wrapper,
// (2) text fields.
Expand All @@ -57,11 +56,8 @@ test.describe( 'Writing Flow', () => {
await expect
.poll( writingFlowUtils.getActiveBlockName )
.toBe( 'core/paragraph' );
await expect
.poll( () =>
page.evaluate( () => document.activeElement.textContent )
)
.toBe( 'First paragraph' );
await expect( activeElementLocator ).toBeFocused();
await expect( activeElementLocator ).toHaveText( 'First paragraph' );

expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down

0 comments on commit 4b45e2f

Please sign in to comment.