This commit adapts the code in addons w.r.t. the introduction of the RelationalModel. Main changes that were requested are: - record datapoints no longer always have an "id" key in their data (they still do if the id field is in the view), so we use record.resId instead - the new model is based on fined-grained reactivity, so several components that previously relied on onWillUpdateProps to update their internal state no longer worked. Typically, using the hook "observeRecord" is the way to go now. - specialdata are no longer handled in the model, so the components needing specialData can use the hook "useSpecialData" - more generally, all overrides of models (RelationalModel or KanbanModel) needed to be reworked. Part of task~3179751 Part-of: odoo/odoo#114024 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: FrancoisGe <fge@odoo.com> Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com> Co-authored-by: Pierre Rousseau <pro@odoo.com>
63 lines
2.2 KiB
JavaScript
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 === "unity_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"
|
|
);
|
|
});
|