From 76efea6da1be857425154fe94ee34db8f2e4f9fb Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 11 Dec 2024 17:07:05 +0100 Subject: [PATCH 1/2] add missing edit-mode interactions --- addons/website/static/src/interactions/footer_slideout.js | 8 ++++++-- .../static/src/snippets/s_image_gallery/gallery_slider.js | 8 ++++++-- .../static/src/snippets/s_blog_posts/blog_posts.js | 2 -- .../website_event/static/src/snippets/s_events/events.js | 2 -- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/website/static/src/interactions/footer_slideout.js b/addons/website/static/src/interactions/footer_slideout.js index fe98d1764eb09..e106082268286 100644 --- a/addons/website/static/src/interactions/footer_slideout.js +++ b/addons/website/static/src/interactions/footer_slideout.js @@ -10,8 +10,6 @@ export class FooterSlideout extends Interaction { }), }, }; - // TODO Support edit mode. - static disabledInEditableMode = false; setup() { const mainEl = this.el.querySelector(":scope > main"); @@ -40,3 +38,9 @@ export class FooterSlideout extends Interaction { registry .category("website.active_elements") .add("website.footer_slideout", FooterSlideout); + +registry + .category("website.editable_active_elements_builders") + .add("website.footer_slideout", { + Interaction: FooterSlideout, + }); diff --git a/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js b/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js index 29a5b97bd7c83..486d5f9d7788a 100644 --- a/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js +++ b/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js @@ -5,8 +5,6 @@ import { isVisible } from "@html_editor/utils/dom_info"; export class GallerySlider extends Interaction { static selector = ".o_slideshow"; - // TODO Support edit-mode enabled. - static disabledInEditableMode = false; setup() { this.carouselEl = this.el.classList.contains("carousel") ? this.el : this.el.querySelector(".carousel"); @@ -114,3 +112,9 @@ export class GallerySlider extends Interaction { } registry.category("website.active_elements").add("website.gallery_slider", GallerySlider); + +registry + .category("website.editable_active_elements_builders") + .add("website.gallery_slider", { + Interaction: GallerySlider, + }); diff --git a/addons/website_blog/static/src/snippets/s_blog_posts/blog_posts.js b/addons/website_blog/static/src/snippets/s_blog_posts/blog_posts.js index 0020e3fd03cde..244b48d225c05 100644 --- a/addons/website_blog/static/src/snippets/s_blog_posts/blog_posts.js +++ b/addons/website_blog/static/src/snippets/s_blog_posts/blog_posts.js @@ -3,8 +3,6 @@ import { DynamicSnippet } from "@website/snippets/s_dynamic_snippet/dynamic_snip export class DynamicSnippetBlogPosts extends DynamicSnippet { static selector = ".s_dynamic_snippet_blog_posts"; - // TODO Support edit mode. - static disabledInEditableMode = false; /** * Method to be overridden in child components in order to provide a search diff --git a/addons/website_event/static/src/snippets/s_events/events.js b/addons/website_event/static/src/snippets/s_events/events.js index 36890090cb997..fbd0acfd27286 100644 --- a/addons/website_event/static/src/snippets/s_events/events.js +++ b/addons/website_event/static/src/snippets/s_events/events.js @@ -6,8 +6,6 @@ export class Events extends DynamicSnippet { // While the selector has 'upcoming_snippet' in its name, it now has a filter // option to include ongoing events. The name is kept for backward compatibility. static selector = ".s_event_upcoming_snippet"; - // TODO Support edit mode. - static disabledInEditableMode = false; /** * @override From 2780d2c3e2028e9372a59d200a471aa0a5f68618 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 11 Dec 2024 17:28:47 +0100 Subject: [PATCH 2/2] misc lint --- addons/website/static/src/core/colibri.js | 2 +- .../static/src/interactions/animation.js | 1 - .../carousel_bootstrap_upgrade_fix.js | 13 --------- .../static/src/interactions/popup/popup.js | 1 - .../src/interactions/popup/shared_popup.js | 1 - .../interactions/video/background_video.js | 1 - .../s_image_gallery/gallery_slider.js | 2 +- .../s_instagram_page/instagram_page.js | 27 +++++++++---------- .../src/snippets/s_website_form/form.js | 1 - .../static/tests/core/interaction.test.js | 4 +-- .../tests/core/interaction_util.test.js | 10 ++++--- .../static/tests/core/website_core.test.js | 6 +---- .../tests/interactions/anchor_slide.test.js | 2 -- .../tests/interactions/plausible_push.test.js | 4 +-- .../snippets/dynamic_snippet.test.js | 2 -- .../interactions/snippets/form.edit.test.js | 6 ++--- .../tests/interactions/snippets/form.test.js | 24 ++++++----------- .../interactions/snippets/search_bar.test.js | 6 ++--- .../snippets/search_bar_results.test.js | 12 +++------ ...ite_controller_page_listing_layout.test.js | 4 +-- .../interactions/snippets/events.test.js | 2 -- .../snippets/dynamic_snippet_products.test.js | 2 +- 22 files changed, 48 insertions(+), 85 deletions(-) diff --git a/addons/website/static/src/core/colibri.js b/addons/website/static/src/core/colibri.js index 101e5c528767d..6e24783f516a5 100644 --- a/addons/website/static/src/core/colibri.js +++ b/addons/website/static/src/core/colibri.js @@ -257,7 +257,7 @@ export class Colibri { destroy() { // restore t-att to their initial values for (const dynAttrs of this.dynamicAttrs) { - const { nodes, attr, definition, initialValues } = dynAttrs; + const { nodes, attr, initialValues } = dynAttrs; if (!initialValues) { continue; } diff --git a/addons/website/static/src/interactions/animation.js b/addons/website/static/src/interactions/animation.js index 0dbd42c8bb70e..961b030ea6639 100644 --- a/addons/website/static/src/interactions/animation.js +++ b/addons/website/static/src/interactions/animation.js @@ -129,7 +129,6 @@ export class Animation extends Interaction { const windowsHeight = window.innerHeight; const elHeight = el.offsetHeight; let elOffset = this.isAnimateOnScroll ? 0 : Math.max((elHeight * this.offsetRatio), this.offsetMin); - const elStyle = window.getComputedStyle(el); // We need to offset for the change in position from some animation. // So we get the top value by not taking CSS transforms into calculations. diff --git a/addons/website/static/src/interactions/carousel_bootstrap_upgrade_fix.js b/addons/website/static/src/interactions/carousel_bootstrap_upgrade_fix.js index d7af762146799..79b9a117bc0ba 100644 --- a/addons/website/static/src/interactions/carousel_bootstrap_upgrade_fix.js +++ b/addons/website/static/src/interactions/carousel_bootstrap_upgrade_fix.js @@ -3,19 +3,6 @@ import { Interaction } from "@website/core/interaction"; const CAROUSEL_SLIDING_CLASS = "o_carousel_sliding"; -/** - * @param {HTMLElement} carouselEl - * @returns {Promise} - */ -async function waitForCarouselToFinishSliding(carouselEl) { - if (!carouselEl.classList.contains(CAROUSEL_SLIDING_CLASS)) { - return; - } - return new Promise(resolve => { - carouselEl.addEventListener("slid.bs.carousel", () => resolve(), {once: true}); - }); -} - /** * This class is used to fix carousel auto-slide behavior in Odoo 17.4 and up. * It handles upgrade cases from lower versions. diff --git a/addons/website/static/src/interactions/popup/popup.js b/addons/website/static/src/interactions/popup/popup.js index c726deff95dcd..962fb460af9d0 100644 --- a/addons/website/static/src/interactions/popup/popup.js +++ b/addons/website/static/src/interactions/popup/popup.js @@ -1,5 +1,4 @@ import { cookie } from "@web/core/browser/cookie"; -import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { utils as uiUtils, SIZES } from "@web/core/ui/ui_service"; import { getTabableElements } from "@web/core/utils/ui"; diff --git a/addons/website/static/src/interactions/popup/shared_popup.js b/addons/website/static/src/interactions/popup/shared_popup.js index a14e789f31842..577b881677e23 100644 --- a/addons/website/static/src/interactions/popup/shared_popup.js +++ b/addons/website/static/src/interactions/popup/shared_popup.js @@ -1,4 +1,3 @@ -import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { getScrollingElement } from "@web/core/utils/scrolling"; import { Interaction } from "@website/core/interaction"; diff --git a/addons/website/static/src/interactions/video/background_video.js b/addons/website/static/src/interactions/video/background_video.js index f4d32b1210566..afb390adb98a7 100644 --- a/addons/website/static/src/interactions/video/background_video.js +++ b/addons/website/static/src/interactions/video/background_video.js @@ -1,7 +1,6 @@ import { Interaction } from "@website/core/interaction"; import { registry } from "@web/core/registry"; -import { _t } from "@web/core/l10n/translation"; import { uniqueId } from "@web/core/utils/functions"; import { renderToElement } from "@web/core/utils/render"; diff --git a/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js b/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js index 486d5f9d7788a..e1170ff36ff35 100644 --- a/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js +++ b/addons/website/static/src/snippets/s_image_gallery/gallery_slider.js @@ -67,7 +67,7 @@ export class GallerySlider extends Interaction { } this.page += dispatchedEl.classList.contains("o_indicators_left") ? -1 : 1; this.page = Math.max(0, Math.min(this.nbPages - 1, this.page)); // should not be necessary - Carousel.getOrCreateInstance(this.carouselEl).to(this.page * this.realNbPerPage); + window.Carousel.getOrCreateInstance(this.carouselEl).to(this.page * this.realNbPerPage); // We dont use hide() before the slide animation in the editor because there is a traceback // TO DO: fix this traceback if (!this.editableMode) { diff --git a/addons/website/static/src/snippets/s_instagram_page/instagram_page.js b/addons/website/static/src/snippets/s_instagram_page/instagram_page.js index 82962dd0f9373..08c274273a1ac 100644 --- a/addons/website/static/src/snippets/s_instagram_page/instagram_page.js +++ b/addons/website/static/src/snippets/s_instagram_page/instagram_page.js @@ -17,28 +17,28 @@ export class InstagramPage extends Interaction { } setup() { - const iframeEl = document.createElement("iframe"); - iframeEl.setAttribute("scrolling", "no"); - iframeEl.setAttribute("aria-label", _t("Instagram")); - iframeEl.classList.add("w-100"); + this.iframeEl = document.createElement("iframe"); + this.iframeEl.setAttribute("scrolling", "no"); + this.iframeEl.setAttribute("aria-label", _t("Instagram")); + this.iframeEl.classList.add("w-100"); // In the meantime Instagram doesn't send us a message with the height, // we use a formula to estimate the height of the iframe (the formula // has been found with a linear regression). - const iframeWidth = parseInt(getComputedStyle(iframeEl).width); + const iframeWidth = parseInt(getComputedStyle(this.iframeEl).width); // The profile picture is smaller when width < 432px. - iframeEl.height = 0.659 * iframeWidth + (iframeWidth < 432 ? 156 : 203); + this.iframeEl.height = 0.659 * iframeWidth + (iframeWidth < 432 ? 156 : 203); - // TODO : Check if the next lines can be replace by `this.insert(iframeEl, this.el.querySelector(".o_instagram_container"));` + // TODO : Check if the next lines can be replace by `this.insert(this.iframeEl, this.el.querySelector(".o_instagram_container"));` - this.el.querySelector(".o_instagram_container").appendChild(iframeEl); + this.el.querySelector(".o_instagram_container").appendChild(this.iframeEl); // TODO : ...observerUnactive() / ...observerActive() - this.registerCleanup(() => { iframeEl.remove(); }); + this.registerCleanup(() => { this.iframeEl.remove(); }); } start() { const src = `https://www.instagram.com/${this.el.dataset.instagramPage}/embed`; - this.services.website_cookies.manageIframeSrc(iframeEl, src); + this.services.website_cookies.manageIframeSrc(this.iframeEl, src); } /** @@ -47,10 +47,9 @@ export class InstagramPage extends Interaction { * @param {Event} ev */ onMessage(ev) { - const iframeEl = this.el.querySelector(".o_instagram_container iframe"); // TODO Check if this issue is fixed with the new editor /* - if (!iframeEl) { + if (!this.iframeEl) { // TODO: fix this case. We should never end up here. It happens when // - Drop Instagram snippet // - Undo @@ -61,7 +60,7 @@ export class InstagramPage extends Interaction { return; } */ - if (ev.origin !== "https://www.instagram.com" || iframeEl.contentWindow !== ev.source) { + if (ev.origin !== "https://www.instagram.com" || this.iframeEl.contentWindow !== ev.source) { return; } const evDataJSON = JSON.parse(ev.data); @@ -73,7 +72,7 @@ export class InstagramPage extends Interaction { // Instagram can return a height of 0 before the real height. if (height) { // this.options.wysiwyg?.odooEditor.observerUnactive(); - iframeEl.height = height; + this.iframeEl.height = height; // this.options.wysiwyg?.odooEditor.observerActive(); } } diff --git a/addons/website/static/src/snippets/s_website_form/form.js b/addons/website/static/src/snippets/s_website_form/form.js index a2881ea4d6f34..275df395cf88d 100644 --- a/addons/website/static/src/snippets/s_website_form/form.js +++ b/addons/website/static/src/snippets/s_website_form/form.js @@ -4,7 +4,6 @@ import { registry } from "@web/core/registry"; import { Interaction } from "@website/core/interaction"; import { user } from "@web/core/user"; import { delay } from "@web/core/utils/concurrency"; -import { debounce } from "@web/core/utils/timing"; import { _t } from "@web/core/l10n/translation"; import { renderToElement } from "@web/core/utils/render"; import { post } from "@web/core/network/http_service"; diff --git a/addons/website/static/tests/core/interaction.test.js b/addons/website/static/tests/core/interaction.test.js index f923ff5dc52b5..ac39ce9764b4c 100644 --- a/addons/website/static/tests/core/interaction.test.js +++ b/addons/website/static/tests/core/interaction.test.js @@ -79,7 +79,7 @@ describe("adding listeners", () => { }, }; } - const { el } = await startInteraction(Test, TemplateTest); + await startInteraction(Test, TemplateTest); expect(clicked).toBe(0); await dblclick("span"); expect(clicked).toBe(3); // event dblclick = click + click + dblclick @@ -230,7 +230,7 @@ describe("using selectors", () => { "_myselector": { "t-att-animal": () => "colibri" }, }; } - const { el } = await startInteraction(Test, ` + await startInteraction(Test, `
coucou
`); diff --git a/addons/website/static/tests/core/interaction_util.test.js b/addons/website/static/tests/core/interaction_util.test.js index e7b6675d9aee0..ad2dc06ce0044 100644 --- a/addons/website/static/tests/core/interaction_util.test.js +++ b/addons/website/static/tests/core/interaction_util.test.js @@ -3,6 +3,8 @@ import { Interaction } from "@website/core/interaction"; import { buildEditableInteractions } from "@website/core/website_edit_service"; test("buildEditableInteractions concrete", async () => { + const doStuff = () => {}; + class Base extends Interaction { stuff() { doStuff(); @@ -13,7 +15,7 @@ test("buildEditableInteractions concrete", async () => { }; class Specific extends Base { otherStuff() { - doOtherStuff(); + doStuff("other"); } } const builders = [ @@ -31,6 +33,8 @@ test("buildEditableInteractions concrete", async () => { }); test("buildEditableInteractions abstract", async () => { + const doStuff = () => {}; + class AbstractBase extends Interaction { stuff() { doStuff(); @@ -41,12 +45,12 @@ test("buildEditableInteractions abstract", async () => { }; class AbstractIntermediate extends AbstractBase { moreStuff() { - doMoreStuff(); + doStuff("more"); } } class Specific extends AbstractIntermediate { otherStuff() { - doOtherStuff(); + doStuff("other"); } } const builders = [ diff --git a/addons/website/static/tests/core/website_core.test.js b/addons/website/static/tests/core/website_core.test.js index 71b2273a47f29..ac81ea8cb0b60 100644 --- a/addons/website/static/tests/core/website_core.test.js +++ b/addons/website/static/tests/core/website_core.test.js @@ -4,8 +4,7 @@ import { animationFrame } from "@odoo/hoot-mock"; import { Component, xml } from "@odoo/owl"; import { makeMockEnv } from "@web/../tests/web_test_helpers"; import { Interaction } from "@website/core/interaction"; -import { startInteraction, startInteractions } from "./helpers"; -import { registry } from "@web/core/registry"; +import { startInteraction } from "./helpers"; test("properly handles case where we have no match for wrapwrap", async () => { const env = await makeMockEnv(); @@ -15,13 +14,10 @@ test("properly handles case where we have no match for wrapwrap", async () => { test("wait for translation before starting interactions", async () => { - let flag = false; - class Test extends Interaction { static selector = ".test"; setup() { - flag = true; expect("localization" in this.services).toBe(true); } } diff --git a/addons/website/static/tests/interactions/anchor_slide.test.js b/addons/website/static/tests/interactions/anchor_slide.test.js index f60a20a851a0e..0cc11e7bb489c 100644 --- a/addons/website/static/tests/interactions/anchor_slide.test.js +++ b/addons/website/static/tests/interactions/anchor_slide.test.js @@ -1,8 +1,6 @@ import { expect, test } from "@odoo/hoot"; import { animationFrame, click } from "@odoo/hoot-dom"; import { advanceTime } from "@odoo/hoot-mock"; -import { patchWithCleanup } from "@web/../tests/web_test_helpers"; -import { AnchorSlide } from "@website/interactions/anchor_slide"; import { isElementInViewport, startInteractions, diff --git a/addons/website/static/tests/interactions/plausible_push.test.js b/addons/website/static/tests/interactions/plausible_push.test.js index 8ff86f45b9e22..4bfe451f5f59a 100644 --- a/addons/website/static/tests/interactions/plausible_push.test.js +++ b/addons/website/static/tests/interactions/plausible_push.test.js @@ -19,6 +19,6 @@ test("plausible push interaction notifies plausible if .js_plausible_push", asyn `); expect(core.interactions.length).toBe(1); - expect(plausible.q[0][0]).toBe("Lead Generation"); - expect(plausible.q[0][1]).toEqual({ props: '{"CTA": "Contact Us"}' }); + expect(window.plausible.q[0][0]).toBe("Lead Generation"); + expect(window.plausible.q[0][1]).toEqual({ props: '{"CTA": "Contact Us"}' }); }); diff --git a/addons/website/static/tests/interactions/snippets/dynamic_snippet.test.js b/addons/website/static/tests/interactions/snippets/dynamic_snippet.test.js index 9e9fe97792295..210a702894a1c 100644 --- a/addons/website/static/tests/interactions/snippets/dynamic_snippet.test.js +++ b/addons/website/static/tests/interactions/snippets/dynamic_snippet.test.js @@ -1,6 +1,4 @@ import { expect, test } from "@odoo/hoot"; -import { animationFrame, click, scroll } from "@odoo/hoot-dom"; -import { advanceTime } from "@odoo/hoot-mock"; import { onRpc } from "@web/../tests/web_test_helpers"; import { registry } from "@web/core/registry"; import { Interaction } from "@website/core/interaction"; diff --git a/addons/website/static/tests/interactions/snippets/form.edit.test.js b/addons/website/static/tests/interactions/snippets/form.edit.test.js index 32a0314f3dcc4..974631371c221 100644 --- a/addons/website/static/tests/interactions/snippets/form.edit.test.js +++ b/addons/website/static/tests/interactions/snippets/form.edit.test.js @@ -66,7 +66,7 @@ test("form formats date in edit mode", async () => { const { core, el } = await startInteractions(formXml, { waitForStart: true, editMode: true }); expect(core.interactions.length).toBe(1); const formEl = el.querySelector("form"); - const dateEl = el.querySelector("input[name=When]"); + const dateEl = formEl.querySelector("input[name=When]"); expect(dateEl.value).toBe("01/01/2025 10:00:00"); // Verify that non-edit code did not run. const dateField = dateEl.closest(".s_website_form_datetime"); @@ -79,7 +79,7 @@ test("form is NOT prefilled in edit mode", async () => { const { core, el } = await startInteractions(formXml, { waitForStart: true, editMode: true }); expect(core.interactions.length).toBe(1); const formEl = el.querySelector("form"); - const companyEl = el.querySelector("input[name=company]"); + const companyEl = formEl.querySelector("input[name=company]"); expect(companyEl.value).toBe(""); }); @@ -89,6 +89,6 @@ test("form is NOT prefilled in translate mode", async () => { const { core, el } = await startInteractions(formXml, { waitForStart: true, translateMode: true }); expect(core.interactions.length).toBe(1); const formEl = el.querySelector("form"); - const companyEl = el.querySelector("input[name=company]"); + const companyEl = formEl.querySelector("input[name=company]"); expect(companyEl.value).toBe(""); }); diff --git a/addons/website/static/tests/interactions/snippets/form.test.js b/addons/website/static/tests/interactions/snippets/form.test.js index a0c1d21759319..b96ce9deb1f34 100644 --- a/addons/website/static/tests/interactions/snippets/form.test.js +++ b/addons/website/static/tests/interactions/snippets/form.test.js @@ -1,7 +1,7 @@ import { expect, test } from "@odoo/hoot"; import { click, fill } from "@odoo/hoot-dom"; import { advanceTime, Deferred } from "@odoo/hoot-mock"; -import { MockServer, onRpc, patchWithCleanup, webModels } from "@web/../tests/web_test_helpers"; +import { MockServer, onRpc, patchWithCleanup } from "@web/../tests/web_test_helpers"; import { startInteractions, setupInteractionWhiteList, @@ -89,11 +89,11 @@ test("form checks conditions", async () => { `); expect(core.interactions.length).toBe(1); const formEl = el.querySelector("form"); - const nameEl = el.querySelector("input[name=name]"); - const mailEl = el.querySelector("input[name=email_from]"); - const subjectEl = el.querySelector("input[name=subject]"); - const questionEl = el.querySelector("textarea[name=description]"); - const submitEl = el.querySelector("a.s_website_form_send"); + const nameEl = formEl.querySelector("input[name=name]"); + const mailEl = formEl.querySelector("input[name=email_from]"); + const subjectEl = formEl.querySelector("input[name=subject]"); + const questionEl = formEl.querySelector("textarea[name=description]"); + const submitEl = formEl.querySelector("a.s_website_form_send"); function checkVisibility( isNameVisible, @@ -241,17 +241,9 @@ test("form prefilled conditional", async () => { `); expect(core.interactions.length).toBe(1); const formEl = el.querySelector("form"); - const nameEl = el.querySelector("input[name=name]"); - const phoneEl = el.querySelector("input[name=phone]"); + const nameEl = formEl.querySelector("input[name=name]"); + const phoneEl = formEl.querySelector("input[name=phone]"); - function checkPhoneVisibility(isVisible) { - const fieldEl = field(el); - if (isVisible) { - expect(fieldEl).not.toHaveClass("d-none"); - } else { - expect(fieldEl).toHaveClass("d-none"); - } - } expect(nameEl).not.toBe(undefined); expect(nameEl.value).toBe("Mitchell Admin"); expect(phoneEl).not.toBe(undefined); diff --git a/addons/website/static/tests/interactions/snippets/search_bar.test.js b/addons/website/static/tests/interactions/snippets/search_bar.test.js index e305ecd273df8..bbd9b96028333 100644 --- a/addons/website/static/tests/interactions/snippets/search_bar.test.js +++ b/addons/website/static/tests/interactions/snippets/search_bar.test.js @@ -90,7 +90,7 @@ test("searchbar triggers a search when text is entered", async () => { test("searchbar selects first result on cursor down", async () => { supportAutocomplete(); - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); const inputEl = formEl.querySelector("input[type=search]"); await click(inputEl); @@ -107,7 +107,7 @@ test("searchbar selects first result on cursor down", async () => { test("searchbar selects last result on cursor up", async () => { supportAutocomplete(); - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); const inputEl = formEl.querySelector("input[type=search]"); await click(inputEl); @@ -124,7 +124,7 @@ test("searchbar selects last result on cursor up", async () => { test("searchbar removes results on escape", async () => { supportAutocomplete(); - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); const inputEl = formEl.querySelector("input[type=search]"); await click(inputEl); diff --git a/addons/website/static/tests/interactions/snippets/search_bar_results.test.js b/addons/website/static/tests/interactions/snippets/search_bar_results.test.js index 7783f5ad03215..a4ac4c16a56e4 100644 --- a/addons/website/static/tests/interactions/snippets/search_bar_results.test.js +++ b/addons/website/static/tests/interactions/snippets/search_bar_results.test.js @@ -1,7 +1,5 @@ import { expect, test } from "@odoo/hoot"; import { press } from "@odoo/hoot-dom"; -import { advanceTime } from "@odoo/hoot-mock"; -import { onRpc } from "@web/../tests/web_test_helpers"; import { startInteractions, setupInteractionWhiteList } from "../../core/helpers"; setupInteractionWhiteList("website.search_bar_results"); @@ -40,9 +38,8 @@ const searchTemplate = ` `; test("searchbar selects next result on cursor down", async () => { - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); - const inputEl = formEl.querySelector("input[type=search]"); const resultEls = formEl.querySelectorAll("a:has(.o_search_result_item)"); resultEls[0].focus(); await press("down"); @@ -50,7 +47,7 @@ test("searchbar selects next result on cursor down", async () => { }); test("searchbar selects input on cursor down on last result", async () => { - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); const inputEl = formEl.querySelector("input[type=search]"); const resultEls = formEl.querySelectorAll("a:has(.o_search_result_item)"); @@ -60,9 +57,8 @@ test("searchbar selects input on cursor down on last result", async () => { }); test("searchbar selects previous result on cursor up", async () => { - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); - const inputEl = formEl.querySelector("input[type=search]"); const resultEls = formEl.querySelectorAll("a:has(.o_search_result_item)"); resultEls[1].focus(); await press("up"); @@ -70,7 +66,7 @@ test("searchbar selects previous result on cursor up", async () => { }); test("searchbar selects input on cursor up on first result", async () => { - const { core, el } = await startInteractions(searchTemplate); + const { el } = await startInteractions(searchTemplate); const formEl = el.querySelector("form"); const inputEl = formEl.querySelector("input[type=search]"); const resultEls = formEl.querySelectorAll("a:has(.o_search_result_item)"); diff --git a/addons/website/static/tests/interactions/website_controller_page_listing_layout.test.js b/addons/website/static/tests/interactions/website_controller_page_listing_layout.test.js index b0d08ab5688d7..4e3477624b6e8 100644 --- a/addons/website/static/tests/interactions/website_controller_page_listing_layout.test.js +++ b/addons/website/static/tests/interactions/website_controller_page_listing_layout.test.js @@ -11,7 +11,7 @@ setupInteractionWhiteList("website.website_controller_page_listing_layout"); test("website controller page listing layout toggle to list mode", async () => { const deferred = new Deferred(); - const { core, el } = await startInteractions(` + const { el } = await startInteractions(`
@@ -55,7 +55,7 @@ test("website controller page listing layout toggle to list mode", async () => { test("website controller page listing layout toggle to grid mode", async () => { const deferred = new Deferred(); - const { core, el } = await startInteractions(` + const { el } = await startInteractions(`
diff --git a/addons/website_event/static/tests/interactions/snippets/events.test.js b/addons/website_event/static/tests/interactions/snippets/events.test.js index b0f587aa98d48..622aaa77af992 100644 --- a/addons/website_event/static/tests/interactions/snippets/events.test.js +++ b/addons/website_event/static/tests/interactions/snippets/events.test.js @@ -1,6 +1,4 @@ import { expect, test } from "@odoo/hoot"; -import { animationFrame, click } from "@odoo/hoot-dom"; -import { advanceTime } from "@odoo/hoot-mock"; import { onRpc, } from "@web/../tests/web_test_helpers"; diff --git a/addons/website_sale/static/tests/interactions/snippets/dynamic_snippet_products.test.js b/addons/website_sale/static/tests/interactions/snippets/dynamic_snippet_products.test.js index b3114d6023963..8fe35114c9f10 100644 --- a/addons/website_sale/static/tests/interactions/snippets/dynamic_snippet_products.test.js +++ b/addons/website_sale/static/tests/interactions/snippets/dynamic_snippet_products.test.js @@ -86,7 +86,7 @@ test.tags("desktop")("dynamic snippet products loads items and displays them thr `); expect(core.interactions.length).toBe(6); const contentEl = el.querySelector(".dynamic_snippet_template"); - const carouselEl = el.querySelector(".carousel"); + const carouselEl = contentEl.querySelector(".carousel"); // Neutralize carousel automatic sliding. carouselEl.dataset.bsRide = "false"; const itemEls = carouselEl.querySelectorAll(".s_test_item");