From 0ce0f510431254ab3f219e0063eaeadc602ed558 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 20 Oct 2022 12:27:08 +0000 Subject: [PATCH] [IMP] web: clickbot: test all views in studio This commit adds a step in the click all test: for each view, enter and leave Studio, to ensure that the view doesn't crash in Studio. With the migration of views to owl, a lot of views worked fine, but crashed when entering Studio. Those issues have been solved now, and we want to ensure that this no longer happens in the future. closes odoo/odoo#107992 X-original-commit: d18310bddf0a4f741a6335e5499ab213fb046993 Related: odoo/enterprise#35054 Signed-off-by: Lucas Perais (lpe) Signed-off-by: Aaron Bohy (aab) --- .../static/src/webclient/clickbot/clickbot.js | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/webclient/clickbot/clickbot.js b/addons/web/static/src/webclient/clickbot/clickbot.js index f5d9695432d..9b08a11d677 100644 --- a/addons/web/static/src/webclient/clickbot/clickbot.js +++ b/addons/web/static/src/webclient/clickbot/clickbot.js @@ -21,8 +21,10 @@ const { isEnterprise } = odoo.info; const { onWillStart } = owl; let appsMenusOnly = false; + const isStudioInstalled = "@web_studio/studio_service" in odoo.__DEBUG__.services; let actionCount = 0; let viewUpdateCount = 0; + let studioCount = 0; let appIndex; let menuIndex; @@ -247,6 +249,26 @@ return app; } + /** + * Test Studio + * Click on the Studio systray item to enter Studio, and simply leave it once loaded. + */ + async function testStudio() { + if (!isStudioInstalled) { + return; + } + const studioIcon = document.querySelector(".o_web_studio_navbar_item:not(.o_disabled) a i"); + if (!studioIcon) { + return; + } + // Open the filter menu dropdown + await triggerClick(studioIcon, "entering studio"); + await waitForCondition(() => document.querySelector(".o_in_studio")); + await triggerClick(document.querySelector(".o_web_studio_leave"), "leaving studio"); + await waitForCondition(() => document.querySelector(".o_main_navbar:not(.o_studio_navbar) .o_menu_toggle")); + studioCount++; + } + /** * Test filters * Click on each filter in the control pannel @@ -329,6 +351,7 @@ await waitForCondition(() => { return document.querySelector(`.o_switch_view.o_${viewType}.active`) !== null; }); + await testStudio(); await testFilters(); } } @@ -367,6 +390,11 @@ } return startActionCount !== actionCount; }) + .then(() => { + if (!isModal) { + return testStudio(); + } + }) .then(() => { if (!isModal) { return testFilters(); @@ -444,12 +472,15 @@ } } - console.log("Test took", (performance.now() - startTime) / 1000, "seconds"); - console.log("Successfully tested", testedApps.length, " apps"); - console.log("Successfully tested", testedMenus.length - testedApps.length, "menus"); + console.log(`Test took ${(performance.now() - startTime) / 1000} seconds`); + console.log(`Successfully tested ${testedApps.length} apps`); + console.log(`Successfully tested ${testedMenus.length - testedApps.length} menus`); + if (isStudioInstalled) { + console.log(`Successfully tested ${studioCount} views in Studio`); + } console.log("test successful"); } catch (err) { - console.log("Test took", (performance.now() - startTime) / 1000, "seconds"); + console.log(`Test took ${(performance.now() - startTime) / 1000} seconds`); console.error(err || "test failed"); } console.log(testedApps);