Skip to content

[IMP] *: adapt tests for mysterious egg #4590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master-mysterious-egg
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion addons/html_editor/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ def link_preview_metadata_internal(self, preview_url):
context = dict(request.env.context)
words = preview_url.strip('/').split('/')

record_id = int(words.pop())
try:
record_id = int(words.pop())
except ValueError:
return {}
action_name = words.pop()
if (action_name.startswith('m-') or '.' in action_name) and action_name in request.env and not request.env[action_name]._abstract:
# if path format is `odoo/<model>/<record_id>` so we use `action_name` as model name
Expand Down
26 changes: 26 additions & 0 deletions addons/website/static/src/js/tours/tour_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,29 @@ export function toggleMobilePreview(toggleOn) {
},
];
}

/**
* Opens the link popup for the specified link element.
*
* @param {string} triggerSelector - Selector for the link element.
* @param {string} [linkName=""] - Name of the link.
* @returns {TourStep[]} The tour steps that opens the link popup.
*/
export function openLinkPopup(triggerSelector, linkName = "") {
return [
{
content: `Open '${linkName}' link popup`,
trigger: triggerSelector,
async run() {
const el = this.anchor;
const sel = el.ownerDocument.getSelection();
sel.collapse(el.childNodes[0], 1);
el.focus();
}
},
{
content: "Check if the link popover opened",
trigger: ".o-we-linkpopover"
}
];
}
9 changes: 2 additions & 7 deletions addons/website/static/tests/tours/carousel_content_removal.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,12 @@ registerWebsitePreviewTour("snippet_carousel_autoplay", {
...clickOnSnippet(".carousel .carousel-item.active"),
{
content: "Decrease the interval between slides",
trigger: "we-input[data-attribute-name='bsInterval'] input",
trigger: "div[data-label='Speed'] input",
run: 'edit 3',
},
{
content: "Save the interval between slides",
trigger: "we-input[data-attribute-name='bsInterval']",
run: 'click',
},
{
content: "Enable the autoplay option",
trigger: ".autoplay we-checkbox",
trigger: "div[data-label='Autoplay'] input",
run: 'click',
},
...clickOnSave(),
Expand Down
76 changes: 18 additions & 58 deletions addons/website/static/tests/tours/edit_megamenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
changeOption,
changeOptionInPopover,
clickOnExtraMenuItem,
clickOnSave,
openLinkPopup,
registerWebsitePreviewTour,
} from "@website/js/tours/tour_utils";

Expand Down Expand Up @@ -123,14 +124,10 @@ registerWebsitePreviewTour("megamenu_active_nav_link", {
edition: true,
}, () => [
// Add a megamenu item to the top menu.
{
content: "Click on a menu item",
trigger: ":iframe .top_menu .nav-item a",
run: "click",
},
...openLinkPopup(":iframe .top_menu .nav-item a", "Home"),
{
content: "Click on 'Link' to open Link Dialog",
trigger: ":iframe .o_edit_menu_popover a.js_edit_menu",
trigger: ".o-we-linkpopover a.js_edit_menu",
run: "click",
},
{
Expand Down Expand Up @@ -160,50 +157,24 @@ registerWebsitePreviewTour("megamenu_active_nav_link", {
run: "click",
},
{
trigger: "#oe_snippets.o_loaded",
trigger: "body:not(:has(.modal))",
},
{
content: "Check for the new mega menu",
trigger: `:iframe .top_menu:has(.nav-item a.o_mega_menu_toggle:contains("Megatron"))`,
},
{
trigger: ".o_website_preview.editor_enable.editor_has_snippets:not(.o_is_blocked)"
},
clickOnExtraMenuItem({}, true),
toggleMegaMenu({}),
...openLinkPopup(":iframe .s_mega_menu_odoo_menu .nav-link:contains('Laptops')", "Laptops"),
{
content: "Select the first menu link of the first column",
trigger: ":iframe .s_mega_menu_odoo_menu .row > div:first-child .nav a",
async run(actions) {
await actions.click();
const iframeDocument = document.querySelector('.o_iframe').contentDocument;
const range = iframeDocument.createRange();
range.selectNodeContents(this.anchor);
const sel = iframeDocument.getSelection();
sel.removeAllRanges();
sel.addRange(range);
},
},
{
content: "Click 'edit link' button if URL input is now shown",
trigger: "#create-link",
async run(actions) {
// Note: the 'create-link' button is always here, however the input
// for the URL might not be.
// We have to consider both cases:
// 1. Single-app website build: a few menu, so no extra menu added
// and the URL input is shown
// 2. Multi-app website build: many menu, so extra menu added
// and the URL input is not shown
if (!document.querySelector("#o_link_dialog_url_input")) {
await actions.click();
}
},
content: "Click on 'Edit Link'",
trigger: ".o-we-linkpopover a.o_we_edit_link",
run: "click",
},
{
content: "Change the link",
trigger: "#o_link_dialog_url_input",
run: "edit /new_page"
trigger: ".o-we-linkpopover input.o_we_href_input_link",
run: "edit /new_page",
},
...clickOnSave(),
clickOnExtraMenuItem({}, true),
Expand All @@ -223,14 +194,10 @@ registerWebsitePreviewTour('edit_megamenu_big_icons_subtitles', {
edition: true,
}, () => [
// Add a megamenu item to the top menu.
{
content: "Click on a menu item",
trigger: ':iframe .top_menu .nav-item a',
run: "click",
},
...openLinkPopup(":iframe .top_menu .nav-item a", "Home"),
{
content: "Click on 'Link' to open Link Dialog",
trigger: ':iframe .o_edit_menu_popover a.js_edit_menu',
trigger: ".o-we-linkpopover a.js_edit_menu",
run: "click",
},
{
Expand Down Expand Up @@ -260,15 +227,12 @@ registerWebsitePreviewTour('edit_megamenu_big_icons_subtitles', {
run: "click",
},
{
trigger: '#oe_snippets.o_loaded',
trigger: "body:not(:has(.modal))",
},
{
content: "Check for the new mega menu",
trigger: ':iframe .top_menu:has(.nav-item a.o_mega_menu_toggle:contains("Megaaaaa2!"))',
},
{
trigger: ".o_website_preview.editor_enable.editor_has_snippets:not(.o_is_blocked)"
},
// Edit a menu item
clickOnExtraMenuItem({}, true),
toggleMegaMenu({}),
Expand All @@ -277,18 +241,14 @@ registerWebsitePreviewTour('edit_megamenu_big_icons_subtitles', {
trigger: ':iframe .s_mega_menu_odoo_menu .row > div:first-child .nav > :first-child',
run: "click",
},
changeOption("MegaMenuLayout", "we-toggler"),
{
content: "Select Big Icons Subtitles mega menu",
trigger: '[data-select-label="Big Icons Subtitles"]',
run: "click",
},
// Change MegaMenu template
...changeOptionInPopover("Mega Menu", "Template", "[title='Big Icons Subtitles']"),
{
content: "Select the h4 of first menu link of the first column",
trigger: ':iframe .s_mega_menu_big_icons_subtitles .row > div:first-child .nav > :first-child h4',
async run(actions) {
await actions.click();
const iframeDocument = document.querySelector('.o_iframe').contentDocument;
const iframeDocument = document.querySelector('.o_iframe_container iframe').contentDocument;
const range = iframeDocument.createRange();
range.selectNodeContents(this.anchor);
const sel = iframeDocument.getSelection();
Expand All @@ -298,7 +258,7 @@ registerWebsitePreviewTour('edit_megamenu_big_icons_subtitles', {
},
{
content: "Convert it to Bold",
trigger: '#oe_snippets #toolbar #bold',
trigger: ".o-we-toolbar button[name='bold']",
run: "click",
},
...clickOnSave(),
Expand Down
37 changes: 9 additions & 28 deletions addons/website/static/tests/tours/edit_menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
clickOnEditAndWaitEditMode,
clickOnExtraMenuItem,
clickOnSave,
goBackToBlocks,
insertSnippet,
openLinkPopup,
registerWebsitePreviewTour,
} from '@website/js/tours/tour_utils';

Expand Down Expand Up @@ -55,24 +57,17 @@ registerWebsitePreviewTour('edit_menus', {
{
trigger: "body:not(:has(.oe_menu_editor))",
},
{
trigger: ":iframe body:contains(welcome to your)",
},
clickOnExtraMenuItem({}, true),
{
content: "There should be a new megamenu item.",
trigger: ':iframe .top_menu .nav-item a.o_mega_menu_toggle:contains("Megaaaaa!")',
},
// Add a menu item in edit mode.
...clickOnEditAndWaitEditMode(),
{
content: "Click on a menu item",
trigger: ":iframe .top_menu .nav-item a",
run: "click",
},
...openLinkPopup(":iframe .top_menu .nav-item a:contains('Home')", "Home"),
{
content: "Click on Edit Menu",
trigger: ':iframe .o_edit_menu_popover a.js_edit_menu',
trigger: '.o-we-linkpopover a.js_edit_menu',
run: "click",
},
{
Expand Down Expand Up @@ -127,27 +122,16 @@ registerWebsitePreviewTour('edit_menus', {
{
trigger: "body:not(:has(.modal))",
},
{
trigger: "#oe_snippets.o_loaded",
},
// Edit the new menu item from the "edit link" popover button
clickOnExtraMenuItem({}, true),
{
trigger: ".o_website_preview.editor_enable.editor_has_snippets:not(.o_is_blocked)",
},
{
content: "Menu should have a new link item",
trigger: ':iframe .top_menu .nav-item a:contains("Random!")',
// Don't click the new menu when the editor is still blocked.
run: "click",
},
...openLinkPopup(":iframe .top_menu .nav-item a:contains('Random!')", "Random!"),
{
content: "navbar shouldn't have any zwnbsp and no o_link_in_selection class",
trigger: ':iframe nav.navbar:not(:has(.o_link_in_selection)):not(:contains("\ufeff"))',
},
{
content: "Click on Edit Link",
trigger: ':iframe .o_edit_menu_popover a.o_we_edit_link',
trigger: '.o-we-linkpopover a.o_we_edit_link',
run: "click",
},
{
Expand All @@ -169,14 +153,10 @@ registerWebsitePreviewTour('edit_menus', {
// Edit the menu item from the "edit menu" popover button
...clickOnEditAndWaitEditMode(),
clickOnExtraMenuItem({}, true),
{
content: "Click on the 'Modnar' link",
trigger: ':iframe .top_menu .nav-item a:contains("Modnar")',
run: "click",
},
...openLinkPopup(":iframe .top_menu .nav-item a:contains('Modnar')", "Modnar"),
{
content: "Click on the popover Edit Menu button",
trigger: ':iframe .o_edit_menu_popover a.js_edit_menu',
trigger: '.o-we-linkpopover a.js_edit_menu',
run: "click",
},
{
Expand Down Expand Up @@ -206,6 +186,7 @@ registerWebsitePreviewTour('edit_menus', {
run: "click",
},
// Drag a block to be able to scroll later.
goBackToBlocks(),
...insertSnippet({ id: "s_media_list", name: "Media List", groupName: "Content" }),
...clickOnSave(),
clickOnExtraMenuItem({}, true),
Expand Down
4 changes: 0 additions & 4 deletions addons/website/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,9 @@ def test_15_website_link_tools(self):
def test_16_website_edit_megamenu(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'edit_megamenu', login='admin')

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

@unittest.skip
def test_17_website_edit_menus(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'edit_menus', login='admin')

Expand Down Expand Up @@ -603,7 +601,6 @@ def test_29_website_backend_menus_redirect(self):
def test_30_website_text_animations(self):
self.start_tour("/", 'text_animations', login='admin')

@unittest.skip
def test_31_website_edit_megamenu_big_icons_subtitles(self):
self.start_tour(self.env['website'].get_client_action_url('/'), 'edit_megamenu_big_icons_subtitles', login='admin')

Expand Down Expand Up @@ -773,7 +770,6 @@ def test_website_edit_menus_delete_parent(self):
def test_snippet_carousel(self):
self.start_tour('/', 'snippet_carousel', login='admin')

@unittest.skip
def test_snippet_carousel_autoplay(self):
self.start_tour("/", "snippet_carousel_autoplay", login="admin")

Expand Down
3 changes: 0 additions & 3 deletions addons/website_sale_autocomplete/tests/test_ui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.tests import HttpCase, patch, tagged
import unittest

from odoo.addons.google_address_autocomplete.controllers.google_address_autocomplete import (
AutoCompleteController,
Expand All @@ -24,8 +23,6 @@ def setUpClass(cls):
'list_price': 1
})

# TODO master-mysterious-egg fix error
@unittest.skip("prepare mysterious-egg for merging")
def test_autocomplete(self):
with patch.object(AutoCompleteController, '_perform_complete_place_search',
lambda controller, *args, **kwargs: {
Expand Down
3 changes: 0 additions & 3 deletions addons/website_sale_wishlist/tests/test_wishlist_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

from odoo.fields import Command
from odoo.tests import HttpCase, tagged
import unittest

@tagged('-at_install', 'post_install')
class TestWishlistProcess(HttpCase):

# TODO master-mysterious-egg fix error
@unittest.skip("prepare mysterious-egg for merging")
def test_01_wishlist_tour(self):
self.env['product.template'].search([]).write({'website_published': False})
# Setup attributes and attributes values
Expand Down