[FIX] web: attempt to fix non deterministic issue in tests

This commit *could* prevent a test from failing randomly. The
important part in the diff is the switch from $.Deferred to native
Promise. JQuery Deferred behave differently upon resolution (it is
sync if the deferred is resolved directly, whereas it is not the
case for native Promise). I couldn't find any other reason to
explain why the test was sometimes failing. There is no reason to
use Deferred anyway.

The issue didn't occur after this commit in more than 600 builds.

[1] https://runbot.odoo.com/web#id=2297&action=573&model=runbot.build.error&view_type=form&cids=1&menu_id=405

X-original-commit: ed0761dce44bd37cdd9d40ddd6e021517f466f97
Part-of: odoo/odoo#78698
This commit is contained in:
Aaron Bohy
2021-10-20 15:15:23 +00:00
parent b6ef017f64
commit 0c8b5c5da8
@@ -1895,9 +1895,9 @@ QUnit.module('Views', {
willStart: function () {
assert.step('load '+rpcCount);
if (rpcCount === 2) {
return $.Deferred();
return new Promise(() => {});
}
return $.Deferred().resolve();
return Promise.resolve();
},
}));
@@ -1924,7 +1924,7 @@ QUnit.module('Views', {
});
assert.verifySteps(['load 1']);
await testUtils.mock.intercept(form, 'execute_action', function (ev) {
testUtils.mock.intercept(form, 'execute_action', function (ev) {
ev.data.on_success();
ev.data.on_closed();
});
@@ -1932,11 +1932,6 @@ QUnit.module('Views', {
await testUtils.dom.click('.o_form_statusbar button.p', form);
assert.verifySteps(['load 2']);
testUtils.mock.intercept(form, 'execute_action', function (ev) {
ev.data.on_success();
ev.data.on_closed();
});
await testUtils.dom.click('.o_form_statusbar button.p', form);
assert.verifySteps(['load 3']);