Skip to content
Merged
Changes from all 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
21 changes: 21 additions & 0 deletions packages/e2e-tests/specs/editor/various/typewriter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,32 @@ describe( 'TypeWriter', () => {
).scrollTop = 1 )
);

/*
* The scroll event fires on the next animation frame, and the
* Typewriter recalculates the caret rectangle in an animation frame
* of its own after that, so wait two frames before reading it.
*/
await page.evaluate(
() =>
new Promise( ( resolve ) =>
window.requestAnimationFrame( () =>
window.requestAnimationFrame( resolve )
)
)
);

const initialPosition = await getCaretPosition();

// Should maintain scroll position.
await page.keyboard.press( 'Enter' );

// Wait for the Typewriter to scroll down past the initial position.
await page.waitForFunction(
() =>
wp.dom.getScrollContainer( document.activeElement ).scrollTop >
1
);

expect( await getDiff( initialPosition ) ).toBeLessThanOrEqual(
BUFFER
);
Expand Down
Loading