From fc3e1b2df556e06d385b6e7b6af2a5765ff74e69 Mon Sep 17 00:00:00 2001 From: "Mehdi Outagant (MOU)" Date: Tue, 27 Feb 2024 13:48:49 +0100 Subject: [PATCH] [FIX] website: fix the extra menu editing test Starting from The "unbreakable menu fix" on `16.0` (see: [1]), the state of the website extra menu was stored before every "resize" adaptation, so it can be possible to reopen it if it was already opened. On `17.0`, the same behaviour was fixed using the `odooEditor` > `withoutRollback()` mechanism (see: [2]), and a step was added to the `edit_menus` test (`clickOnExtraMenuItem`) to open the extra menu after the "edit mode resize" [3]. The forward port of [1], on `17.0` was adapted to keep the main fix from [2], and removed the tour step since the extra menu will be automatically opened if it was already open before the "resize". Now, if we have a menu with no overflowing items before the resize, and after switching to "edit" mode an extra menu was added, this menu will be closed by default which makes the test fail without the step in [3]. The goal of this commit is to fix this behaviour by simply restoring the `clickOnExtraMenuItem` step with a simple tweak: We don't click if the extra menu is already opened to prevent closing it again. Remark: the test failed on `17.0` but the commit is targeting `16.0` to prevent any test failure linked to the "extra menu auto open" feature. [1]: https://github.com/odoo/odoo/commit/2598cc9ef7fe89a0ce5e375bca6f6a781f6ffdf7 [2]: https://github.com/odoo/odoo/commit/cbed990924887eb529056d89a042a92ba27b825b Related to opw-3484742 Related to task-3439226 closes odoo/odoo#157290 X-original-commit: 42bcc3ef284ca355e2323641176573b53e7d2e28 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Outagant Mehdi (mou) --- addons/website/static/src/js/tours/tour_utils.js | 3 ++- addons/website/static/tests/tours/edit_menus.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/js/tours/tour_utils.js b/addons/website/static/src/js/tours/tour_utils.js index 804cad5f254..16f93a6d392 100644 --- a/addons/website/static/src/js/tours/tour_utils.js +++ b/addons/website/static/src/js/tours/tour_utils.js @@ -331,7 +331,8 @@ function clickOnExtraMenuItem(stepOptions, backend = false) { trigger: `${backend ? "iframe" : ""} .top_menu`, run: function () { const extraMenuButton = this.$anchor[0].querySelector('.o_extra_menu_items a.nav-link'); - if (extraMenuButton) { + // Don't click on the extra menu button if it's already visible. + if (extraMenuButton && !extraMenuButton.classList.contains("show")) { extraMenuButton.click(); } }, diff --git a/addons/website/static/tests/tours/edit_menus.js b/addons/website/static/tests/tours/edit_menus.js index 49d5a72be56..60d69585267 100644 --- a/addons/website/static/tests/tours/edit_menus.js +++ b/addons/website/static/tests/tours/edit_menus.js @@ -116,6 +116,7 @@ wTourUtils.registerWebsitePreviewTour('edit_menus', { }, // Edit the menu item from the "edit menu" popover button ...wTourUtils.clickOnEditAndWaitEditMode(), + wTourUtils.clickOnExtraMenuItem({}, true), { content: "Click on the 'Modnar' link", trigger: 'iframe .top_menu .nav-item a:contains("Modnar")',