-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Multi-select: restore pre-Playwright migration test for failed selection attempt #53418
Conversation
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
// Wait for: | ||
// https://github.com/WordPress/gutenberg/blob/eb2bb1d3456ea98db74b4518e3394ed6aed9e79f/packages/block-editor/src/components/writing-flow/use-drag-selection.js#L47 | ||
await page.evaluate( | ||
() => new Promise( window.requestAnimationFrame ) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing implementation details and we generally want to avoid that in e2e tests. Could you think of any other way? Perhaps just waiting for the user-visible results?
const [ coord1, coord2 ] = await editor.canvas.evaluate( () => { | ||
const selection = window.getSelection(); | ||
|
||
// Move caret to the start of the second block. | ||
await paragraph2.click( { position: { x: 0, y: height / 2 } } ); | ||
await page.mouse.down(); | ||
await paragraph1.hover( { | ||
position: { x: -5, y: height / 2 }, | ||
// Use force since it's outside the bounding box of the element. | ||
force: true, | ||
if ( ! selection.rangeCount ) { | ||
return; | ||
} | ||
|
||
const range = selection.getRangeAt( 0 ); | ||
const rect1 = range.getClientRects()[ 0 ]; | ||
const element = document.querySelector( | ||
'[data-type="core/paragraph"]' | ||
); | ||
const rect2 = element.getBoundingClientRect(); | ||
const iframeOffset = window.frameElement.getBoundingClientRect(); | ||
|
||
return [ | ||
{ | ||
x: iframeOffset.x + rect1.x, | ||
y: iframeOffset.y + rect1.y + rect1.height / 2, | ||
}, | ||
{ | ||
// Move a bit outside the paragraph. | ||
x: iframeOffset.x + rect2.x - 5, | ||
y: iframeOffset.y + rect2.y + rect2.height / 2, | ||
}, | ||
]; | ||
} ); | ||
|
||
await page.mouse.click( coord1.x, coord1.y ); | ||
await page.mouse.down(); | ||
await page.mouse.move( coord2.x, coord2.y, { steps: 10 } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the steps
here for?
What?
A regression in #48035.
This test was previous testing an operation on a single block, moving the mouse from the caret out of the paragraph. The migrated test does something completely different with two blocks, so this test is no longer working.
I'm not sure why it was altered so much, the same APIs are available in Playwright, so this could have literally kept the same test line by line.
I adjusted the rectangles to take into account the iframe offset that was recently introduced.
Why?
When I remove the code that was supposed to make this test fail, it still passes.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast