-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Migrate multi-block selection E2E tests to Playwright #48035
Conversation
Size Change: 0 B Total Size: 1.34 MB ℹ️ View Unchanged
|
Flaky tests detected in 21b6549. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4319674233
|
@WunderBart Have you worked on this yet? I have some WIP code on my local branch. If you don't mind, I'd be happy to contribute to it as well :)! |
👋 @kevin940726, so far only what's committed here, so feel free to push what you got! 🚀 |
@WunderBart Nice! I think I've already migrated half of the test cases, so it would be nice if you could hold it up a little bit and help me review it once I'm done 😅 . |
4e77743
to
245ad39
Compare
.toEqual( [ 3 ] ); | ||
} ); | ||
|
||
test( 'should deselect with Escape', async ( { |
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 was originally marked as a flaky test and skipped.
// FIXME: This doesn't seem to work anymore. | ||
// await expect | ||
// .poll( multiBlockSelectionUtils.getSelectedFlatIndices ) | ||
// .toEqual( [] ); |
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.
Pressing escape no longer deselects the blocks. I guess we would want to mark this test as .fail
and create an issue for it?
] ); | ||
} ); | ||
|
||
test( 'should copy and paste', async ( { page, editor, pageUtils } ) => { |
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.
As per the best practices of Playwright, this is now a combination of multiple similar test cases:
should copy and paste
should place the caret at the end of last pasted paragraph (paste to empty editor)
should place the caret at the end of last pasted paragraph (paste mid-block)
should place the caret at the end of last pasted paragraph (replace)
.toBe( 'Post title' ); | ||
} ); | ||
|
||
test( 'should multi-select in the ListView component with shift + click', async ( { |
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 now a combination of two test cases because they share the same initial state:
should multi-select in the ListView component with shift + click
should multi-select in the ListView component with shift + up and down keys
await expect( | ||
navButtons.nth( 3 ).getByRole( 'link', { includeHidden: true } ) | ||
).toBeFocused(); | ||
// Press Up twice to highlight the second block. |
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.
The original comment suggested that it would "focus" the block, but in reality, it only "highlights" the block.
e1e9623
to
137481b
Compare
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 one's massive! 🥵 Awesome work, thank you @kevin940726! 🎉
I left just a few non-blocking comments. I'd approve but I can't since I've opened it 🤷
// Move to the middle of the first line. | ||
await pageUtils.pressKeyTimes( 'ArrowUp', 4 ); | ||
await page.keyboard.press( 'ArrowRight' ); | ||
// Select mid line one to mid line four. | ||
await pageUtils.pressKeyTimes( 'Shift+ArrowDown', 3 ); | ||
// Delete the text to see if the selection was correct. | ||
await page.keyboard.press( 'Backspace' ); |
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.
Should we combine pressKeyTimes
and pressKeyWithModifier
into a single pressKey
util? We could then use only that, e.g.:
await pageUtils.pressKey( 'ArrowUp', { times: 4 } );
await pageUtils.pressKey( 'ArrowRight' ); // instead of page.keyboard.press(...
await pageUtils.pressKey( 'ArrowDown', { modifier: 'Shift', times: 3 } );
await pageUtils.pressKey( 'Backspace' );
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.
Yeah! That sounds like a good idea! Probably should do it in another PR though.
await editor.canvas | ||
.getByRole( 'button', { name: 'Add default block' } ) | ||
.click(); |
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.
Any reason we're not inserting the block programmatically here as well?
await editor.canvas | |
.getByRole( 'button', { name: 'Add default block' } ) | |
.click(); | |
await editor.insertBlock( { | |
name: 'core/paragraph', | |
attributes: { content: '' }, |
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.
Because insertBlock
doesn't place the caret at the end of the paragraph block. It's just a bit easier sometimes to manually type it than focusing and moving the caret after inserting the block.
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.
Thanks for the review @WunderBart ! I'll approve it myself then 😆 .
20b26eb
to
21b6549
Compare
await clickBlockAppender(); | ||
await page.keyboard.type( '1' ); | ||
await page.keyboard.type( '2' ); | ||
await page.keyboard.press( 'ArrowLeft' ); |
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.
Unfortunately the new test is not doing the same thing. Restored it in #53418. Why not simply copy over the old test as is?
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.
Oops! I think I misunderstood the two separate .type()
calls and thought that they were inserting two blocks. Thanks for catching that!
Why not simply copy over the old test as is?
Because it's not only a migration but also a refactor trying to fix the longstanding flakiness of the original test.
What?
Migrate multi-block selection E2E tests to Playwright.
Why?
How?
Testing Instructions
The output of the following should be all ✅: