-
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
CustomSelectControl: align v1 and legacy v2 unit tests #62706
CustomSelectControl: align v1 and legacy v2 unit tests #62706
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: 0 B Total Size: 1.76 MB ℹ️ View Unchanged
|
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.
Looks great. I appreciate the clarity this brings when looking at the 2 distinct test suites 🙌
expect( mockOnChange ).toHaveBeenNthCalledWith( | ||
1, | ||
expect.objectContaining( { | ||
inputValue: '', | ||
isOpen: false, | ||
// TODO: key should be different — this is a known bug and will be fixed |
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.
👍
} ) | ||
); | ||
|
||
// DIFFERENCE WITH V2: NOT CALLED |
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.
If this is something that we need to update, let's add a TODO comment to remember to address 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.
I'm not sure about how much we can do about this, since:
- we don't want to change the v1 behaviour (which doesn't call
onChange
on initial render) - the v2 behaviour comes directly from
Ariakit
— I'm not sure how easy it would be to suppress only the first call without introducing unwanted side effects.
I will add an item to the tracking issue
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.
Good news! This will be fixed in #62733
/> | ||
); | ||
|
||
await user.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.
Just to confirm, using @testing-library/user-event
for v1 vs using @ariakit/test
for legacy v2 is an expected difference, right?
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 is — we had to use @ariakit/test
for ariakit-based components as (if I recall) @testing-library/user-event
doesn't work well with how Ariakit performs DOM updates
What?
While working on #62255 and, more in general, on refining the new version of
CustomSelectControl
, one of the main tasks is to make sure that the new version of the component offers an easy way to replace the old implementation with the new implementation pain-free — and that is what the legacy v2 version is for. It implements the same API surface as the v1 and it aims at behaving as closely as possible as the v1, despite its internal implementation is completely different.This PR aims at aligning further the unit tests between v1 and legacy v2 as much as possible, as a way to gain more confidence when making future fixes and changes to the legacy v2 version.
Why?
See above.
How?
Making sure that the unit tests for v1 and legacy v2 overlap as much as possible
Testing Instructions
No runtime changes