Files
odoo_source/addons/web_tour/static/tests/debug_manager_tests.js
T
Samuel Degueldre 07bbe4e8dc [IMP] test_lint, *: activate no-duplicate-imports eslint rule
*: base_automation, hr, mail, web, web_tour, website_payment

Previously, some modules were imported twice, this increases duplication
and can make refactoring more difficult. This commit enables the
no-duplicate-imports eslint rule and fixes offending modules to remove
duplicates.

closes odoo/odoo#84530

Related: odoo/enterprise#24319
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-02-15 09:26:54 +00:00

68 lines
2.3 KiB
JavaScript

/** @odoo-module **/
import { disableTours } from "@web_tour/debug/debug_manager";
import { hotkeyService } from "@web/core/hotkeys/hotkey_service";
import { ormService } from "@web/core/orm_service";
import { registry } from "@web/core/registry";
import { uiService } from "@web/core/ui/ui_service";
import { click, getFixture, mount } from "@web/../tests/helpers/utils";
import { makeTestEnv } from "@web/../tests/helpers/mock_env";
import { makeFakeLocalizationService, fakeCommandService } from "@web/../tests/helpers/mock_services";
import { DebugMenuParent } from "@web/../tests/core/debug/debug_manager_tests";
const debugRegistry = registry.category("debug");
let target;
QUnit.module("Tours", (hooks) => {
QUnit.module("DebugManager");
hooks.beforeEach(async () => {
target = getFixture();
registry
.category("services")
.add("hotkey", hotkeyService)
.add("ui", uiService)
.add("orm", ormService)
.add("localization", makeFakeLocalizationService())
.add("command", fakeCommandService);
});
QUnit.test("can disable tours", async (assert) => {
debugRegistry.category("default").add("disableTours", disableTours);
const fakeTourService = {
start(env) {
return {
getActiveTours() {
return [{ name: 'a' }, { name: 'b' }];
}
}
},
};
registry.category("services").add("tour", fakeTourService);
const mockRPC = async (route, args) => {
if (args.method === "check_access_rights") {
return Promise.resolve(true);
}
if (args.method === "consume") {
assert.step("consume");
assert.deepEqual(args.args[0], ['a', 'b']);
return Promise.resolve(true);
}
};
const env = await makeTestEnv({ mockRPC });
const debugManager = await mount(DebugMenuParent, target, { env });
await click(debugManager.el.querySelector("button.dropdown-toggle"));
assert.containsOnce(debugManager.el, ".dropdown-item");
await click(debugManager.el.querySelector(".dropdown-item"));
assert.verifySteps(["consume"]);
});
});