-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
feat: add start
and end
hooks to the fireEvent
helper
#1185
Conversation
Thanks for doing this, @shamrt. Would you mind taking a look at the failing CI?
|
In broad strokes this changes seems really great. One issue is I think there may be unrelated changes included in this PR, which makes it a tad more difficult to review. Is there anything we can pull out as a separate, discrete change? |
I'd say there are a couple of changes that aren't necessary to this PR, such as:
I'll revert those changes. If you can think of any others, please let me know. |
}) | ||
.then(({ focusTarget, previousFocusedElement }) => { | ||
if (!focusTarget) { | ||
throw new Error('There was a previously focused element'); |
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.
Throwing an error here (and later catch
ing) in order to mimic the behaviour previously handled by a return
statement.
Alright, I've reverted a few things. Hopefully that tightens up the PR a bit. |
Checking in to see whether I've covered everything for this PR. I think it's ready for re-review. Thanks! |
@shamrt I'll take another look. Thanks so much for simplifying! |
.then(() => runHooks('fireEvent', 'start', element)) | ||
.then(() => runHooks(`fireEvent:${eventType}`, 'start', element)) |
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 like the flexibility this provides. It's a nice composition of general to specific!
) | ||
.then(() => settled()); | ||
}) | ||
.catch(() => {}); |
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.
Should we not let the exception propagate and fail the test if an exception is thrown?
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 mention in the comment above that the thrown error is a stand-in for the earlier return
statement (see L62 of original code). Given we simply want to short-circuit the Promise chain, I didn't see any purpose in processing or propagating the error.
Additionally, given this function is being executed in a nested Promise within the focus
function (see L155 of new code), the parent Promise chain doesn't know whether the child Promise resolved or was rejected (AFAIK).
This should result in the same behaviour we had when this function was synchronous. It doesn't look or feel great, but it gets the job done.
That said, I'm open to suggestions!
Overall this looks really good. It's crazy how much simpler the code would be with async/await... |
@rwjblue Any chance you'll have time to review this PR this week? Thanks! |
Hey folks 👋 I'm just pinging here in case we didn't see my issue from yesterday: #1210 I don't know how widespread this is going to be but if a lot of people are going to hit this problem it might be good to move on it sooner rather than later. Let me know your thoughts 👍 |
Hi @mansona. I'm very sorry this happened! I'm taking a look at the issue today, which I've been able to replicate. Hopefully I can come up with a patch for you. |
No worries, thanks for looking into it @shamrt 🎉 Can you expand a bit what the difference is? and how wide-reaching the regression is likely to be? I'm trying to figure out if this is going to be a widespread enough issue that we should really revert sooner rather than later and add the fix to an updated PR. I don't really know enough about the issue to be able to judge but maybe you have an idea, especially since you have been able to replicate the issue |
@shamrt any more info on what the issue is? |
I'm still digging into it at work. The apparent source is unclear, but I'll post progress either way tomorrow |
TL;DR: I've spent a solid chunk of time trying to debug this issue, but have run up against a wall, and have been forced to time-box it at work. Debug and reproduction steps:
I'm at a complete loss, at this point, as to why this issue has sprung up. It appears to be a legitimate edge case, but I'm flummoxed. Side-question for the library maintainers: Given the library now only supports Ember 3.8, Node 10 supports |
REVIEWER NOTE: Use of
Hide whitespace
option recommended.Following suggestions in #1182 and #1183, the following PR:
fireEvent
helper to a Promise in order to support the hooks systemstart
andend
hooks to thefireEvent
helperstart:[eventType]
andend:[eventType]
hooks to thefireEvent
helper for finer controlfireEvent
helper