Repository navigation
Multi-select: restore pre-Playwright migration test for failed selection attempt - #53418
Merged
Merged
Conversation
|
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
kevin940726
reviewed
Aug 8, 2023
Comment on lines
+613
to
+617
| // 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 ) | ||
| ); |
Member
There was a problem hiding this comment.
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?
Comment on lines
+580
to
+610
| 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 } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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