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

Back ported the timer util that returns a scaled down timer value in test environments #1145

Open
wants to merge 5 commits into
base: release-6x
Choose a base branch
from

Conversation

tgvrssanthosh
Copy link
Contributor

Summary

Created timer util that returns a scaled-down timer value in the test environments.

Details

ember-lifeline methods such as runTask, debounceTask defer execution of the callback function passed to them by the amount of timer value that is passed to these functions. Under the hood, It uses ember runloop's methods which in turn will be delegated to backburner.

Since these tasks are delegated to the backburner, they fall under ember-aware async constructs. Due to this, the async ember test util settled (click, render etc., internally uses the settled method) will wait for all the pending async timer functions to be completed and then the test execution flow will proceed to the next line.

Let's say we are debouncing the task of making a request to API to fetch the typeahead results by 300ms. It means that the test will wait for at least 300ms to make an API call (which can be mocked using pretender or ember-cli-mirage). Ideally, in test environments, there is no need to wait as the necessary input will be added programmatically as opposed to the user typing manually (in which case it makes sense to defer by 300ms owing to the typing speed of a user)

Hence, I have added a util method to return a scaled-down version of the timer in the test environments. By default, it will scale down the timer value by 100x. If a second argument is passed, the second value will be returned in the test environment.

},
"resolutions": {
"favicons": "5.3.0"
},
"engines": {
"node": ">= 10.*"
"node": "12.* || 14.* || >= 16"
Copy link
Member

Choose a reason for hiding this comment

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

We can't make this change in the v6 branch. Changing node engines is a breaking change, and as such it's not possible to do.

"ember-cli": "~3.21.2",
"ember-cli-addon-docs": "^0.8.0",
"ember-cli-addon-docs": "^4.2.2",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should be bumping addon-docs all the way up to this version. I'd prefer we do minimal changes in this release branch, and defer changes to the master branch.

@elwayman02
Copy link
Contributor

@tgvrssanthosh can you update this PR according to the review feedback, to avoid introducing breaking changes?

@elwayman02
Copy link
Contributor

Please rebase now that #1149 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants