From e6eac65e4a49627e8949913b314343ddeb20bfeb Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 24 Sep 2020 14:48:08 +0000 Subject: [PATCH] [FIX] web: skip map views and increase timeout in click_all MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the click_everywhere test, the map views are tested but leads to random failures when the view takes too long to load. Moreover, the map resources are queried on external nominatim.org servers. This could lead in the test runner being black-listed by nominatim and more indeterminism as those servers are not under our control. For those reasons, this commit will skip the map views in the click_everywhere test. Also, the general time limit is increased. Five seconds was sometimes too short, depending on external conditions (e.g.: server load or screencast enabled). Finally, on a database with all apps installed, the `Settings` menu of some apps loads the full settings and it can takes a huge amount of time to load on a clean browser (as in the tests). For that reason, the time limit for the test of those menus was also increased. closes odoo/odoo#58750 X-original-commit: 2f3ea94a46fde9870db6b6b1d6a4233aaff805ce Signed-off-by: Xavier Dollé (xdo) Signed-off-by: Christophe Monniez (moc) --- addons/web/static/src/js/tools/test_menus.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/tools/test_menus.js b/addons/web/static/src/js/tools/test_menus.js index e340b79fd67..d555f644310 100644 --- a/addons/web/static/src/js/tools/test_menus.js +++ b/addons/web/static/src/js/tools/test_menus.js @@ -126,9 +126,11 @@ async function testMenuItem(element){ if (testedMenus.indexOf(element.dataset.menuXmlid) >= 0) return Promise.resolve(); // Avoid infinite loop var menuDescription = element.innerText.trim() + " " + element.dataset.menuXmlid; + var menuTimeLimit = 10000; console.log("Testing menu", menuDescription); testedMenus.push(element.dataset.menuXmlid); if (blackListedMenus.includes(element.dataset.menuXmlid)) return Promise.resolve(); // Skip black listed menus + if (element.innerText.trim() == 'Settings') menuTimeLimit = 20000; var startActionCount = clientActionCount; await triggerClick(element, `menu item "${element.innerText.trim()}"`); var isModal = false; @@ -145,7 +147,7 @@ return true; } return startActionCount !== clientActionCount; - }).then(function() { + }, menuTimeLimit).then(function() { if (!isModal) { return testFilters(); } @@ -170,7 +172,7 @@ if (appsMenusOnly === true) { return; } - const switchButtons = document.querySelectorAll('nav.o_cp_switch_buttons > button:not(.active)'); + const switchButtons = document.querySelectorAll('nav.o_cp_switch_buttons > button.o_switch_view:not(.active):not(.o_map)'); for (const switchButton of switchButtons) { // Only way to get the viewType from the switchButton const viewType = [...switchButton.classList] @@ -228,10 +230,10 @@ * @param {function} stopCondition a function that returns a boolean * @returns {Promise} that is rejected if the timeout is exceeded */ - function waitForCondition(stopCondition) { + function waitForCondition(stopCondition, tl=10000) { var prom = new Promise(function (resolve, reject) { var interval = 250; - var timeLimit = 5000; + var timeLimit = tl; function checkCondition() { if (stopCondition()) { @@ -242,7 +244,7 @@ // recursive call until the resolve or the timeout setTimeout(checkCondition, interval); } else { - console.error('Timeout, the clicked element took more than 5 seconds to load'); + console.error('Timeout, the clicked element took more than', tl/1000,'seconds to load'); reject(); } }