-
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
ToolsPanel: Improve unit tests #35658
Conversation
Size Change: -5.08 kB (0%) Total Size: 1.07 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.
Thank you @aaronrobertshaw for working on this! I left a few inline comments.
No test for the above case has been added yet as the issue stems from the switching between blocks. This switching of block selections results in the fills rendered in a single panel being mutated. I haven't found a means of triggering this via the unit tests.
@andrewserong do you have any suggestions on how we could check for this behaviour?
Now we aren't checking specifically just for the panel container's existence there is overlap with other tests and the benefit of separating individual concerns is lost. For a general overview test it seems ok to merge them.
After an earlier refactor it was missed that this could be the more direct getByText call instead.
I've revisited this with some fresh eyes after the weekend. The best I could find to test that the
Removing the check added in #35375 or fudging the |
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 digging into the issue with changing panelIds @aaronrobertshaw, much appreciated! I'm glad you managed to come up with an example that mimics the behaviour we observed when switching blocks, without needing to pull in the actual block switching behaviour 👍
It's a complex situation to deal with, but the inline comments make sense to me, and for someone glancing at the test, even if they don't understand all the moving pieces, it's clear that the main thing that's changing between the two renders is that the panelId has changed, along with the optional item being toggled. While it is testing an internal state, in this situation, I think it's worth it to include the regression test how you've written it, without having to artificially build out a block switching UI for the purposes of the test. But most importantly, we've now got test coverage for a difficult to test edge case! 🎉
The changes to the existing tests all look good to me, and I confirmed that reverting #35375 causes the additional test to fail 👍
Fixes: #35057
Description
This PR improves the
ToolsPanel
unit tests so there are no uses ofquerySelector
,querySelectorAll
, and no accessing of parent nodes.It also simulates a change of block selection with a SlotFill provided control and ensures the
onDeselect
callback isn't called erroneously.How has this been tested?
Run
npm run test-unit packages/components/src/tools-panel/test
Screenshots
Types of changes
Enhancement
Checklist:
*.native.js
files for terms that need renaming or removal).