From 1c1dcdb676d3d4759b80be0dbc78bf26672741b7 Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Wed, 22 Mar 2023 20:31:53 +0000 Subject: [PATCH] [FIX] web: properties test very slow In tests, if we need to interact with dropdowns, we should patch setTimout so that we don't have to wait x ms for the dropdown to open. closes odoo/odoo#116319 X-original-commit: 008d4faebabbecb88d4ce514650b59cdc21ff85a Signed-off-by: Aaron Bohy (aab) --- .../tests/views/fields/properties_field_tests.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/addons/web/static/tests/views/fields/properties_field_tests.js b/addons/web/static/tests/views/fields/properties_field_tests.js index 187efc33c3e..bb750c88cba 100644 --- a/addons/web/static/tests/views/fields/properties_field_tests.js +++ b/addons/web/static/tests/views/fields/properties_field_tests.js @@ -7,9 +7,11 @@ import { editInput, getFixture, nextTick, + patchWithCleanup, triggerEvent, } from "@web/../tests/helpers/utils"; import { makeView, setupViewRegistries } from "@web/../tests/views/helpers"; +import { browser } from "@web/core/browser/browser"; let serverData; let target; @@ -218,6 +220,10 @@ QUnit.module("Fields", (hooks) => { }; setupViewRegistries(); + + patchWithCleanup(browser, { + setTimeout: (fn) => fn(), + }); }); QUnit.module("PropertiesField"); @@ -729,10 +735,6 @@ QUnit.module("Fields", (hooks) => { const createNewTag = async (selector, text) => { await click(target, selector); await editInput(target, selector, text); - for (let i = 0; i < 50; ++i) { - // Wait until the dropdown appears - await nextTick(); - } await triggerEvent(target, selector, "keydown", { key: "Enter" }); await nextTick(); }; @@ -898,9 +900,6 @@ QUnit.module("Fields", (hooks) => { // Quick create a user await click(target, ".o_property_field:nth-child(2) .o_property_field_value input"); await editInput(target, ".o_property_field:nth-child(2) input", "New User"); - for (let i = 0; i < 50; ++i) { - await nextTick(); - } // wait until the dropdown appears await click(target, ".o_property_field:nth-child(2) .o_m2o_dropdown_option_create"); selectedUser = target.querySelector( ".o_property_field:nth-child(2) .o_property_field_value input" @@ -997,9 +996,6 @@ QUnit.module("Fields", (hooks) => { // Quick create a user await click(target, ".o_property_field:nth-child(2) .o_property_field_value input"); await editInput(target, ".o_property_field:nth-child(2) input", "New User"); - for (let i = 0; i < 50; ++i) { - await nextTick(); - } // wait until the dropdown appears await click(target, ".o_property_field:nth-child(2) .o_m2o_dropdown_option_create"); assert.deepEqual( getSelectedUsers(),