diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-03-18 14:14:41 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2020-03-18 14:51:36 +0000 |
| commit | 9cf534f577c9c454c2055ac12e853188a5985c25 (patch) | |
| tree | 05bb5c8d1777813e79e4f6d7b8f748bd9e963ff5 /addons/web/static/tests/helpers/test_utils_mock.js | |
| parent | c9ce8a07e1d4f7253e4a889d659092d26477b8b6 (diff) | |
[REF] web: properly wait for services to start
When using a mock environment, some services are started and need to be loaded
for some tests to work as intended. Before this commit, we waited for the result
of the `start` method of each service to be resolved. This was flawed because these
methods are all synchronous, so the awaiting period was actually a single microtask
tick.
To clarify this and still make sure that the asynchronous services have enough time
to load properly, the `Promise.all` has been replaced by an Owl next tick method
(with animation frame request).
Consistently waiting for services to be fully ready does not make sense anyway as
we may want to mock a delay during the starting mechanism.
closes odoo/odoo#47865
Related: odoo/enterprise#9328
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils_mock.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_mock.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_mock.js b/addons/web/static/tests/helpers/test_utils_mock.js index 45b5dd6abcf..9e87c4e76da 100644 --- a/addons/web/static/tests/helpers/test_utils_mock.js +++ b/addons/web/static/tests/helpers/test_utils_mock.js @@ -315,7 +315,6 @@ async function addMockEnvironment(widget, params) { // Deploy services var done = false; var servicesToDeploy = _.clone(params.services); - const servicePromises = []; if (!servicesToDeploy.ajax) { services.ajax = null; // use mocked ajax from mocked server } @@ -333,7 +332,7 @@ async function addMockEnvironment(widget, params) { intercept(service, "get_session", function (event) { event.data.callback(session); }); - servicePromises.push(service.start()); + service.start(); } else { var serviceNames = _.keys(servicesToDeploy); if (serviceNames.length) { @@ -343,7 +342,8 @@ async function addMockEnvironment(widget, params) { } } - await Promise.all(servicePromises); + // Wait for asynchronous services to properly start + await new Promise(setTimeout); return mockServer; } |
