From 83b81cc44d135852ff2ccaeea600edb12c2c68d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Tue, 15 Dec 2020 13:23:15 +0000 Subject: [PATCH] [FIX] web_editor: fix non-deterministic error in QUnit wysiwyg tests Another try at fixing the non-deterministic error in the `field_html_test > save` QUnit test which use the JW wysiwyg editor. closes odoo/odoo#63409 X-original-commit: e3ff253e433397b05a809f1267083475b53c7fb5 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/tests/field_html_tests.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/tests/field_html_tests.js b/addons/web_editor/static/tests/field_html_tests.js index ac0b8d3a695..ebb54a47f53 100644 --- a/addons/web_editor/static/tests/field_html_tests.js +++ b/addons/web_editor/static/tests/field_html_tests.js @@ -271,14 +271,14 @@ QUnit.module('web_editor', {}, function () { '' + '', res_id: 1, - mockRPC: function (route, args) { + mockRPC: async function (route, args) { if (args.method === "write") { assert.strictEqual(args.args[1].body, '

toto toto toto

tata

', "should save the content"); } - return this._super.apply(this, arguments); + return await this._super.apply(this, arguments); }, }); await testUtils.form.clickEdit(form); @@ -297,7 +297,12 @@ QUnit.module('web_editor', {}, function () { } await testUtils.nextTick(); + // Fake an editor command to force the QUnit test scenario to wait + // until all the mutex are processed in the JW editor await new Promise((resolve) => wysiwyg.execCommand(resolve)); + // Add a small delay to ensure the FollowRange menu is available in the DOM + // before the openColorPicker() method will try to click on a buton inside the menu + await new Promise(resolve => setTimeout(resolve, 100)); await openColorpicker(); await testUtils.nextTick(); @@ -308,8 +313,9 @@ QUnit.module('web_editor', {}, function () { await new Promise((resolve) => wysiwyg.execCommand(resolve)); await testUtils.form.clickSave(form); - await wysiwyg.isEditorStoppedPromise; + await testUtils.nextTick(); form.destroy(); + await wysiwyg.isEditorStoppedPromise; }); QUnit.test('media dialog: image', async function (assert) { assert.expect(1);