-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix: mark as visited on change in addition to blur #2138
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2138 +/- ##
=======================================
Coverage 93.71% 93.71%
=======================================
Files 62 62
Lines 1607 1607
Branches 361 361
=======================================
Hits 1506 1506
Misses 66 66
Partials 35 35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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
const projectInput = await findByTestId('project'); | ||
await user.type(projectInput, '123'); | ||
// Mimic change that happens without blur | ||
fireEvent.change(projectInput); |
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.
Was looking into this a bit. I guess it doesn't work with user.type
because testing library is just calling dispatchEvent
for the respective keyboard events, it doesn't integrate with the browser driver to natively press keys. As such it probably can't trigger the change event of a native input.
setCount(count + 1); | ||
return !entity.projectId; |
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.
Regarding spy usage: It's possible to define a spy outside of the component and call the spy here. That requires adding a timeout before the assertion though, it looks like there is some async processing in the binder. Not sure if that makes things easier.
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. I guess we can keep the current approach as it's not very complicated anyway.
646b367
to
e96ca41
Compare
Quality Gate passedIssues Measures |
This ticket/PR has been released with Hilla 24.4.0.alpha8 and is also targeting the upcoming stable 24.4.0 version. |
Description
Fixes #2134
Type of change
Note: I'm not very happy with my approach to test this (like, I'd prefer to spy on validator). Suggestions are welcome.
Also, ideally we wouldn't need to use
fireEvent
manually, as native<input type="number">
fires it on Enter.But for some reason
user.type(projectInput, '123[Enter]')
didn't work this way, probably RTL doesn't handle this case.