-
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 Block Mover Test For Playwright #42039
Migrate Block Mover Test For Playwright #42039
Conversation
Hi @kevin940726, I hope you are doing well! Could you please help me in reviewing this PR? Thanks!! |
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 working on this! I left a few comments about how we can take advantage playwright's nicer API. I haven't tested the code snippets, so you might need to double check they're correct.
await page.click( '.block-editor-default-block-appender' ); | ||
await page.keyboard.type( 'First Paragraph' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'Second Paragraph' ); |
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.
I think it would be good to simplify this part with something like:
await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'First Paragraph' } } );
await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'Second Paragraph' } } );
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.
Worked on the feedbacks
const count = await page.$$eval( | ||
'.block-editor-block-mover', | ||
( el ) => el.length | ||
); | ||
expect( count ).toBe( 1 ); |
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.
It'd be good to take advantage of Playwright's locator system here, and use the role selector:
const moveDownButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move down"i]' );
const moveUpButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move up"i]' );
await expect( moveDownButton ).toBeVisible();
await expect( moveUpButton ).toBeVisible();
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.
Worked on the feedbacks
await page.click( '.block-editor-default-block-appender' ); | ||
await page.keyboard.type( 'First Paragraph' ); |
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.
Similar to the previous comment, this can change to:
await editor.insertBlock( { name: 'core/paragraph', attributes: { content: 'First Paragraph' } );
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.
Worked on the feedbacks
const count = await page.$$eval( | ||
'.block-editor-block-mover', | ||
( el ) => el.length | ||
); | ||
expect( count ).toBe( 0 ); |
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.
And this part could also be refactored to be use locators:
const moveDownButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move down"i]' );
const moveUpButton = page.locator( 'role=toolbar[name="Block tools"i] >> role=button[name="Move up"i]' );
await expect( moveDownButton ).toBeHidden();
await expect( moveUpButton ).toBeHidden();
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.
Worked on the feedbacks.
Hi @talldan, I have addressed all the feedbacks, could you please review again? Also I noticed that CI is failing but not related to the test case I worked on. I am little confused here 🤔 |
Thanks for making those changes!
Some of our old tests are not very reliable, which is one of the reasons for migrating them to Playwright. I've restarted them to see if they pass. |
Hi @talldan, good morning.. All the CI checks have passed except the End to End Tests / Admin -3 🤔 |
Did a another retry and managed to get it passing 👍 |
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 working on this!
Thank you :) |
What?
Part of #38851.
Migrate block-mover.test.js to its Playwright version.
Why?
Part of #38851.
How?
See MIGRATION.md for migration steps.
Testing Instructions
Run
npm run test-e2e:playwright test/e2e/specs/editor/various/block-mover.spec.js