Skip to content

Commit

Permalink
Inline page.evaluate and use expect.poll
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Aug 31, 2022
1 parent 5d9dc81 commit a977eea
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/e2e/specs/editor/various/writing-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ test.describe( 'Writing Flow', () => {
// editor state, in order to protect against potential disparities.
//
// See: https://github.com/WordPress/gutenberg/issues/18928
let activeElementText;

await writingFlowUtils.addDemoContent();

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

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

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

0 comments on commit a977eea

Please sign in to comment.