Skip to content

Commit 60d7d15

Browse files
committed
[IMP] website: adapt megamenu_active_nav_link tour
`megamenu_active_nav_link` tour was broken and disabled after the new website builder changes. This commit adapts the tour steps accordingly and re-enables the related test.
1 parent 4f3867f commit 60d7d15

File tree

3 files changed

+35
-40
lines changed

3 files changed

+35
-40
lines changed

addons/website/static/src/js/tours/tour_utils.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,29 @@ export function toggleMobilePreview(toggleOn) {
638638
},
639639
];
640640
}
641+
642+
/**
643+
* Opens the link popup for the specified link element.
644+
*
645+
* @param {string} triggerSelector - Selector for the link element.
646+
* @param {string} [linkName=""] - Name of the link.
647+
* @returns {TourStep[]} The tour steps that opens the link popup.
648+
*/
649+
export function openLinkPopup(triggerSelector, linkName = "") {
650+
return [
651+
{
652+
content: `Open '${linkName}' link popup`,
653+
trigger: triggerSelector,
654+
async run() {
655+
const el = this.anchor;
656+
const sel = el.ownerDocument.getSelection();
657+
sel.collapse(el.childNodes[0], 1);
658+
el.focus();
659+
}
660+
},
661+
{
662+
content: "Check if the link popover opened",
663+
trigger: ".o-we-linkpopover"
664+
}
665+
];
666+
}

addons/website/static/tests/tours/edit_megamenu.js

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2-
changeOption,
32
clickOnExtraMenuItem,
43
clickOnSave,
4+
openLinkPopup,
55
registerWebsitePreviewTour,
66
} from "@website/js/tours/tour_utils";
77

@@ -123,14 +123,10 @@ registerWebsitePreviewTour("megamenu_active_nav_link", {
123123
edition: true,
124124
}, () => [
125125
// Add a megamenu item to the top menu.
126-
{
127-
content: "Click on a menu item",
128-
trigger: ":iframe .top_menu .nav-item a",
129-
run: "click",
130-
},
126+
...openLinkPopup(":iframe .top_menu .nav-item a:contains('Home')", "Home"),
131127
{
132128
content: "Click on 'Link' to open Link Dialog",
133-
trigger: ":iframe .o_edit_menu_popover a.js_edit_menu",
129+
trigger: ".o-we-linkpopover a.js_edit_menu",
134130
run: "click",
135131
},
136132
{
@@ -160,49 +156,23 @@ registerWebsitePreviewTour("megamenu_active_nav_link", {
160156
run: "click",
161157
},
162158
{
163-
trigger: "#oe_snippets.o_loaded",
159+
trigger: "body:not(:has(.modal))",
164160
},
165161
{
166162
content: "Check for the new mega menu",
167163
trigger: `:iframe .top_menu:has(.nav-item a.o_mega_menu_toggle:contains("Megatron"))`,
168164
},
169-
{
170-
trigger: ".o_website_preview.editor_enable.editor_has_snippets:not(.o_is_blocked)"
171-
},
172165
clickOnExtraMenuItem({}, true),
173166
toggleMegaMenu({}),
167+
...openLinkPopup(":iframe .s_mega_menu_odoo_menu .nav-link:contains('Laptops')", "Laptops"),
174168
{
175-
content: "Select the first menu link of the first column",
176-
trigger: ":iframe .s_mega_menu_odoo_menu .row > div:first-child .nav a",
177-
async run(actions) {
178-
await actions.click();
179-
const iframeDocument = document.querySelector('.o_iframe').contentDocument;
180-
const range = iframeDocument.createRange();
181-
range.selectNodeContents(this.anchor);
182-
const sel = iframeDocument.getSelection();
183-
sel.removeAllRanges();
184-
sel.addRange(range);
185-
},
186-
},
187-
{
188-
content: "Click 'edit link' button if URL input is now shown",
189-
trigger: "#create-link",
190-
async run(actions) {
191-
// Note: the 'create-link' button is always here, however the input
192-
// for the URL might not be.
193-
// We have to consider both cases:
194-
// 1. Single-app website build: a few menu, so no extra menu added
195-
// and the URL input is shown
196-
// 2. Multi-app website build: many menu, so extra menu added
197-
// and the URL input is not shown
198-
if (!document.querySelector("#o_link_dialog_url_input")) {
199-
await actions.click();
200-
}
201-
},
169+
content: "Click on 'Edit Link'",
170+
trigger: ".o-we-linkpopover a.o_we_edit_link",
171+
run: "click",
202172
},
203173
{
204174
content: "Change the link",
205-
trigger: "#o_link_dialog_url_input",
175+
trigger: ".o-we-linkpopover input.o_we_href_input_link",
206176
run: "edit /new_page"
207177
},
208178
...clickOnSave(),

addons/website/tests/test_ui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ def test_15_website_link_tools(self):
512512
def test_16_website_edit_megamenu(self):
513513
self.start_tour(self.env['website'].get_client_action_url('/'), 'edit_megamenu', login='admin')
514514

515-
@unittest.skip
516515
def test_website_megamenu_active_nav_link(self):
517516
self.start_tour(self.env['website'].get_client_action_url('/'), 'megamenu_active_nav_link', login='admin')
518517

0 commit comments

Comments
 (0)