-
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
EditPostPreferencesModal: refactor to remove snapshots for index.js #54141
Conversation
a1f607d
to
865aecb
Compare
Size Change: 0 B Total Size: 1.51 MB ℹ️ View Unchanged
|
…anges when the viewport width changes (show toggle inputs vs don't)
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 good to me! It might be worth confirming with @ntsekouras or others if there were any other reasons that snapshot tests were used for this component, over testing for the visibility of particular child components as in this PR. Personally, in general, I much prefer tests like in this PR, as it makes it clearer what's being tested for, and is less prone to fail due to side effects.
Since it sounds like this will help unblock things on trunk
, this LGTM to merge, and we can always roll back if it turns out that the snapshots were needed for other aspects of the test coverage (or add additional tests for what needs to be covered).
Thanks 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.
Thank you for fixing this. My previous attempt to fix the snapshot has failed, and it would be exceedingly difficult to make it really right. Testing for specific elements or behavior is better than a summary snapshot.
Thanks for confirming, Jarda! |
No specific reasons.. These tests look fine, thank you for handling that! |
Thanks for double-checking everyone! 🙇🏻 |
I've noticed similar failures (Modal or Popover related) with |
I saw those too. The opacity changes on the inline styles. I wasn't sure if it was related to the aria-kit changes or not, but maybe there's scope to remove the snapshot there too. |
@Mamaduka I have a PR up to fix that test: |
What?
Every second or third run, I'm seeing the following errors in both local and CI JS unit tests
This PR already tried to fix this test:
Historical context: #52133 (comment)
Instead of waiting around for aria-kit to add the tab-index attribute, this PR just gets rid of the relevant snapshot, and, rather, tests for main view elements to verify that the viewport switch is made. Thanks to @andrewserong for helping to debug
The snapshots seem to only test whether
useViewportMatch
renders the correct views. By testing for some key elements we don't need the entire snapshot.There's also a strong argument to turn this into an E2E test, but for now, I'm just getting the tests to pass to unblock folks.
How are you?
All good here, thanks!
Testing Instructions
Check CI
npm run test:unit packages/edit-post/src/components/preferences-modal/test/index.js
until you get sick of it