Files
odoo_source/addons/mail/static/tests/web/debug_menu_tests.js
T
Sébastien Theys 9dba4e0d77 [REF] mail, *: reorganize JS files
Remove "fake" feature sub-folders that make files harder to find.

Note: If there are too many files in the main folder now, a new split
that actually makes sense can be done at a later time: this would not
just be code move, but removing coupling between said feature and the
rest of the code.

Apply consistent structure, where the top level folder is a feature (or
core), and sub-folders are subdivision of the feature depending on
context (closely related to assets bundles).

```
- core
    - common
    - public
    - web
- feature
    - common
    - public
    - web
```

The opportunity is taken to reorganize the top of the files and imports:
- Always use absolute path in imports to be able to find all usages of a
  file with a single search.
- Reorganize imports to group them by module, and to sort them
  alphabetically by path/feature.
- Always use single asterisk (*) for `odoo-module`: less characters yay!
  And double asterisk should be used for JSDoc comments, not for custom
  instructions.

Part of task-3265211

closes odoo/odoo#124168

Related: odoo/enterprise#42121
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-06-08 21:52:44 +02:00

63 lines
2.2 KiB
JavaScript

/* @odoo-module */
import { manageMessages } from "@mail/js/tools/debug_manager";
import { registry } from "@web/core/registry";
import {
click,
getFixture,
legacyExtraNextTick,
patchWithCleanup,
} from "@web/../tests/helpers/utils";
import {
createWebClient,
doAction,
getActionManagerServerData,
} from "@web/../tests/webclient/helpers";
QUnit.module("debug menu");
QUnit.test("Manage Messages", async (assert) => {
patchWithCleanup(odoo, { debug: "1" });
const serverData = getActionManagerServerData();
// Add fake "mail.message" model and arch
serverData.models["mail.message"] = {
fields: { name: { string: "Name", type: "char" } },
records: [],
};
Object.assign(serverData.views, {
"mail.message,false,list": "<tree/>",
"mail.message,false,form": "<form/>",
"mail.message,false,search": "<search/>",
});
registry.category("debug").category("form").add("manageMessages", manageMessages);
async function mockRPC(route, { method, model, kwargs }) {
if (method === "check_access_rights") {
return true;
}
if (method === "web_search_read" && model === "mail.message") {
assert.step("message_read");
const { context, domain } = kwargs;
assert.strictEqual(context.default_res_id, 5);
assert.strictEqual(context.default_res_model, "partner");
assert.deepEqual(domain, ["&", ["res_id", "=", 5], ["model", "=", "partner"]]);
}
}
const target = getFixture();
const wc = await createWebClient({ serverData, mockRPC });
await doAction(wc, 3, { viewType: "form", props: { resId: 5 } });
await legacyExtraNextTick();
await click(target, ".o_debug_manager .dropdown-toggle");
const dropdownItems = target.querySelectorAll(".o_debug_manager .dropdown-menu .dropdown-item");
assert.strictEqual(dropdownItems.length, 1);
assert.strictEqual(dropdownItems[0].innerText.trim(), "Manage Messages");
await click(dropdownItems[0]);
await legacyExtraNextTick();
assert.verifySteps(["message_read"]);
assert.strictEqual(
target.querySelector(".o_breadcrumb .active > span").innerText.trim(),
"Manage Messages"
);
});