-
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
Testing: Add an e2e test to check the interactions in write mode #65819
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +11 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
packages/e2e-test-utils-playwright/src/editor/switch-editor-tool.ts
Outdated
Show resolved
Hide resolved
* @param this | ||
* @param label The text string of the button label. | ||
*/ | ||
export async function switchEditorTool( this: Editor, label: string ) { |
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.
Nit: Prefer using unions of string literals in types since we only have two options for now. Something like 'Design' | 'Write'
.
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'm hesitant, someone could decide to test another language.
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.
They're only types so I guess they can always bypass that. We can also add | string
to the end to allow arbitrary strings.
name: 'Editor settings', | ||
} ); | ||
await expect( | ||
editorSettings.locator( '.block-editor-block-card__title' ) |
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.
Using class name selectors is not recommended. Could we instead select it by getByRole
and optionally with a level
field here?
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 know but for me, this is not easy to pinpoint and avoid random failures when we add headings... I prefer the selector here.
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 there's already a heading in place? What do you mean by pinpointing random failures? I'd appreciate if we could follow the established best practices whenever possible and add comments if we could not. 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.
The h2
is not enough to say that I'm targeting the "title" of the inspector panel. There could be more h2 in the inspector panel, in fact there are already. (content).
We could theoretically say h2 > eq( 0 )
but that's not very stable, any random design change can break that. (moving titles around).
So for me, in this case, I prefer a non ambiguous assertion rather than a generic one.
I agree on following best practices, but we need to understand what's important and why they exist.
I'm happy to update If there's a less ambiguous approach using that doesn't use selectors.
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.
A common workaround practice throughout the codebase is using expect( getByRole('heading', {name: 'Group', level: 2}) ).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.
I'd echo Riad about until fixing the a11y issue, we should stick with that classname for now and unblock this PR. Let's create an issue for this.
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 need to block this PR. But we should raise a followup Issue as suggested with the appropriate labels to get Accessibility feedback.
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.
IMO, getByRole
is always preferred, in cases when it doesn't apply, we should still fallback to alternatives like getByTestId
than class name selectors. I don't understand the argument of using class name selectors being more "solid". TBH, this has happened too many times that this is becoming frustrating to me. Could we at least add a comment above indicating that this is an edge case so that people won't accidentally follow the practice? I don't think it should block this PR, but I think this type of issue is still important, especially given that it just flagged a potential accessibility concern here by trying to avoid the class name selectors.
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'll add a comment. I'm not sure we used test ids 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.
Thanks for the comment.
Nit: the wording isn't quite accurate and should read (emphasis added for clarity):
// Ideally we should **_NOT_** be using CSS selectors
30071fb
to
f158e0e
Compare
Flaky tests detected in f158e0e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11141739869
|
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.
LGTM, thanks!
We need these kind of tests sooner than later. Let's create an issue for this and ship this.
@@ -104,6 +104,9 @@ test.describe( 'Write/Design mode', () => { | |||
name: 'Editor settings', | |||
} ); | |||
await expect( | |||
// Ideally we should be using CSS selectors |
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.
"not" be using CSS selectors? 😅
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.
haha :)
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's fixed in trunk.
…dPress#65819) Co-authored-by: youknowriad <[email protected]> Co-authored-by: kevin940726 <[email protected]> Co-authored-by: getdave <[email protected]> Co-authored-by: ntsekouras <[email protected]>
Related #60021
What?
This PR adds a first e2e test to check the different interactions in the "write" mode.
Starting with inspector and mouse selection.