diff --git a/addons/test_website/static/tests/tours/custom_snippets.js b/addons/test_website/static/tests/tours/custom_snippets.js index 6dd953164ce..757b89ed6be 100644 --- a/addons/test_website/static/tests/tours/custom_snippets.js +++ b/addons/test_website/static/tests/tours/custom_snippets.js @@ -28,8 +28,7 @@ wTourUtils.registerWebsitePreviewTour('test_custom_snippet', { }, [ { content: "drop a snippet", - trigger: "#oe_snippets.o_loaded .oe_snippet[name='Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)", - extra_trigger: "iframe body.editor_enable", + trigger: ".oe_snippet[name='Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)", moveTrigger: ".oe_drop_zone", run: "drag_and_drop iframe #wrap", }, diff --git a/addons/test_website/static/tests/tours/replace_media.js b/addons/test_website/static/tests/tours/replace_media.js index be21a96fa2f..406e292cbd1 100644 --- a/addons/test_website/static/tests/tours/replace_media.js +++ b/addons/test_website/static/tests/tours/replace_media.js @@ -12,10 +12,10 @@ const VIDEO_URL = 'https://www.youtube.com/watch?v=Dpq87YCHmJc'; wTourUtils.registerWebsitePreviewTour('test_replace_media', { url: '/', test: true, + edition: true, }, [ - wTourUtils.clickOnEdit(), { - trigger: '.editor_enable.editor_has_snippets', + trigger: "body", run: function () { // Patch the VideoDialog so that it does not do external calls // during the test (note that we don't unpatch but as the patch diff --git a/addons/test_website/static/tests/tours/reset_views.js b/addons/test_website/static/tests/tours/reset_views.js index a1ae9ba4def..981d3328d48 100644 --- a/addons/test_website/static/tests/tours/reset_views.js +++ b/addons/test_website/static/tests/tours/reset_views.js @@ -21,7 +21,7 @@ wTourUtils.registerWebsitePreviewTour('test_reset_page_view_complete_flow_part1' [ { content: "drop a snippet", - trigger: "#oe_snippets.o_loaded .oe_snippet:has(.s_cover) .oe_snippet_thumbnail", + trigger: ".oe_snippet:has(.s_cover) .oe_snippet_thumbnail", // id starting by 'oe_structure..' will actually create an inherited view run: "drag_and_drop iframe #oe_structure_test_website_page", }, diff --git a/addons/website/static/src/js/tours/tour_utils.js b/addons/website/static/src/js/tours/tour_utils.js index f309fed103d..20979bbf1c5 100644 --- a/addons/website/static/src/js/tours/tour_utils.js +++ b/addons/website/static/src/js/tours/tour_utils.js @@ -139,20 +139,6 @@ function changePaddingSize(direction) { }; } -/** - * Click on the top right edit button - * @param {*} position Where the purple arrow will show up - */ -function clickOnEdit(position = "bottom") { - return { - trigger: ".o_menu_systray .o_edit_website_container a", - content: Markup(_t("Click Edit to start designing your homepage.")), - extra_trigger: "body:not(.editor_has_snippets)", - position: position, - timeout: 30000, - }; -} - /** * Simple click on an element in the page. * @param {*} elementName @@ -166,6 +152,23 @@ function clickOnElement(elementName, selector) { }; } +/** + * Click on the top right edit button and wait for the edit mode + * + * @param {string} position Where the purple arrow will show up + */ +function clickOnEditAndWaitEditMode(position = "bottom") { + return [{ + content: _t("Click Edit to start designing your homepage."), + trigger: ".o_menu_systray .o_edit_website_container a", + position: position, + }, { + content: "Check that we are in edit mode", + trigger: ".o_website_preview.editor_enable.editor_has_snippets", + run: () => null, // it's a check + }]; +} + /** * Simple click on a snippet in the edition area * @param {*} snippet @@ -403,8 +406,8 @@ export default { changeImage, changeOption, changePaddingSize, - clickOnEdit, clickOnElement, + clickOnEditAndWaitEditMode, clickOnSave, clickOnSnippet, clickOnText, diff --git a/addons/website/static/tests/tours/conditional_visibility.js b/addons/website/static/tests/tours/conditional_visibility.js index 2482039ff2a..12b7bdc4a62 100644 --- a/addons/website/static/tests/tours/conditional_visibility.js +++ b/addons/website/static/tests/tours/conditional_visibility.js @@ -44,10 +44,9 @@ wTourUtils.changeOption('ConditionalVisibility', 'we-toggler'), } }, }, -wTourUtils.clickOnEdit(), +...wTourUtils.clickOnEditAndWaitEditMode(), { content: 'Check if the element is visible as it should always be visible in edit view', - extra_trigger: 'body.editor_has_snippets', trigger: 'iframe #wrap .s_text_image', run: function (actions) { const style = window.getComputedStyle((this.$anchor[0])); diff --git a/addons/website/static/tests/tours/edit_megamenu.js b/addons/website/static/tests/tours/edit_megamenu.js index 889272f6157..9addcbb80c9 100644 --- a/addons/website/static/tests/tours/edit_megamenu.js +++ b/addons/website/static/tests/tours/edit_megamenu.js @@ -22,7 +22,6 @@ wTourUtils.registerWebsitePreviewTour('edit_megamenu', { // Add a megamenu item to the top menu. { content: "Click on a menu item", - extra_trigger: '#oe_snippets.o_loaded', trigger: 'iframe #top_menu .nav-item a', }, { diff --git a/addons/website/static/tests/tours/edit_menus.js b/addons/website/static/tests/tours/edit_menus.js index b7fd682f624..4986649a6e2 100644 --- a/addons/website/static/tests/tours/edit_menus.js +++ b/addons/website/static/tests/tours/edit_menus.js @@ -42,11 +42,10 @@ wTourUtils.registerWebsitePreviewTour('edit_menus', { run: () => {}, // It's a check. }, // Add a menu item in edit mode. - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Click on a menu item", trigger: 'iframe #top_menu .nav-item a', - extra_trigger: '#oe_snippets.o_loaded', }, { content: "Click on Edit Menu", @@ -117,10 +116,9 @@ wTourUtils.registerWebsitePreviewTour('edit_menus', { run: () => {}, // it's a check }, // Edit the menu item from the "edit menu" popover button - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Click on the 'Modnar' link", - extra_trigger: "#oe_snippets.o_loaded", trigger: 'iframe #top_menu .nav-item a:contains("Modnar")', }, { diff --git a/addons/website/static/tests/tours/edit_translated_page.js b/addons/website/static/tests/tours/edit_translated_page.js index 2152b106ce0..dde26b2180a 100644 --- a/addons/website/static/tests/tours/edit_translated_page.js +++ b/addons/website/static/tests/tours/edit_translated_page.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wTourUtils from "website.tour_utils"; registry.category("web_tour.tours").add('edit_translated_page_redirect', { test: true, @@ -11,13 +12,14 @@ registry.category("web_tour.tours").add('edit_translated_page_redirect', { trigger: 'a.o_frontend_to_backend_edit_btn', }, { - content: "Enter edit mode", - extra_trigger: 'iframe main:has([data-for="contactus_form"])', - trigger: '.o_edit_website_container > a', - }, + content: "Check the data-for attribute", + trigger: 'iframe main:has([data-for="contactus_form"])', + run: () => {}, // it's a check + }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { - content: 'check editor dashboard', - trigger: '#oe_snippets.o_loaded', + content: "Go to /nl", + trigger: "body", run: () => { // After checking the presence of the editor dashboard, we visit a // translated version of the homepage. The homepage is a special @@ -29,14 +31,5 @@ registry.category("web_tour.tours").add('edit_translated_page_redirect', { content: "Enter backend", trigger: 'a.o_frontend_to_backend_edit_btn', }, - { - content: "Enter edit mode", - extra_trigger: 'iframe #wrapwrap', - trigger: '.o_edit_website_container > a', - }, - { - content: 'check editor dashboard', - trigger: '#oe_snippets.o_loaded', - run: () => {}, - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), ]}); diff --git a/addons/website/static/tests/tours/focus_blur_snippets.js b/addons/website/static/tests/tours/focus_blur_snippets.js index 108b5169fac..3323cb9c32f 100644 --- a/addons/website/static/tests/tours/focus_blur_snippets.js +++ b/addons/website/static/tests/tours/focus_blur_snippets.js @@ -1,6 +1,6 @@ /** @odoo-module **/ -import { registry } from "@web/core/registry"; +import wTourUtils from 'website.tour_utils'; const blockIDToData = { parent: { @@ -49,10 +49,11 @@ function clickAndCheck(blockID, expected) { window.focusBlurSnippetsResult = []; -registry.category("web_tour.tours").add('focus_blur_snippets', { +wTourUtils.registerWebsitePreviewTour("focus_blur_snippets", { test: true, - url: '/?enable_editor=1', - steps: [ + url: "/", + edition: true, +}, [ { content: 'Drag the custom block into the page', trigger: '#snippet_structure .oe_snippet:has(.oe_snippet_body.s_focusblur) .oe_snippet_thumbnail', @@ -67,4 +68,4 @@ registry.category("web_tour.tours").add('focus_blur_snippets', { ...clickAndCheck('child1', ['blur parent', 'focus parent', 'focus child1']), ...clickAndCheck('child2', ['blur parent', 'blur child1', 'focus parent', 'focus child2']), ...clickAndCheck('parent', ['blur parent', 'blur child2', 'focus parent']), -]}); +]); diff --git a/addons/website/static/tests/tours/gray_color_palette.js b/addons/website/static/tests/tours/gray_color_palette.js index cd0f0901585..a32d2f5fc0a 100644 --- a/addons/website/static/tests/tours/gray_color_palette.js +++ b/addons/website/static/tests/tours/gray_color_palette.js @@ -28,7 +28,6 @@ wTourUtils.registerWebsitePreviewTour('website_gray_color_palette', { { content: "Go to theme options", trigger: '.o_we_customize_theme_btn', - extra_trigger: '#oe_snippets.o_loaded', }, { content: "Toggle gray color palette", diff --git a/addons/website/static/tests/tours/html_editor.js b/addons/website/static/tests/tours/html_editor.js index 5c1fadc6bc1..430c0ce158e 100644 --- a/addons/website/static/tests/tours/html_editor.js +++ b/addons/website/static/tests/tours/html_editor.js @@ -14,7 +14,7 @@ wTourUtils.registerWebsitePreviewTour('html_editor_multiple_templates', { [ { content: "drop a snippet", - trigger: '#oe_snippets.o_loaded .oe_snippet:has(.s_cover) .oe_snippet_thumbnail', + trigger: ".oe_snippet:has(.s_cover) .oe_snippet_thumbnail", // id starting by 'oe_structure..' will actually create an inherited view run: "drag_and_drop iframe #oe_structure_test_ui", }, diff --git a/addons/website/static/tests/tours/link_tools.js b/addons/website/static/tests/tours/link_tools.js index 11500f92969..0b86a8efba5 100644 --- a/addons/website/static/tests/tours/link_tools.js +++ b/addons/website/static/tests/tours/link_tools.js @@ -70,10 +70,9 @@ wTourUtils.registerWebsitePreviewTour('link_tools', { clickOnImgStep, ...wTourUtils.clickOnSave(), // 3. Edit a link after saving the page. - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "The new link content should be odoo website and url odoo.be", - extra_trigger: "#oe_snippets.o_loaded", trigger: 'iframe .s_text_image a[href="http://odoo.be"]:contains("odoo website")', }, { @@ -101,11 +100,10 @@ wTourUtils.registerWebsitePreviewTour('link_tools', { run: () => {}, // It's a check. }, // 4. Add link on image. - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Click on image.", trigger: 'iframe .s_text_image img', - extra_trigger: '#oe_snippets.o_loaded', }, { content: "Activate link.", diff --git a/addons/website/static/tests/tours/media_dialog.js b/addons/website/static/tests/tours/media_dialog.js index 5c9e111299d..372a3f01638 100644 --- a/addons/website/static/tests/tours/media_dialog.js +++ b/addons/website/static/tests/tours/media_dialog.js @@ -1,15 +1,12 @@ /** @odoo-module */ -import { registry } from "@web/core/registry"; import wTourUtils from 'website.tour_utils'; -registry.category("web_tour.tours").add('website_media_dialog_undraw', { +wTourUtils.registerWebsitePreviewTour("website_media_dialog_undraw", { test: true, url: '/', - steps: [ -{ - trigger: 'a[data-action=edit]', -}, + edition: true, +}, [ wTourUtils.dragNDrop({ id: 's_text_image', name: 'Text - Image', @@ -21,7 +18,7 @@ wTourUtils.dragNDrop({ { trigger: '.o_select_media_dialog:has(.o_we_search_select option[value="media-library"])', }, -]}); +]); wTourUtils.registerWebsitePreviewTour('website_media_dialog_icons', { test: true, diff --git a/addons/website/static/tests/tours/restricted_editor.js b/addons/website/static/tests/tours/restricted_editor.js index 8891e85c7e1..8c65497956c 100644 --- a/addons/website/static/tests/tours/restricted_editor.js +++ b/addons/website/static/tests/tours/restricted_editor.js @@ -5,10 +5,6 @@ import wTourUtils from "website.tour_utils"; wTourUtils.registerWebsitePreviewTour("restricted_editor", { test: true, url: "/", -}, [{ - trigger: '.o_edit_website_container a', - content: "Click \"EDIT\" button of website as Restricted Editor", -}, { - trigger: '#oe_snippets.o_loaded', - content: "Check that the snippets loaded properly", -}]); +}, [ + ...wTourUtils.clickOnEditAndWaitEditMode(), +]); diff --git a/addons/website/static/tests/tours/rte.js b/addons/website/static/tests/tours/rte.js index 0576a8c0c61..ee172906e4a 100644 --- a/addons/website/static/tests/tours/rte.js +++ b/addons/website/static/tests/tours/rte.js @@ -171,12 +171,13 @@ wTourUtils.registerWebsitePreviewTour('rte_translator', { content: "return to english version", trigger: 'iframe .js_language_selector a[data-url_code="en"]', }, { - content: "edit english version", - trigger: '.o_edit_website_container > a', - extra_trigger: 'iframe body:not(:has(#wrap p font:first:containsExact(paragraphs describing)))', -}, { + content: "Check body", + trigger: "iframe body:not(:has(#wrap p font:first:containsExact(paragraphs describing)))", + run: function () {}, // it's a check +}, +...wTourUtils.clickOnEditAndWaitEditMode(), +{ content: "select text", - extra_trigger: '#oe_snippets.o_loaded', trigger: 'iframe #wrap p', run: function (actionHelper) { actionHelper.click(); diff --git a/addons/website/static/tests/tours/snippet_cache_across_websites.js b/addons/website/static/tests/tours/snippet_cache_across_websites.js index e285d72402e..1c1a9264e27 100644 --- a/addons/website/static/tests/tours/snippet_cache_across_websites.js +++ b/addons/website/static/tests/tours/snippet_cache_across_websites.js @@ -29,7 +29,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_cache_across_websites', { trigger: 'iframe html:not([data-website-id="1"])', run: () => null, }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Check that the custom snippet is not here", extra_trigger: '#oe_snippets:not(:has(#snippet_custom_body span:contains("custom_snippet_test")))', diff --git a/addons/website/static/tests/tours/snippet_image_gallery.js b/addons/website/static/tests/tours/snippet_image_gallery.js index 0a8b0576b1e..42f6b5c071b 100644 --- a/addons/website/static/tests/tours/snippet_image_gallery.js +++ b/addons/website/static/tests/tours/snippet_image_gallery.js @@ -24,8 +24,8 @@ wTourUtils.registerWebsitePreviewTour('snippet_image_gallery', { wTourUtils.registerWebsitePreviewTour("snippet_image_gallery_remove", { test: true, url: "/", + edition: true, }, [ - wTourUtils.clickOnEdit(), wTourUtils.dragNDrop({ id: "s_image_gallery", name: "Image Gallery", diff --git a/addons/website/static/tests/tours/snippet_popup_add_remove.js b/addons/website/static/tests/tours/snippet_popup_add_remove.js index 7b2f2a1a8a7..2d16745a8af 100644 --- a/addons/website/static/tests/tours/snippet_popup_add_remove.js +++ b/addons/website/static/tests/tours/snippet_popup_add_remove.js @@ -8,7 +8,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_popup_add_remove', { edition: true, }, [{ content: 'Drop s_popup snippet', - trigger: '#oe_snippets.o_loaded .oe_snippet:has( > [data-snippet="s_popup"]) .oe_snippet_thumbnail', + trigger: '.oe_snippet:has( > [data-snippet="s_popup"]) .oe_snippet_thumbnail', run: "drag_and_drop iframe #wrap", }, { content: 'Edit s_popup snippet', diff --git a/addons/website/static/tests/tours/snippet_table_of_content.js b/addons/website/static/tests/tours/snippet_table_of_content.js index 12327b0ea36..8c82413c999 100644 --- a/addons/website/static/tests/tours/snippet_table_of_content.js +++ b/addons/website/static/tests/tours/snippet_table_of_content.js @@ -38,14 +38,10 @@ wTourUtils.registerWebsitePreviewTour('snippet_table_of_content', { checkTOCNavBar(1, 0), scrollToHeading(3), checkTOCNavBar(1, 1), - wTourUtils.clickOnEdit(), - { - trigger: "#oe_snippets.o_loaded", - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Click on the first TOC's title", trigger: 'iframe .s_table_of_content:eq(0) h1', - extra_trigger: "#oe_snippets.o_loaded", }, { content: "Hide the first TOC on mobile", diff --git a/addons/website/static/tests/tours/snippet_translation.js b/addons/website/static/tests/tours/snippet_translation.js index 76f0a2f0f54..e7798d03903 100644 --- a/addons/website/static/tests/tours/snippet_translation.js +++ b/addons/website/static/tests/tours/snippet_translation.js @@ -40,19 +40,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_translation_changing_lang', { trigger: '.modal-footer .btn-primary', }, ...wTourUtils.clickOnSave(), - { - trigger: '.o_website_preview:not(.editor_enable.editor_has_snippets)', - run() {}, - }, - { - content: "Click on edit in master", - trigger: '.o_edit_website_container a', - }, - { - content: "Wait for edit mode to start", - trigger: '.o_website_preview.editor_enable.editor_has_snippets', - timeout: '30000', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.dragNDrop({name: 'Cover'}), { content: "Check that contact us contain Parseltongue", diff --git a/addons/website/static/tests/tours/snippet_version.js b/addons/website/static/tests/tours/snippet_version.js index 6073ef60473..885cf5435a5 100644 --- a/addons/website/static/tests/tours/snippet_version.js +++ b/addons/website/static/tests/tours/snippet_version.js @@ -32,15 +32,10 @@ wTourUtils.registerWebsitePreviewTour("snippet_version", { }, }, ...wTourUtils.clickOnSave(), -{ - trigger: ".o_edit_website_container a:has(span.fa-pencil)", - run() {}, -}, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Modify the version of snippets", trigger: '#oe_snippets .o_panel_body > .oe_snippet', - extra_trigger: '#oe_snippets.o_loaded', run: function () { document.querySelector('#oe_snippets .oe_snippet > [data-snippet="s_test_snip"]').dataset.vjs = '999'; document.querySelector('#oe_snippets .oe_snippet > [data-snippet="s_share"]').dataset.vcss = '999'; diff --git a/addons/website/static/tests/tours/snippets_all_drag_and_drop.js b/addons/website/static/tests/tours/snippets_all_drag_and_drop.js index d4ca2c38995..5170a1201fe 100644 --- a/addons/website/static/tests/tours/snippets_all_drag_and_drop.js +++ b/addons/website/static/tests/tours/snippets_all_drag_and_drop.js @@ -78,10 +78,10 @@ registry.category("web_tour.tours").add("snippets_all_drag_and_drop", { // tour here. There is currently an issue with tours which don't have an URL // url: '/?enable_editor=1&snippets_names=s_showcase,s_numbers,s_...', steps: [ - websiteTourUtils.clickOnEdit(), + ...websiteTourUtils.clickOnEditAndWaitEditMode(), { content: "Ensure snippets are actually passed at the test.", - trigger: "#oe_snippets.o_loaded", + trigger: "body", run: function () { // safety check, otherwise the test might "break" one day and // receive no steps. The test would then not test anything anymore diff --git a/addons/website/static/tests/tours/specific_website_editor.js b/addons/website/static/tests/tours/specific_website_editor.js index 85700bc0ea4..8804ff9d455 100644 --- a/addons/website/static/tests/tours/specific_website_editor.js +++ b/addons/website/static/tests/tours/specific_website_editor.js @@ -1,29 +1,27 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wTourUtils from "website.tour_utils"; -registry.category("web_tour.tours").add('generic_website_editor', { +wTourUtils.registerWebsitePreviewTour("generic_website_editor", { test: true, - steps: [{ - content: 'Click edit button', - trigger: '.o_edit_website_container > a', -}, -{ + edition: true, +}, [{ trigger: 'iframe body:not([data-hello="world"])', - extra_trigger: '#oe_snippets.o_loaded', content: 'Check that the editor DOM matches its website-generic features', run: function () {}, // Simple check -}]}); +}]); +// Good practice would have been to use `wTourUtils.registerWebsitePreviewTour` +// for this tour with `edition: true` and remove the first step to enter edit +// mode. Unfortunately this breaks the page and therefore the test fails for +// unknown reason. registry.category("web_tour.tours").add('specific_website_editor', { test: true, - steps: [{ - content: 'Click edit button', - trigger: '.o_edit_website_container > a', -}, + steps: [ + ...wTourUtils.clickOnEditAndWaitEditMode(), { trigger: 'iframe body[data-hello="world"]', - extra_trigger: '#oe_snippets.o_loaded', content: 'Check that the editor DOM matches its website-specific features', run: function () {}, // Simple check }]}); diff --git a/addons/website/static/tests/tours/website_click_tests.js b/addons/website/static/tests/tours/website_click_tests.js index 8ee610d59b5..aa5a495cf37 100644 --- a/addons/website/static/tests/tours/website_click_tests.js +++ b/addons/website/static/tests/tours/website_click_tests.js @@ -20,12 +20,7 @@ wTourUtils.registerWebsitePreviewTour('website_click_tour', { trigger: '.o_website_preview[data-view-xmlid="website.contactus"]', run: () => null, // it's a check }, - wTourUtils.clickOnEdit(), - { - content: "wait for edition to be started", - trigger: 'iframe body.editor_enable', - run: () => null, // it's a check - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "click on a link that would trigger navigation", trigger: 'iframe a[href="/"]', diff --git a/addons/website/static/tests/tours/website_form_editor.js b/addons/website/static/tests/tours/website_form_editor.js index fd7bb84f9c8..42c90183620 100644 --- a/addons/website/static/tests/tours/website_form_editor.js +++ b/addons/website/static/tests/tours/website_form_editor.js @@ -1,5 +1,5 @@ /** @odoo-module alias=website.tour.form_editor **/ - + import wTourUtils from "website.tour_utils"; // Visibility possible values: @@ -359,15 +359,10 @@ trigger: 'iframe .s_website_form_field input[data-fill-with="phone"]:propValue("+1 555-555-5555")', }, // Check that if we edit again and save again the default value is not deleted. - { - content: 'Enter in edit mode again', - trigger: '.o_edit_website_container > a', - run: 'click', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: 'Edit the form', trigger: 'iframe .s_website_form_field:eq(0) input', - extra_trigger: 'button[data-action="save"]', run: 'click', }, ...addCustomField('many2one', 'select', 'Select Field', true), @@ -381,15 +376,10 @@ extra_trigger: 'iframe body:not(.editor_enable)', trigger: 'iframe .s_website_form_field:eq(0) input[value="John Smith"]', }, - { - trigger: ".o_edit_website_container a:has(span.fa-pencil)", - run() {}, - }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: 'Click on the submit button', trigger: 'iframe .s_website_form_send', - extra_trigger: '.o_website_preview.editor_enable', run: 'click', }, { @@ -456,15 +446,13 @@ wTourUtils.registerWebsitePreviewTour('website_form_conditional_required_checkboxes', { test: true, url: '/', + edition: true, }, [ // Create a form with two checkboxes: the second one required but // invisible when the first one is checked. Basically this should allow // to have: both checkboxes are visible by default but the form can // only be sent if one of the checkbox is checked. { - content: "Enter edit mode", - trigger: '.o_edit_website_container > a', - }, { content: "Add the form snippet", trigger: '#oe_snippets .oe_snippet:has(.s_website_form) .oe_snippet_thumbnail', run: 'drag_and_drop iframe #wrap', diff --git a/addons/website/static/tests/tours/website_page_options.js b/addons/website/static/tests/tours/website_page_options.js index 081832c8b3c..7412d756060 100644 --- a/addons/website/static/tests/tours/website_page_options.js +++ b/addons/website/static/tests/tours/website_page_options.js @@ -19,7 +19,7 @@ wTourUtils.registerWebsitePreviewTour('website_page_options', { trigger: 'iframe #wrapwrap.o_header_overlay', run: () => null, // it's a check }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.clickOnSnippet({id: 'o_header_standard', name: 'Header'}), wTourUtils.changeOption('topMenuColor', 'we-select.o_we_so_color_palette'), wTourUtils.changeOption('topMenuColor', 'button[data-color="black-50"]', 'background color', 'bottom', true), @@ -29,7 +29,7 @@ wTourUtils.registerWebsitePreviewTour('website_page_options', { trigger: 'iframe header#top.bg-black-50', run: () => null, // it's a check }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.clickOnSnippet({id: 'o_header_standard', name: 'Header'}), wTourUtils.changeOption('TopMenuVisibility', 'we-select:has([data-visibility]) we-toggler'), wTourUtils.changeOption('TopMenuVisibility', 'we-button[data-visibility="hidden"]'), @@ -39,10 +39,9 @@ wTourUtils.registerWebsitePreviewTour('website_page_options', { trigger: 'iframe #wrapwrap:has(header#top.d-none.o_snippet_invisible)', run: () => null, // it's a check }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "Click on 'header' in the invisible elements list", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_invisible_el_panel .o_we_invisible_entry', }, wTourUtils.clickOnSnippet({id: 'o_footer', name: 'Footer'}), diff --git a/addons/website/static/tests/tours/website_snippets_menu_tabs.js b/addons/website/static/tests/tours/website_snippets_menu_tabs.js index 5e905b3c3b9..ad4234f178d 100644 --- a/addons/website/static/tests/tours/website_snippets_menu_tabs.js +++ b/addons/website/static/tests/tours/website_snippets_menu_tabs.js @@ -1,12 +1,12 @@ /** @odoo-module **/ -import { registry } from "@web/core/registry"; import wTourUtils from 'website.tour_utils'; -registry.category("web_tour.tours").add("website_snippets_menu_tabs", { +wTourUtils.registerWebsitePreviewTour("website_snippets_menu_tabs", { test: true, - url: "/?enable_editor=1", - steps: [ + url: "/", + edition: true, +}, [ wTourUtils.goToTheme(), { content: "Click on the empty 'DRAG BUILDING BLOCKS HERE' area.", @@ -30,4 +30,4 @@ registry.category("web_tour.tours").add("website_snippets_menu_tabs", { trigger: '.o_we_customize_panel > we-customizeblock-options', run: () => null, // it's a check }, -]}); +]); diff --git a/addons/website/static/tests/tours/website_style_edition.js b/addons/website/static/tests/tours/website_style_edition.js index 4292091804a..41ff9086139 100644 --- a/addons/website/static/tests/tours/website_style_edition.js +++ b/addons/website/static/tests/tours/website_style_edition.js @@ -17,7 +17,6 @@ wTourUtils.registerWebsitePreviewTour("website_style_edition", { edition: true, }, [{ content: "Go to theme options", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_theme_btn', }, { content: "Change font size", @@ -37,7 +36,7 @@ wTourUtils.registerWebsitePreviewTour("website_style_edition", { trigger: 'iframe body:not(.editor_enable) #wrapwrap', run: checkFontSize, }, -wTourUtils.clickOnEdit(), +...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.goToTheme(), { content: "Click on the Background Image selection", diff --git a/addons/website/tests/test_snippets.py b/addons/website/tests/test_snippets.py index 17191a597b8..9cb3e985bdc 100644 --- a/addons/website/tests/test_snippets.py +++ b/addons/website/tests/test_snippets.py @@ -17,7 +17,7 @@ class TestSnippets(HttpCase): self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_empty_parent_autoremove', login='admin') def test_02_default_shape_gets_palette_colors(self): - self.start_tour('/@/?enable_editor=1', "default_shape_gets_palette_colors", login='admin') + self.start_tour('/@/', 'default_shape_gets_palette_colors', login='admin') def test_03_snippets_all_drag_and_drop(self): with MockRequest(self.env, website=self.env['website'].browse(1)): diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 5fb5ae44baa..efc63963e23 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -283,7 +283,7 @@ class TestUi(odoo.tests.HttpCase): self.start_tour(self.env['website'].get_client_action_url('/'), 'website_style_edition', login='admin') def test_09_website_edit_link_popover(self): - self.start_tour('/@/?enable_editor=1', "edit_link_popover", login="admin") + self.start_tour('/@/', 'edit_link_popover', login='admin') def test_10_website_conditional_visibility(self): self.start_tour(self.env['website'].get_client_action_url('/'), 'conditional_visibility_1', login='admin') @@ -353,7 +353,7 @@ class TestUi(odoo.tests.HttpCase): """, }]) - self.start_tour("/?enable_editor=1", "focus_blur_snippets", login="admin") + self.start_tour('/', 'focus_blur_snippets', login='admin') def test_14_carousel_snippet_content_removal(self): self.start_tour(self.env['website'].get_client_action_url('/'), 'carousel_content_removal', login='admin') @@ -368,13 +368,13 @@ class TestUi(odoo.tests.HttpCase): self.start_tour(self.env['website'].get_client_action_url('/'), 'edit_menus', login='admin') def test_18_website_snippets_menu_tabs(self): - self.start_tour("/?enable_editor=1", "website_snippets_menu_tabs", login="admin") + self.start_tour('/', 'website_snippets_menu_tabs', login='admin') def test_19_website_page_options(self): self.start_tour("/web", "website_page_options", login="admin") def test_20_snippet_editor_panel_options(self): - self.start_tour("/@/?enable_editor=1", "snippet_editor_panel_options", login="admin") + self.start_tour('/@/', 'snippet_editor_panel_options', login='admin') def test_21_website_start_cloned_snippet(self): self.start_tour('/web', 'website_start_cloned_snippet', login='admin') @@ -383,7 +383,7 @@ class TestUi(odoo.tests.HttpCase): self.start_tour('/web', 'website_gray_color_palette', login='admin') def test_23_website_multi_edition(self): - self.start_tour('/@?enable_editor=1', 'website_multi_edition', login='admin') + self.start_tour('/@/', 'website_multi_edition', login='admin') def test_24_snippet_cache_across_websites(self): default_website = self.env.ref('website.default_website') diff --git a/addons/website_blog/static/tests/tours/blog_tags_tour.js b/addons/website_blog/static/tests/tours/blog_tags_tour.js index 5c2d13795ce..ce7bece7ba1 100644 --- a/addons/website_blog/static/tests/tours/blog_tags_tour.js +++ b/addons/website_blog/static/tests/tours/blog_tags_tour.js @@ -13,7 +13,7 @@ wTourUtils.registerWebsitePreviewTour('blog_tags', { content: "Go to first blog", trigger: "iframe article[name=blog_post] a", }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.clickOnSnippet('#o_wblog_post_top .o_wblog_post_page_cover'), { content: "Open tag dropdown", @@ -36,7 +36,7 @@ wTourUtils.registerWebsitePreviewTour('blog_tags', { trigger: "iframe #o_wblog_post_content .badge:contains(testtag)", isCheck: true, }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.clickOnSnippet('#o_wblog_post_top .o_wblog_post_page_cover'), { content: "Remove tag", diff --git a/addons/website_crm/static/tests/tours/website_crm.js b/addons/website_crm/static/tests/tours/website_crm.js index 112f0ae975e..748cc6f6b2a 100644 --- a/addons/website_crm/static/tests/tours/website_crm.js +++ b/addons/website_crm/static/tests/tours/website_crm.js @@ -10,7 +10,6 @@ }, [{ content: "Select contact form", trigger: "iframe #wrap.o_editable section.s_website_form", - extra_trigger: "iframe body.editor_enable", }, { content: "Open action select", trigger: "we-select:has(we-button:contains('Create an Opportunity')) we-toggler", diff --git a/addons/website_hr_recruitment/static/tests/tours/website_hr_recruitment.js b/addons/website_hr_recruitment/static/tests/tours/website_hr_recruitment.js index 11ada35333b..3268cdf7d7e 100644 --- a/addons/website_hr_recruitment/static/tests/tours/website_hr_recruitment.js +++ b/addons/website_hr_recruitment/static/tests/tours/website_hr_recruitment.js @@ -72,12 +72,11 @@ }, { content: 'Check if the Guru form is present', trigger: 'iframe form' - }, { - content: 'Enter in edit mode', - trigger: '.o_edit_website_container > a', - }, { + }, + ...wTourUtils.clickOnEditAndWaitEditMode(), + { content: 'Add a fake default value for the job_id field', - trigger: '#oe_snippets.o_loaded', + trigger: "body", run: () => { // It must be done in this way because the editor does not allow to // put a default value on a field with type="hidden". @@ -86,7 +85,6 @@ }, { content: 'Edit the form', trigger: 'iframe input[type="file"]', - extra_trigger: '#oe_snippets.o_loaded', }, { content: 'Add a new field', trigger: 'we-button[data-add-field]', @@ -115,12 +113,11 @@ console.error('The job_id field has a wrong value'); } } - }, { - content: 'Enter in edit mode', - trigger: '.o_edit_website_container > a', - }, { + }, + ...wTourUtils.clickOnEditAndWaitEditMode(), + { content: 'Verify that the job_id field has kept its default value', - trigger: '#oe_snippets.o_loaded', + trigger: "body", run: () => { if (!document.querySelector('.o_iframe:not(.o_ignore_in_tour)').contentDocument.querySelector('input[name="job_id"][value="FAKE_JOB_ID_DEFAULT_VAL"]')) { console.error('The job_id field has lost its default value'); diff --git a/addons/website_mass_mailing/static/tests/tours/newsletter_block.js b/addons/website_mass_mailing/static/tests/tours/newsletter_block.js index e3f063d1f63..240fc8d71cb 100644 --- a/addons/website_mass_mailing/static/tests/tours/newsletter_block.js +++ b/addons/website_mass_mailing/static/tests/tours/newsletter_block.js @@ -25,7 +25,7 @@ wTourUtils.registerWebsitePreviewTour('newsletter_block_edition', { extra_trigger: 'iframe .s_newsletter_block input:propValue(admin@yourcompany.example.com)', }, // Change the link style. - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: 'Click on the Subscribe button', trigger: 'iframe .s_newsletter_block .js_subscribe_btn', diff --git a/addons/website_mass_mailing/static/tests/tours/newsletter_popup_edition.js b/addons/website_mass_mailing/static/tests/tours/newsletter_popup_edition.js index f898fead467..497a6fe1078 100644 --- a/addons/website_mass_mailing/static/tests/tours/newsletter_popup_edition.js +++ b/addons/website_mass_mailing/static/tests/tours/newsletter_popup_edition.js @@ -1,13 +1,13 @@ /** @odoo-module **/ -import { registry } from "@web/core/registry"; import wTourUtils from "website.tour_utils"; import newsletterPopupUseTour from "website_mass_mailing.tour.newsletter_popup_use"; -registry.category("web_tour.tours").add('newsletter_popup_edition', { +wTourUtils.registerWebsitePreviewTour("newsletter_popup_edition", { test: true, - url: '/?enable_editor=1', - steps: [ + url: "/", + edition: true, +}, [ wTourUtils.dragNDrop({ id: 's_newsletter_subscribe_popup', name: 'Newsletter Popup', @@ -25,4 +25,4 @@ registry.category("web_tour.tours").add('newsletter_popup_edition', { extra_trigger: 'iframe body:not(.editor_enable)', run: newsletterPopupUseTour.ensurePopupNotVisible, } -]}); +]); diff --git a/addons/website_mass_mailing/tests/test_snippets.py b/addons/website_mass_mailing/tests/test_snippets.py index 62be2986397..311674b0fcf 100644 --- a/addons/website_mass_mailing/tests/test_snippets.py +++ b/addons/website_mass_mailing/tests/test_snippets.py @@ -9,7 +9,7 @@ import odoo.tests class TestSnippets(odoo.tests.HttpCase): def test_01_newsletter_popup(self): - self.start_tour("/?enable_editor=1", "newsletter_popup_edition", login='admin') + self.start_tour('/', 'newsletter_popup_edition', login='admin') self.start_tour("/", "newsletter_popup_use", login=None) mailing_list = self.env['mailing.list'].search([], limit=1) emails = mailing_list.contact_ids.mapped('email') diff --git a/addons/website_sale/static/tests/tours/website_sale_add_to_cart_snippet_tour.js b/addons/website_sale/static/tests/tours/website_sale_add_to_cart_snippet_tour.js index 833bfefae84..c6fa409c726 100644 --- a/addons/website_sale/static/tests/tours/website_sale_add_to_cart_snippet_tour.js +++ b/addons/website_sale/static/tests/tours/website_sale_add_to_cart_snippet_tour.js @@ -5,7 +5,7 @@ import wTourUtils from 'website.tour_utils'; function editAddToCartSnippet() { return [ - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), wTourUtils.clickOnSnippet({id: 's_add_to_cart'}) ] } diff --git a/addons/website_sale/static/tests/tours/website_sale_complete_flow_backend.js b/addons/website_sale/static/tests/tours/website_sale_complete_flow_backend.js index d307c56f2dd..04f22309ec8 100644 --- a/addons/website_sale/static/tests/tours/website_sale_complete_flow_backend.js +++ b/addons/website_sale/static/tests/tours/website_sale_complete_flow_backend.js @@ -9,7 +9,6 @@ wTourUtils.registerWebsitePreviewTour('website_sale_tour_backend', { }, [ { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { diff --git a/addons/website_sale/static/tests/tours/website_sale_shop_customize.js b/addons/website_sale/static/tests/tours/website_sale_shop_customize.js index da1063a2e23..3ce50bbb6a8 100644 --- a/addons/website_sale/static/tests/tours/website_sale_shop_customize.js +++ b/addons/website_sale/static/tests/tours/website_sale_shop_customize.js @@ -31,13 +31,9 @@ wTourUtils.registerWebsitePreviewTour('shop_customize', { trigger: 'iframe body:not(:has(.js_product_change))', run: function () {}, }, - { - content: "enter edit mode", - trigger: '.o_edit_website_container > a', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { @@ -70,13 +66,9 @@ wTourUtils.registerWebsitePreviewTour('shop_customize', { trigger: "iframe .product_price .oe_price .oe_currency_value:containsExact(800.40)", run: function () {}, }, - { - content: "enter edit mode", - trigger: '.o_edit_website_container > a', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { @@ -133,13 +125,9 @@ wTourUtils.registerWebsitePreviewTour('shop_customize', { trigger: "iframe a:contains(Continue Shopping)", extra_trigger: 'iframe body:not(:has(#products_grid_before .js_attributes))', }, - { - content: "enter edit mode", - trigger: '.o_edit_website_container > a', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { diff --git a/addons/website_sale/static/tests/tours/website_sale_shop_editor_tour.js b/addons/website_sale/static/tests/tours/website_sale_shop_editor_tour.js index 9004498c604..e7c3278cb03 100644 --- a/addons/website_sale/static/tests/tours/website_sale_shop_editor_tour.js +++ b/addons/website_sale/static/tests/tours/website_sale_shop_editor_tour.js @@ -1,14 +1,12 @@ /** @odoo-module **/ -import { registry } from "@web/core/registry"; +import wTourUtils from "website.tour_utils"; -registry.category("web_tour.tours").add('shop_editor', { +wTourUtils.registerWebsitePreviewTour("shop_editor", { test: true, - url: '/shop?enable_editor=1', - steps: [{ - trigger: '#oe_snippets.o_loaded', - content: "Wait for the editor to be loaded" -}, { + url: "/shop", + edition: true, +}, [{ content: "Click on pricelist dropdown", trigger: "iframe div.o_pricelist_dropdown a[data-bs-toggle=dropdown]", }, { @@ -19,4 +17,4 @@ registry.category("web_tour.tours").add('shop_editor', { trigger: "iframe div.o_pricelist_dropdown a[data-bs-toggle=dropdown]", extra_trigger: "iframe div.o_pricelist_dropdown a[data-bs-toggle=dropdown][aria-expanded=false]", content: "Click on the pricelist again.", -}]}); +}]); diff --git a/addons/website_sale/static/tests/tours/website_sale_shop_list_view_b2c.js b/addons/website_sale/static/tests/tours/website_sale_shop_list_view_b2c.js index dc68ddde1f3..a912d8362b6 100644 --- a/addons/website_sale/static/tests/tours/website_sale_shop_list_view_b2c.js +++ b/addons/website_sale/static/tests/tours/website_sale_shop_list_view_b2c.js @@ -23,13 +23,9 @@ wTourUtils.registerWebsitePreviewTour('shop_list_view_b2c', { extra_trigger: 'iframe #product_details', run: () => {}, // It's a check. }, - { - content: "go to edit mode", - trigger: '.o_edit_website_container > a', - }, + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { diff --git a/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist_admin.js b/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist_admin.js index aaf5fd0ad8f..cc4bbd686f2 100644 --- a/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist_admin.js +++ b/addons/website_sale_wishlist/static/tests/tours/website_sale_wishlist_admin.js @@ -16,10 +16,9 @@ wTourUtils.registerWebsitePreviewTour('shop_wishlist_admin', { trigger: 'iframe body:not(:has(.js_product_change))', extra_trigger: 'iframe #product_details', }, - wTourUtils.clickOnEdit(), + ...wTourUtils.clickOnEditAndWaitEditMode(), { content: "open customize tab", - extra_trigger: '#oe_snippets.o_loaded', trigger: '.o_we_customize_snippet_btn', }, { diff --git a/addons/website_slides/static/tests/tours/slide_course_publisher_standard.js b/addons/website_slides/static/tests/tours/slide_course_publisher_standard.js index d11af119019..3b431ccf57d 100644 --- a/addons/website_slides/static/tests/tours/slide_course_publisher_standard.js +++ b/addons/website_slides/static/tests/tours/slide_course_publisher_standard.js @@ -41,12 +41,10 @@ wTourUtils.registerWebsitePreviewTour('course_publisher_standard', { }, { content: 'eLearning: seems cool, create it', trigger: 'button:contains("Save")', -}, { - content: 'eLearning: launch course edition', - trigger: '.o_edit_website_container a', -}, { +}, +...wTourUtils.clickOnEditAndWaitEditMode(), +{ content: 'eLearning: double click image to edit it', - extra_trigger: 'iframe body.editor_enable', trigger: 'iframe img.o_wslides_course_pict', run: 'dblclick', }, { diff --git a/addons/website_slides/static/tests/tours/slides_course_publisher.js b/addons/website_slides/static/tests/tours/slides_course_publisher.js index 23a419a1515..bd2b2b7828a 100644 --- a/addons/website_slides/static/tests/tours/slides_course_publisher.js +++ b/addons/website_slides/static/tests/tours/slides_course_publisher.js @@ -45,12 +45,10 @@ wTourUtils.registerWebsitePreviewTour('course_publisher', { }, { content: 'eLearning: seems cool, create it', trigger: 'button:contains("Save")', -}, { - content: 'eLearning: launch course edition', - trigger: '.o_edit_website_container a', -}, { +}, +...wTourUtils.clickOnEditAndWaitEditMode(), +{ content: 'eLearning: double click image to edit it', - extra_trigger: 'iframe body.editor_enable', trigger: 'iframe img.o_wslides_course_pict', run: 'dblclick', }, { diff --git a/addons/website_slides/static/tests/tours/slides_full_screen_web_editor.js b/addons/website_slides/static/tests/tours/slides_full_screen_web_editor.js index 227361235ed..b3c9a8c615a 100644 --- a/addons/website_slides/static/tests/tours/slides_full_screen_web_editor.js +++ b/addons/website_slides/static/tests/tours/slides_full_screen_web_editor.js @@ -25,11 +25,8 @@ import wTourUtils from 'website.tour_utils'; trigger: 'iframe .o_wslides_fs_main', run: function () {} // check we land on the fullscreen view }, -wTourUtils.clickOnEdit() +...wTourUtils.clickOnEditAndWaitEditMode() , { trigger: 'iframe .o_wslides_lesson_main', run: function () {} // check we are redirected on the detailed view -}, { - trigger: 'body.editor_has_snippets', - run: function () {} // check the editor is automatically opened on the detailed view }]);