[FW][FIX] web: tests: fix randomly failing load state tests #162975
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit, several qunit load state tests sometimes failed. They all follow the same pattern:
However, waiting for 2 ticks isn't enough. Indeed, when the url hash is set, our mock location object dispatches a "real" hashchange event on window, but it does it after a setTimeout [1]. Then, the webclient is notified (via the router service) of the url change, and reacts by loading the appropriate action. This then requires 2 ticks, because we first clear the DOM with the BlankComponent, and then we mount the requested action/view.
This commit makes those tests more robust by waiting for a setTimeout before the 2 nextTicks.
[1]
odoo/addons/web/static/tests/setup.js
Line 52 in 1882d8f
Runbot issue~37030
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: #162939