From 5b7151e0efc30a8d2016b612f8e4be87b57728b8 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Wed, 14 Jul 2021 16:33:04 +0000 Subject: [PATCH] [FIX] web_editor: wait editor loading in tests In a undeterministic circumnstance, the editor has not enough time to be loaded after `testUtils.nextTick()`. By using a 100ms timeout instead, it will give more time for the editor to be loaded and therfore reduce the risk of a false negative to appear. closes odoo/odoo#76980 X-original-commit: 190ddf08b8bb6c4750f1d0ad1c57f19b936794de Signed-off-by: Christophe Monniez (moc) --- .../web_editor/static/tests/field_html_tests.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/web_editor/static/tests/field_html_tests.js b/addons/web_editor/static/tests/field_html_tests.js index a0ce398aab0..0fe39069baa 100644 --- a/addons/web_editor/static/tests/field_html_tests.js +++ b/addons/web_editor/static/tests/field_html_tests.js @@ -168,7 +168,7 @@ QUnit.module('web_editor', {}, function () { "should have applied the style correctly"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); assert.strictEqual($field.find('.note-editable').html(), '

toto toto toto

tata

', @@ -191,7 +191,7 @@ QUnit.module('web_editor', {}, function () { }); // check that there is no error on clicking Edit await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); assert.containsOnce(form, '.o_form_editable'); form.destroy(); @@ -222,7 +222,7 @@ QUnit.module('web_editor', {}, function () { }, true); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); await testUtils.dom.click(form.$('.o_form_button_save')); form.destroy(); @@ -440,7 +440,7 @@ QUnit.module('web_editor', {}, function () { "should have rendered a div with correct content in readonly"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); // the dialog load some xml assets const defLinkDialog = testUtils.makeTestPromise(); @@ -488,7 +488,7 @@ QUnit.module('web_editor', {}, function () { "should have rendered a div with correct content in readonly"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); // the dialog load some xml assets const defLinkDialog = testUtils.makeTestPromise(); @@ -536,7 +536,7 @@ QUnit.module('web_editor', {}, function () { "should have rendered a div with correct content in readonly"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); // the dialog load some xml assets const defLinkDialog = testUtils.makeTestPromise(); @@ -585,7 +585,7 @@ QUnit.module('web_editor', {}, function () { "should have rendered a div with correct content in readonly"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); // the dialog load some xml assets const defLinkDialog = testUtils.makeTestPromise(); @@ -615,7 +615,7 @@ QUnit.module('web_editor', {}, function () { "the link should be created with the right format"); await testUtils.form.clickEdit(form); - await testUtils.nextTick(); + await new Promise((resolve)=>setTimeout(resolve, 100)); $field = form.$('.oe_form_field[name="body"]'); pText = $field.find('.note-editable a').eq(0).contents()[0];