ClientAction_
diff --git a/addons/web/static/tests/webclient/mobile/mobile_switch_company_menu_tests.js b/addons/web/static/tests/webclient/mobile/mobile_switch_company_menu_tests.js
index 2803434bd34..985f2d07c26 100644
--- a/addons/web/static/tests/webclient/mobile/mobile_switch_company_menu_tests.js
+++ b/addons/web/static/tests/webclient/mobile/mobile_switch_company_menu_tests.js
@@ -17,6 +17,7 @@ import { uiService } from "@web/core/ui/ui_service";
import { session } from "@web/session";
const serviceRegistry = registry.category("services");
+let target;
async function createSwitchCompanyMenu(routerParams = {}, toggleDelay = 0) {
patchWithCleanup(MobileSwitchCompanyMenu, { toggleDelay });
@@ -34,13 +35,13 @@ async function createSwitchCompanyMenu(routerParams = {}, toggleDelay = 0) {
});
}
const env = await makeTestEnv();
- const target = getFixture();
const scMenu = await mount(MobileSwitchCompanyMenu, target, { env });
return scMenu;
}
-QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
+QUnit.module("MobileSwitchCompanyMenu", (hooks) => {
hooks.beforeEach(() => {
+ target = getFixture();
patchWithCleanup(session.user_companies, {
allowed_companies: {
1: { id: 1, name: "Hermit" },
@@ -57,34 +58,34 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
QUnit.test("basic rendering", async (assert) => {
assert.expect(13);
- const scMenu = await createSwitchCompanyMenu();
+ await createSwitchCompanyMenu();
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
- assert.strictEqual(scMenu.el.tagName.toUpperCase(), "DIV");
- assert.hasClass(scMenu.el, "o_burger_menu_companies");
-
- assert.containsN(scMenu, ".toggle_company", 3);
- assert.containsN(scMenu, ".log_into", 3);
- assert.containsOnce(scMenu.el, ".fa-check-square");
- assert.containsN(scMenu.el, ".fa-square-o", 2);
+ assert.strictEqual(scMenuEl.tagName.toUpperCase(), "DIV");
+ assert.hasClass(scMenuEl, "o_burger_menu_companies");
+ assert.containsN(scMenuEl, ".toggle_company", 3);
+ assert.containsN(scMenuEl, ".log_into", 3);
+ assert.containsOnce(scMenuEl, ".fa-check-square");
+ assert.containsN(scMenuEl, ".fa-square-o", 2);
assert.strictEqual(
- scMenu.el.querySelectorAll(".menu_companies_item")[0].textContent,
+ scMenuEl.querySelectorAll(".menu_companies_item")[0].textContent,
"Hermit(current)"
);
assert.strictEqual(
- scMenu.el.querySelectorAll(".menu_companies_item")[1].textContent,
+ scMenuEl.querySelectorAll(".menu_companies_item")[1].textContent,
"Herman's"
);
assert.strictEqual(
- scMenu.el.querySelectorAll(".menu_companies_item")[2].textContent,
+ scMenuEl.querySelectorAll(".menu_companies_item")[2].textContent,
"Heroes TM"
);
- assert.hasClass(scMenu.el.querySelectorAll(".menu_companies_item i")[0], "fa-check-square");
- assert.hasClass(scMenu.el.querySelectorAll(".menu_companies_item i")[1], "fa-square-o");
- assert.hasClass(scMenu.el.querySelectorAll(".menu_companies_item i")[2], "fa-square-o");
+ assert.hasClass(scMenuEl.querySelectorAll(".menu_companies_item i")[0], "fa-check-square");
+ assert.hasClass(scMenuEl.querySelectorAll(".menu_companies_item i")[1], "fa-square-o");
+ assert.hasClass(scMenuEl.querySelectorAll(".menu_companies_item i")[2], "fa-square-o");
- assert.strictEqual(scMenu.el.textContent, "CompaniesHermit(current)Herman'sHeroes TM");
+ assert.strictEqual(scMenuEl.textContent, "CompaniesHermit(current)Herman'sHeroes TM");
});
QUnit.test("companies can be toggled: toggle a second company", async (assert) => {
@@ -96,6 +97,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
prom.resolve();
}
const scMenu = await createSwitchCompanyMenu({ onPushState });
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] **Company 1**
@@ -104,18 +106,18 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 2);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 1);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 2);
/**
* [x] **Company 1**
* [x] Company 2 -> toggle
* [ ] Company 3
*/
- await click(scMenu.el.querySelectorAll(".toggle_company")[1]);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 2);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 1);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[1]);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 2);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 1);
await prom;
assert.verifySteps(["cids=1%2C2"]);
});
@@ -129,6 +131,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
prom.resolve();
}
const scMenu = await createSwitchCompanyMenu({ onPushState }, 50);
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] **Company 1**
@@ -137,20 +140,20 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 2);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 1);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 2);
/**
* [ ] **Company 1** -> toggle all
* [x] Company 2 -> toggle all
* [x] Company 3 -> toggle all
*/
- await click(scMenu.el.querySelectorAll(".toggle_company")[0]);
- await click(scMenu.el.querySelectorAll(".toggle_company")[1]);
- await click(scMenu.el.querySelectorAll(".toggle_company")[2]);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 2);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 1);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[0]);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[1]);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[2]);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 2);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 1);
assert.verifySteps([]);
await prom; // await toggle promise
@@ -166,6 +169,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
},
});
const scMenu = await createSwitchCompanyMenu();
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] **Company 1**
@@ -175,21 +179,21 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
assert.deepEqual(scMenu.env.services.router.current.hash, { cids: 1 });
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 2);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 1);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 2);
/**
* [ ] **Company 1** -> toggle off
* [ ] Company 2
* [ ] Company 3
*/
- await click(scMenu.el.querySelectorAll(".toggle_company")[0]);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[0]);
assert.deepEqual(scMenu.env.services.router.current.hash, { cids: 1 });
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-squarqe", 0);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-squarqe", 0);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 3);
});
QUnit.test("single company mode: companies can be logged in", async (assert) => {
@@ -199,6 +203,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
assert.step(url.split("#")[1]);
}
const scMenu = await createSwitchCompanyMenu({ onPushState });
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] **Company 1**
@@ -207,16 +212,16 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 2);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 1);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 2);
/**
* [x] **Company 1**
* [ ] Company 2 -> log into
* [ ] Company 3
*/
- await click(scMenu.el.querySelectorAll(".log_into")[1]);
+ await click(scMenuEl.querySelectorAll(".log_into")[1]);
assert.verifySteps(["cids=2"]);
});
@@ -228,6 +233,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
}
Object.assign(browser.location, { hash: "cids=3%2C1" });
const scMenu = await createSwitchCompanyMenu({ onPushState });
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] Company 1
@@ -236,16 +242,16 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [3, 1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 3);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 2);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 1);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 2);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 1);
/**
* [x] Company 1
* [ ] Company 2 -> log into
* [x] **Company 3**
*/
- await click(scMenu.el.querySelectorAll(".log_into")[1]);
+ await click(scMenuEl.querySelectorAll(".log_into")[1]);
assert.verifySteps(["cids=2%2C3%2C1"]);
});
@@ -257,6 +263,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
}
Object.assign(browser.location, { hash: "cids=2%2C3" });
const scMenu = await createSwitchCompanyMenu({ onPushState });
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [ ] Company 1
@@ -265,16 +272,16 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [2, 3]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 2);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 2);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 1);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 2);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 1);
/**
* [ ] Company 1
* [x] **Company 2**
* [x] Company 3 -> log into
*/
- await click(scMenu.el.querySelectorAll(".log_into")[2]);
+ await click(scMenuEl.querySelectorAll(".log_into")[2]);
assert.verifySteps(["cids=3%2C2"]);
});
@@ -285,6 +292,7 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
assert.step(url.split("#")[1]);
}
const scMenu = await createSwitchCompanyMenu({ onPushState }, 50);
+ const scMenuEl = target.querySelector(".o_burger_menu_companies");
/**
* [x] **Company 1**
@@ -293,18 +301,18 @@ QUnit.module("MobileMobileSwitchCompanyMenu", (hooks) => {
*/
assert.deepEqual(scMenu.env.services.company.allowedCompanyIds, [1]);
assert.strictEqual(scMenu.env.services.company.currentCompany.id, 1);
- assert.containsN(scMenu.el, "[data-company-id]", 3);
- assert.containsN(scMenu.el, "[data-company-id] .fa-check-square", 1);
- assert.containsN(scMenu.el, "[data-company-id] .fa-square-o", 2);
+ assert.containsN(scMenuEl, "[data-company-id]", 3);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-check-square", 1);
+ assert.containsN(scMenuEl, "[data-company-id] .fa-square-o", 2);
/**
* [ ] **Company 1** -> toggled
* [ ] Company 2 -> logged in
* [ ] Company 3 -> toggled
*/
- await click(scMenu.el.querySelectorAll(".toggle_company")[2]);
- await click(scMenu.el.querySelectorAll(".toggle_company")[0]);
- await click(scMenu.el.querySelectorAll(".log_into")[1]);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[2]);
+ await click(scMenuEl.querySelectorAll(".toggle_company")[0]);
+ await click(scMenuEl.querySelectorAll(".log_into")[1]);
assert.verifySteps(["cids=2"]);
});
});
diff --git a/addons/web/static/tests/webclient/navbar_tests.js b/addons/web/static/tests/webclient/navbar_tests.js
index 55cea8160bf..19d499080c0 100644
--- a/addons/web/static/tests/webclient/navbar_tests.js
+++ b/addons/web/static/tests/webclient/navbar_tests.js
@@ -18,18 +18,19 @@ import {
patchWithCleanup,
makeDeferred,
} from "../helpers/utils";
-import { LegacyComponent } from "@web/legacy/legacy_component";
-const { xml } = owl;
+const { Component, xml } = owl;
const systrayRegistry = registry.category("systray");
const serviceRegistry = registry.category("services");
-class MySystrayItem extends LegacyComponent {}
+class MySystrayItem extends Component {}
MySystrayItem.template = xml`
my item`;
let baseConfig;
+let target;
QUnit.module("Navbar", {
async beforeEach() {
+ target = getFixture();
serviceRegistry.add("menu", menuService);
serviceRegistry.add("action", actionService);
serviceRegistry.add("notification", notificationService);
@@ -51,10 +52,9 @@ QUnit.module("Navbar", {
QUnit.test("can be rendered", async (assert) => {
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
+ await mount(NavBar, target, { env });
assert.containsOnce(
- navbar.el,
+ target,
".o_navbar_apps_menu button.dropdown-toggle",
"1 apps menu toggler present"
);
@@ -62,9 +62,8 @@ QUnit.test("can be rendered", async (assert) => {
QUnit.test("dropdown menu can be toggled", async (assert) => {
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
- const dropdown = navbar.el.querySelector(".o_navbar_apps_menu");
+ await mount(NavBar, target, { env });
+ const dropdown = target.querySelector(".o_navbar_apps_menu");
await click(dropdown, "button.dropdown-toggle");
assert.containsOnce(dropdown, ".dropdown-menu");
await click(dropdown, "button.dropdown-toggle");
@@ -81,11 +80,10 @@ QUnit.test("data-menu-xmlid attribute on AppsMenu items", async (assert) => {
5: { id: 5, children: [], name: "Sub menu", appID: 1, xmlid: "menu_5" },
};
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
+ await mount(NavBar, target, { env });
// check apps
- const appsMenu = navbar.el.querySelector(".o_navbar_apps_menu");
+ const appsMenu = target.querySelector(".o_navbar_apps_menu");
await click(appsMenu, "button.dropdown-toggle");
const menuItems = appsMenu.querySelectorAll("a");
assert.strictEqual(
@@ -102,21 +100,20 @@ QUnit.test("data-menu-xmlid attribute on AppsMenu items", async (assert) => {
// check menus
env.services.menu.setCurrentMenu(1);
await nextTick();
- assert.containsOnce(navbar, ".o_menu_sections .dropdown-item[data-menu-xmlid=menu_3]");
+ assert.containsOnce(target, ".o_menu_sections .dropdown-item[data-menu-xmlid=menu_3]");
// check sub menus toggler
- assert.containsOnce(navbar, ".o_menu_sections button.dropdown-toggle[data-menu-xmlid=menu_4]");
+ assert.containsOnce(target, ".o_menu_sections button.dropdown-toggle[data-menu-xmlid=menu_4]");
// check sub menus
- await click(navbar.el.querySelector(".o_menu_sections .dropdown-toggle"));
- assert.containsOnce(navbar, ".o_menu_sections .dropdown-item[data-menu-xmlid=menu_5]");
+ await click(target.querySelector(".o_menu_sections .dropdown-toggle"));
+ assert.containsOnce(target, ".o_menu_sections .dropdown-item[data-menu-xmlid=menu_5]");
});
QUnit.test("navbar can display current active app", async (assert) => {
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
- const dropdown = navbar.el.querySelector(".o_navbar_apps_menu");
+ await mount(NavBar, target, { env });
+ const dropdown = target.querySelector(".o_navbar_apps_menu");
// Open apps menu
await click(dropdown, "button.dropdown-toggle");
assert.containsOnce(
@@ -137,19 +134,18 @@ QUnit.test("navbar can display current active app", async (assert) => {
QUnit.test("navbar can display systray items", async (assert) => {
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
- assert.containsOnce(navbar.el, "li.my-item");
+ await mount(NavBar, target, { env });
+ assert.containsOnce(target, "li.my-item");
});
QUnit.test("navbar can display systray items ordered based on their sequence", async (assert) => {
- class MyItem1 extends LegacyComponent {}
+ class MyItem1 extends Component {}
MyItem1.template = xml`
my item 1`;
- class MyItem2 extends LegacyComponent {}
+ class MyItem2 extends Component {}
MyItem2.template = xml`
my item 2`;
- class MyItem3 extends LegacyComponent {}
+ class MyItem3 extends Component {}
MyItem3.template = xml`
my item 3`;
- class MyItem4 extends LegacyComponent {}
+ class MyItem4 extends Component {}
MyItem4.template = xml`
my item 4`;
clearRegistryWithCleanup(systrayRegistry);
@@ -158,9 +154,8 @@ QUnit.test("navbar can display systray items ordered based on their sequence", a
systrayRegistry.add("addon.myitem3", { Component: MyItem3 }, { sequence: 100 });
systrayRegistry.add("addon.myitem4", { Component: MyItem4 });
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
- const navbar = await mount(NavBar, target, { env });
- const menuSystray = navbar.el.getElementsByClassName("o_menu_systray")[0];
+ await mount(NavBar, target, { env });
+ const menuSystray = target.getElementsByClassName("o_menu_systray")[0];
assert.containsN(menuSystray, "li", 4, "four systray items should be displayed");
assert.strictEqual(menuSystray.innerText, "my item 3\nmy item 4\nmy item 2\nmy item 1");
});
@@ -188,51 +183,50 @@ QUnit.test("can adapt with 'more' menu sections behavior", async (assert) => {
const env = await makeTestEnv(baseConfig);
// Force the parent width, to make this test independent of screen size
- const target = getFixture();
target.style.width = "1080px";
// Set menu and mount
env.services.menu.setCurrentMenu(1);
- const navbar = await mount(MyNavbar, target, { env });
+ await mount(MyNavbar, target, { env });
assert.containsN(
- navbar.el,
+ target,
".o_menu_sections > *:not(.o_menu_sections_more):not(.d-none)",
3,
"should have 3 menu sections displayed (that are not the 'more' menu)"
);
- assert.containsNone(navbar.el, ".o_menu_sections_more", "the 'more' menu should not exist");
+ assert.containsNone(target, ".o_menu_sections_more", "the 'more' menu should not exist");
// Force minimal width and dispatch window resize event
- navbar.el.style.width = "0%";
+ target.style.width = "0%";
window.dispatchEvent(new Event("resize"));
await nextTick();
assert.containsOnce(
- navbar.el,
+ target,
".o_menu_sections > *:not(.d-none)",
"only one menu section should be displayed"
);
assert.containsOnce(
- navbar.el,
+ target,
".o_menu_sections_more:not(.d-none)",
"the displayed menu section should be the 'more' menu"
);
// Open the more menu
- await click(navbar.el, ".o_menu_sections_more .dropdown-toggle");
+ await click(target, ".o_menu_sections_more .dropdown-toggle");
assert.deepEqual(
- [...navbar.el.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
+ [...target.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
["Section 10", "Section 11", "Section 12", "Section 120", "Section 121", "Section 122"],
"'more' menu should contain all hidden sections in correct order"
);
// Reset to full width and dispatch window resize event
- navbar.el.style.width = "100%";
+ target.style.width = "100%";
window.dispatchEvent(new Event("resize"));
await nextTick();
assert.containsN(
- navbar.el,
+ target,
".o_menu_sections > *:not(.o_menu_sections_more):not(.d-none)",
3,
"should have 3 menu sections displayed (that are not the 'more' menu)"
);
- assert.containsNone(navbar.el, ".o_menu_sections_more", "the 'more' menu should not exist");
+ assert.containsNone(target, ".o_menu_sections_more", "the 'more' menu should not exist");
// Check the navbar adaptation calls
assert.verifySteps([
"adapt -> hide 0/3 sections",
@@ -272,13 +266,12 @@ QUnit.test(
baseConfig.serverData.menus = newMenus;
// Force the parent width, to make this test independent of screen size
- const target = getFixture();
target.style.width = "600px";
const env = await makeTestEnv(baseConfig);
const navbar = await mount(MyNavbar, target, { env });
assert.strictEqual(navbar.currentAppSections.length, 0, "0 app sub menus");
- assert.strictEqual(navbar.el.offsetWidth, 600);
+ assert.strictEqual(target.querySelector(".o_navbar").offsetWidth, 600);
assert.strictEqual(adaptCount, 1);
assert.strictEqual(
adaptRenderCount,
@@ -287,10 +280,10 @@ QUnit.test(
);
// Force minimal width and dispatch window resize event
- navbar.el.style.width = "0%";
+ target.querySelector(".o_navbar").style.width = "0%";
window.dispatchEvent(new Event("resize"));
await nextTick();
- assert.strictEqual(navbar.el.offsetWidth, 0);
+ assert.strictEqual(target.querySelector(".o_navbar").offsetWidth, 0);
assert.strictEqual(adaptCount, 2);
assert.strictEqual(
adaptRenderCount,
@@ -315,7 +308,7 @@ QUnit.test(
);
// Force 40% width and dispatch window resize event
- navbar.el.style.width = "40%";
+ target.querySelector(".o_navbar").style.width = "40%";
window.dispatchEvent(new Event("resize"));
await nextTick();
assert.strictEqual(
@@ -331,7 +324,7 @@ QUnit.test(
);
// Reset to full width and dispatch window resize event
- navbar.el.style.width = "100%";
+ target.querySelector(".o_navbar").style.width = "100%";
window.dispatchEvent(new Event("resize"));
await nextTick();
assert.strictEqual(navbar.currentAppSections.length, 3, "still 3 app sub menus");
@@ -373,46 +366,45 @@ QUnit.test("'more' menu sections properly updated on app change", async (assert)
const env = await makeTestEnv(baseConfig);
// Force the parent width, to make this test independent of screen size
- const target = getFixture();
target.style.width = "1080px";
// Set App1 menu and mount
env.services.menu.setCurrentMenu(1);
- const navbar = await mount(NavBar, target, { env });
+ await mount(NavBar, target, { env });
// Force minimal width and dispatch window resize event
- navbar.el.style.width = "0%";
+ target.style.width = "0%";
window.dispatchEvent(new Event("resize"));
await nextTick();
assert.containsOnce(
- navbar.el,
+ target,
".o_menu_sections > *:not(.d-none)",
"only one menu section should be displayed"
);
assert.containsOnce(
- navbar.el,
+ target,
".o_menu_sections_more:not(.d-none)",
"the displayed menu section should be the 'more' menu"
);
// Open the more menu
- await click(navbar.el, ".o_menu_sections_more .dropdown-toggle");
+ await click(target, ".o_menu_sections_more .dropdown-toggle");
assert.deepEqual(
- [...navbar.el.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
+ [...target.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
["Section 10", "Section 11", "Section 12", "Section 120", "Section 121", "Section 122"],
"'more' menu should contain App1 sections"
);
// Close the more menu
- await click(navbar.el, ".o_menu_sections_more .dropdown-toggle");
+ await click(target, ".o_menu_sections_more .dropdown-toggle");
// Set App2 menu
env.services.menu.setCurrentMenu(2);
await nextTick();
// Open the more menu
- await click(navbar.el, ".o_menu_sections_more .dropdown-toggle");
+ await click(target, ".o_menu_sections_more .dropdown-toggle");
assert.deepEqual(
- [...navbar.el.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
+ [...target.querySelectorAll(".dropdown-menu > *")].map((el) => el.textContent),
["Section 20", "Section 21", "Section 22", "Section 220", "Section 221", "Section 222"],
"'more' menu should contain App2 sections"
);
@@ -438,8 +430,6 @@ QUnit.test("Do not execute adapt when navbar is destroyed", async (assert) => {
}
const env = await makeTestEnv(baseConfig);
- const target = getFixture();
-
// Set menu and mount
env.services.menu.setCurrentMenu(1);
const navbar = await mount(MyNavbar, target, { env });
diff --git a/addons/web/static/tests/webclient/webclient_tests.js b/addons/web/static/tests/webclient/webclient_tests.js
index 4395b2bc6fc..764e0b37960 100644
--- a/addons/web/static/tests/webclient/webclient_tests.js
+++ b/addons/web/static/tests/webclient/webclient_tests.js
@@ -13,9 +13,8 @@ import { WebClient } from "@web/webclient/webclient";
import { clearRegistryWithCleanup, makeTestEnv } from "../helpers/mock_env";
import { fakeTitleService } from "../helpers/mock_services";
import { destroy, getFixture, mount, patchWithCleanup, triggerEvent } from "../helpers/utils";
-import { LegacyComponent } from "@web/legacy/legacy_component";
-const { xml } = owl;
+const { Component, xml } = owl;
const mainComponentRegistry = registry.category("main_components");
const serviceRegistry = registry.category("services");
@@ -48,7 +47,7 @@ QUnit.test("can be rendered", async (assert) => {
QUnit.test("can render a main component", async (assert) => {
assert.expect(1);
- class MyComponent extends LegacyComponent {}
+ class MyComponent extends Component {}
MyComponent.template = xml`
MyComponent`;
clearRegistryWithCleanup(mainComponentRegistry);
mainComponentRegistry.add("mycomponent", { Component: MyComponent });
@@ -75,7 +74,7 @@ QUnit.test("control-click propagation stopped on
", async (assert) => {
},
});
- class MyComponent extends LegacyComponent {
+ class MyComponent extends Component {
/** @param {MouseEvent} ev */
onclick(ev) {
assert.step(ev.ctrlKey ? "ctrl-click" : "click");
@@ -89,8 +88,8 @@ QUnit.test("control-click propagation stopped on
", async (assert) => {
// Mount the component as standalone and control-click the
const standaloneComponent = await mount(MyComponent, target, { env });
assert.verifySteps([]);
- await triggerEvent(standaloneComponent.el, "", "click", { ctrlKey: false });
- await triggerEvent(standaloneComponent.el, "", "click", { ctrlKey: true });
+ await triggerEvent(target.querySelector(".MyComponent"), "", "click", { ctrlKey: false });
+ await triggerEvent(target.querySelector(".MyComponent"), "", "click", { ctrlKey: true });
assert.verifySteps(["click", "ctrl-click"]);
destroy(standaloneComponent);