-
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 quote e2e tests to playwright #46549
Conversation
await page.keyboard.press( 'ArrowRight' ); | ||
await page.keyboard.type( '2' ); | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
await pageUtils.pressKeyTimes( 'ArrowLeft', 4 ); |
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.
Originally, the arrow-left was used for keystrokes.
However, as discovered in this comment, the arrow-up key may cause unstable behavior depending on the theme, so it is rewritten as the arrow-left key.
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.
Maybe we should leave an inline comment here. What do you think?
Size Change: +1.42 kB (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Thanks for working on this, @t-hamano 🦸 The migration looks great, and I will review this first thing tomorrow 👍
The updated guidelines haven't been merged yet, but the inline snapshot would be preferred here. Plus, we don't have a block assertions helper in place yet. See the rendered document about snapshot assertions: https://github.com/WordPress/gutenberg/blob/f2d2fa14f18ba1d257ede08b714940d4c3ba5590/docs/contributors/code/e2e/overusing-snapshots.md. |
Thanks for the info, @Mamaduka! I have read the update guidelines. Personally, I think inline snapshots are appropriate for this test, but if the approach using |
@t-hamano, using inline snapshots with |
I replaced it with an inline snapshot. |
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.
Thank you, @t-hamano! The migration looks great.
I've only left a few suggestions.
test.describe( 'Quote', () => { | ||
test.beforeEach( async ( { admin } ) => { | ||
await admin.createNewPost(); | ||
} ); | ||
|
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.
We should probably clean up after all tests are done.
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deleteAllPosts();
} );
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.
Done.
By the way, I think that once #46459 is merged, The clean-up might no longer be needed 🤔
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. That would be great. We can remove post-cleanup methods after that is confirmed in #46459.
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'two' ); | ||
await page.keyboard.down( 'Shift' ); | ||
await page.click( '[data-type="core/paragraph"] >> nth=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.
Suggestion: You can use role selector + explicit text for the block. Maybe something like this:
await page.click( 'role=document[name="Paragraph block"i] >> text=one' );
P.S. I've tested this selector in this case, but have used similar one before :)
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.
Done.
await page.keyboard.press( 'ArrowRight' ); | ||
await page.keyboard.type( '2' ); | ||
expect( await editor.getEditedPostContent() ).toMatchSnapshot(); | ||
await pageUtils.pressKeyTimes( 'ArrowLeft', 4 ); |
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.
Maybe we should leave an inline comment here. What do you think?
I have added the following comment, is it appropriate? // Move the cursor to the start of the first paragraph of the quoted block.
await pageUtils.pressKeyTimes( 'ArrowLeft', 4 ); |
Thanks again. Feel free to merge after all checks are green ✅ |
* Migrate qupte e2e tests to playwright * Use inline snapshots * Add `deleteAllPosts` * Use accesible selector * Add an inline comment for `pressKeyTimes`
What?
Part of #38851.
Migrate
quote.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/blocks/quote.spec.js
Note