Skip to content
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

Ensure typeIn does not await settled() after each event #707

Merged
merged 3 commits into from
Oct 25, 2019

Conversation

jakebixbyavalara
Copy link
Contributor

@jakebixbyavalara jakebixbyavalara commented Sep 13, 2019

The current behavior of the typeIn helper waits for settled promises between text inputs/key events. This is not ideal because it prevents the helper from being used for testing things like debounced functions (like in a typeahead component for instance).

Here is a repro repo demonstrating the issue., I originally encountered the behavior using an ember-concurrency timeout to debounce a task, which worked fine in the app, but began failing in test due to the change to the triggerKeyEvent helper.

This PR fixes the issue by making the triggerKeyEvent helper optionally wait for settled promises via a boolean. It's a simple fix that may be overlooking something, so please let me know if there would be a more preferred solution.

Initial PR text (when it was just a failing test PR):

Previous to this PR, the typeIn helper would not wait for settled promises, allowing the helper to work with things like run.debounce or ember-concurrency timeout in test. Now the helper waits for any unsettled promises to settle between input because it now uses the triggerKeyEvent (which waits for settled promises).

Added failing test for typeIn waiting for other promises, and will try and take a crack at fixing it as well. I mainly wanted to put this PR up for eyes and advice if I hit any walls.

@jakebixbyavalara
Copy link
Contributor Author

I figured out a way to fix this, by optionally returning settled from triggerKeyEvent, we can have it just return resolve in the cases where we intentionally don't want it to wait for. Seems to fix the issue, but let me know if there's a more preferred solution!

@jakebixbyavalara jakebixbyavalara changed the title Add failing test for typeIn helper waiting for settled promises The typeIn helper should not wait for settled promises between inputs Sep 13, 2019
Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @jakebixbyavalara! I've pushed a commit that tweaks the fix a bit (avoids requiring us to add an additional boolean argument to the main triggerKeyEvent function). Please take a look when you have a chance...

@jakebixbyavalara
Copy link
Contributor Author

@rwjblue That works for me, I appreciate the refactor!

@jakebixbyavalara
Copy link
Contributor Author

@rwjblue just wanted to check in, did you need me to do any additional work on this PR?

jakebixbyavalara and others added 3 commits October 25, 2019 12:14
Moves the bulk of the actual event firing logic of `triggerKeyEvent`
into a separate function that can be used by our other helper functions
(e.g. `typeIn`) without incorporating `await settled()` directly.

Does **not** change the fundamental mechanism that makes `typeIn` work,
but does ensure that we do not wait for all settledness checks to fire
before continueing to fire typing events.
@rwjblue rwjblue force-pushed the typeIn-settled-issue branch from 710f1b8 to 1c365f3 Compare October 25, 2019 19:15
@rwjblue
Copy link
Member

rwjblue commented Oct 25, 2019

We had an issue with Node 6 that we just resolved. I just rebased on top of those fixes, and I think that CI should be happy now...

Assuming it is, we can land and release.

@rwjblue rwjblue merged commit d60115f into emberjs:master Oct 25, 2019
@rwjblue rwjblue added the bug label Oct 25, 2019
@rwjblue rwjblue changed the title The typeIn helper should not wait for settled promises between inputs Ensure typeIn does not await settled() after each event Oct 25, 2019
@jakebixbyavalara jakebixbyavalara deleted the typeIn-settled-issue branch October 29, 2019 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants