-
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
Migrate RichText e2e tests to Playwright #53493
Conversation
Size Change: 0 B Total Size: 1.51 MB ℹ️ View Unchanged
|
99103eb
to
88f5d1d
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.
Nice to be able to read the expected results inline with the tests. Well done!
] ); | ||
} ); | ||
|
||
test( 'should apply multiple formats when selection is collapse', 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.
test( 'should apply multiple formats when selection is collapse', async ( { | |
test( 'should apply multiple formats when selection is collapsed', async ( { |
I was finding by titles to jump back and forth and compare old tests to new and so didn’t find this one right away.
] ); | ||
} ); | ||
|
||
test( 'should undo backtick transform with backspace', 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.
Total parity in the migration so ✅. On a side note, it happens that I was curious about this one because I didn't know about it. So I tried in Chrome/macOS and ended up with an empty paragraph. I could only get it to undo the transform if the `a` had content before it.
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.
Hm, it's working correctly for me. Need to press backspace immediately after typing it, you do anything else it will fail
88f5d1d
to
1c6d586
Compare
Flaky tests detected in f812f59. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6037609713
|
1c6d586
to
f812f59
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.
Is this file (and the other one below) supposed to be committed to the repo? c.c. @WunderBart
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.
Whoops, how did this happen?
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 definitely shouldn't! 😄 It looks like a custom WP_ARTIFACTS_PATH
env variable was used because those files are by default saved to /artifacts
path, unless specified otherwise by that var. Otherwise, maybe it was just copied/moved by accident? 🤷
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've just learned this can happen when running tests via the Playwright VSCode extension. The WP_ARTIFACTS_PATH
is not being set in that scenario, so the artifacts folder is created inside the cwd
, which is the running test file location.
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.
} ) => { | ||
await editor.canvas.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( '`a`' ); | ||
await page.evaluate( () => new Promise( window.requestIdleCallback ) ); |
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've said this before elsewhere but repeating it in case you missed it: I don't think e2e tests should rely on implementation details like this. I understand if this is just a 1-to-1 migration though! Flagging this again so that we can find another way to solve this in the future. c.c. @Mamaduka any idea?
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 welcome solutions. We have to specifically wait this amount of time, otherwise the test could be running too fast and we'd get flaky tests. There's code that's waiting for an idle callback.
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 we can make this test a bit more explicit, which might allow us to drop the requestIdleCallback
. For example:
test( 'should not undo backtick transform with backspace after selection change', async ( {
page,
pageUtils,
editor,
} ) => {
await editor.canvas
.getByRole( 'button', { name: 'Add default block' } )
.click();
await page.keyboard.type( '`test`' );
const inlineCode = editor.canvas
.getByRole( 'document', {
name: 'Paragraph block',
} )
.locator( 'code' );
await expect( inlineCode ).toHaveText( 'test' ); // Here we make sure the inline code exists before moving inside the format boundary.
// Move inside format boundary.
await pageUtils.pressKeys( 'ArrowLeft', { times: 2 } );
await pageUtils.pressKeys( 'ArrowRight' );
// Empty the inline code content.
await pageUtils.pressKeys( 'Backspace', { times: 4 } );
await expect( inlineCode ).not.toBeAttached();
// Ensure the backtick transform was not undone.
await page.keyboard.type( 'test' );
await expect( inlineCode ).toHaveText( 'test' );
} );
await page.keyboard.press( 'ArrowRight' ); | ||
await page.keyboard.press( 'Backspace' ); | ||
|
||
expect( await editor.getBlocks() ).toMatchObject( [] ); |
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 might be missing something here, but how does this ensure the backtick transform was not undone?
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 it's removed a
and didn't restore `a`
?
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.
So the test is for ensuring backspace works as expected inside the inline code boundary? Was there a regression where hitting backspace inside that boundary restored the string as well?
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.
No, this test is making sure that the transform is not undone after a selection change. Instead of undoing the transform, it should remove the character (default behaviour).
What?
Migrate RichText e2e tests to Playwright, remove snapshots.
Why?
Paves the way for some of these tests to be run in Webkit and Firefox, perhaps also reorganising some of these.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast