Before this commit the doAction method of the action_service did not support
to pass props directly to the Component. Only a few ad-hoc options were passed though.
After this commit, doAction can take a key "props" in options, that will be passed to the Component
(a View or a ClientAction)
the new API becomes
```ts
interface Options {
props: { [key: string]: any };
...
}
doAction(action: ActionRequest, options: Options);
Note that some props (like withFilters) are set by the action service
and cannot be set via the key "props".
Alongside the change mentioned above, we take the opportunity to align the
terminology used in action service to the one used server side: we know use
the terms resModel, resId, and resIds instead of model, recordId, and recordIds.
```
closes odoo/odoo#72397
Related: odoo/enterprise#19127
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import { manageMessages } from "@mail/js/tools/debug_manager";
|
|
import { click, legacyExtraNextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
|
|
import { createWebClient, doAction, getActionManagerServerData } from "@web/../tests/webclient/helpers";
|
|
import { debugService } from "@web/core/debug/debug_service";
|
|
import { registry } from "@web/core/registry";
|
|
|
|
QUnit.module("DebugMenu");
|
|
|
|
QUnit.test("Manage Messages", async function (assert) {
|
|
assert.expect(6);
|
|
|
|
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/>`,
|
|
});
|
|
|
|
// Activate debug service with "Manage Message" item
|
|
registry.category("services").add("debug", debugService);
|
|
registry.category("debug").category("form").add("manageMessages", manageMessages);
|
|
|
|
async function mockRPC(route, args) {
|
|
if (args.method === "check_access_rights") {
|
|
return true;
|
|
}
|
|
if (route === "/web/dataset/search_read" && args.model === "mail.message") {
|
|
assert.strictEqual(args.context.default_res_id, 5);
|
|
assert.strictEqual(args.context.default_res_model, "partner");
|
|
assert.deepEqual(args.domain, ["&", ["res_id", "=", 5], ["model", "=", "partner"]]);
|
|
}
|
|
}
|
|
|
|
const wc = await createWebClient({ serverData, mockRPC });
|
|
await doAction(wc, 3, { viewType: "form", props: { resId: 5 } });
|
|
await legacyExtraNextTick();
|
|
await click(wc.el, ".o_debug_manager .o_dropdown_toggler");
|
|
|
|
const dropdownItems = wc.el.querySelectorAll(
|
|
".o_debug_manager .o_dropdown_menu .o_dropdown_item"
|
|
);
|
|
assert.strictEqual(dropdownItems.length, 1);
|
|
assert.strictEqual(
|
|
dropdownItems[0].innerText.trim(),
|
|
"Manage Messages",
|
|
"should have correct menu item text"
|
|
);
|
|
|
|
await click(dropdownItems[0]);
|
|
await legacyExtraNextTick();
|
|
|
|
assert.strictEqual(
|
|
wc.el.querySelector(".breadcrumb-item.active").innerText.trim(),
|
|
"Manage Messages"
|
|
);
|
|
});
|