Files
odoo_source/addons/website/static/tests/tours/edit_megamenu.js
T
Younn Olivier aa1134ac05 [FIX] website: fix mega menu items text edition
When inserting a new paragraph by pressing 'enter', it would
automatically close the mega menu.

As inserting a new paragraph triggers a historyRevert at the editor
level, it was leading to two issues:
- The widgets of the public root were stopped then restarted. The
StandardAffixedHeader (the public widget for the header), as an
Animation, would start its effects when started, which would close its
dropdowns. This commit changes the _updateHeaderOnScroll method to close
opened menus and dropdowns only when the animation has scrolled.
- Opening the dropdown was a recorded step. When history was reverted,
it would close it. Now toggling the mega menu is done with the editor
observer unactive.

task-2668908

closes odoo/odoo#81559

X-original-commit: 675430d53f6ef048b77afe95395bd760d3f5a2be
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-12-17 09:18:15 +00:00

83 lines
2.6 KiB
JavaScript

odoo.define("website.tour.edit_megamenu", function (require) {
"use strict";
const tour = require('web_tour.tour');
const wTourUtils = require('website.tour_utils');
const toggleMegaMenu = (stepOptions) => Object.assign({}, {
content: "Toggles the mega menu.",
trigger: '#top_menu .nav-item a.o_mega_menu_toggle',
run: function () {
// If the mega menu is displayed inside the extra menu items, it should
// already be displayed.
if (!this.$anchor[0].closest('.o_extra_menu_items')) {
this.$anchor.click();
}
},
}, stepOptions);
tour.register('edit_megamenu', {
test: true,
url: '/?enable_editor=1',
}, [
// Add a megamenu item to the top menu.
{
content: "Click on a menu item",
trigger: '#top_menu .nav-item a',
},
{
content: "Click on 'Link' to open Link Dialog",
trigger: '.o_edit_menu_popover a.js_edit_menu',
},
{
content: "Trigger the link dialog (click 'Add Mega Menu Item')",
extra_trigger: '.o_web_editor_dialog:visible',
trigger: '.modal-body a.js_add_menu[data-type="mega"]',
},
{
content: "Write a label for the new menu item",
extra_trigger: '.o_link_dialog',
trigger: '.o_link_dialog #o_link_dialog_label_input',
run: 'text Megaaaaa!'
},
{
content: "Save the new menu item",
trigger: '.modal-dialog .btn-primary span:contains("Save")',
run: 'click',
},
{
content: "Save the changes to the menu",
trigger: '.modal-dialog .btn-primary span:contains("Save")',
run: 'click',
},
// Edit a menu item
wTourUtils.clickOnEdit(),
wTourUtils.clickOnExtraMenuItem({extra_trigger: '#oe_snippets.o_loaded'}),
toggleMegaMenu({extra_trigger: '#top_menu .nav-item a.o_mega_menu_toggle:contains("Megaaaaa!")'}),
{
content: "Clicks on the first title item.",
trigger: '.o_mega_menu h4',
},
{
content: "Press enter.",
trigger: '.o_mega_menu h4',
run: function (actions) {
this.$anchor[0].dispatchEvent(new window.InputEvent('input', {bubbles: true, inputType: 'insertParagraph'}));
},
},
{
content: "The menu should still be visible. Edit a menu item.",
trigger: '.o_mega_menu h4',
run: 'text New Menu Item',
},
...wTourUtils.clickOnSave(),
wTourUtils.clickOnExtraMenuItem({extra_trigger: 'a[data-action=edit]'}),
toggleMegaMenu(),
{
content: "The menu item should have been renamed.",
trigger: '.o_mega_menu h4:contains("New Menu Item")',
run: function () {}, // it's a check
},
]);
});