mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-22 18:22:00 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
|
|
@ -1,56 +1,82 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { getBasicData } from "@spreadsheet/../tests/utils/data";
|
||||
|
||||
import { getBasicData } from "@spreadsheet/../tests/helpers/data";
|
||||
import { serverState } from "@web/../tests/web_test_helpers";
|
||||
|
||||
export function getMenuServerData() {
|
||||
const serverData = {};
|
||||
serverData.menus = {
|
||||
root: { id: "root", children: [1, 2], name: "root", appID: "root" },
|
||||
1: {
|
||||
id: 1,
|
||||
children: [],
|
||||
name: "menu with xmlid",
|
||||
name: "App_1",
|
||||
appID: 1,
|
||||
xmlid: "test_menu",
|
||||
actionID: "action1",
|
||||
xmlid: "app_1",
|
||||
children: [
|
||||
{
|
||||
id: 11,
|
||||
name: "menu with xmlid",
|
||||
appID: 1,
|
||||
xmlid: "test_menu",
|
||||
actionID: "spreadsheet.action1",
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
name: "menu without xmlid",
|
||||
actionID: "spreadsheet.action1",
|
||||
appID: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
2: { id: 2, children: [], name: "menu without xmlid", appID: 2 },
|
||||
};
|
||||
serverData.actions = {
|
||||
action1: {
|
||||
id: 99,
|
||||
xml_id: "action1",
|
||||
xml_id: "spreadsheet.action1",
|
||||
name: "action1",
|
||||
res_model: "ir.ui.menu",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"]],
|
||||
views: [
|
||||
[false, "list"],
|
||||
[false, "form"],
|
||||
],
|
||||
},
|
||||
action2: {
|
||||
id: 199,
|
||||
xml_id: "spreadsheet.action2",
|
||||
name: "action1",
|
||||
res_model: "ir.ui.menu",
|
||||
type: "ir.actions.act_window",
|
||||
views: [
|
||||
[false, "graph"],
|
||||
[false, "pivot"],
|
||||
],
|
||||
},
|
||||
};
|
||||
serverData.views = {};
|
||||
serverData.views["ir.ui.menu,false,list"] = `<tree></tree>`;
|
||||
serverData.views["ir.ui.menu,false,search"] = `<search></search>`;
|
||||
serverData.models = {
|
||||
...getBasicData(),
|
||||
"ir.ui.menu": {
|
||||
fields: {
|
||||
name: { string: "Name", type: "char" },
|
||||
action: { string: "Action", type: "char" },
|
||||
groups_id: { string: "Groups", type: "many2many", relation: "res.group" },
|
||||
group_ids: { string: "Groups", type: "many2many", relation: "res.group" },
|
||||
},
|
||||
records: [
|
||||
{ id: 1, name: "menu with xmlid", action: "action1", groups_id: [10] },
|
||||
{ id: 2, name: "menu without xmlid", action: "action2", groups_id: [10] },
|
||||
{ id: 11, name: "menu with xmlid", action: "action1", group_ids: [10] },
|
||||
{ id: 12, name: "menu without xmlid", action: "action1", group_ids: [10] },
|
||||
],
|
||||
},
|
||||
"res.users": {
|
||||
fields: {
|
||||
name: { string: "Name", type: "char" },
|
||||
groups_id: { string: "Groups", type: "many2many", relation: "res.group" },
|
||||
group_ids: { string: "Groups", type: "many2many", relation: "res.group" },
|
||||
},
|
||||
records: [
|
||||
{ id: 1, name: "Raoul", groups_id: [10] },
|
||||
{ id: 2, name: "Joseph", groups_id: [] },
|
||||
{
|
||||
id: 1,
|
||||
name: "Raoul",
|
||||
active: true,
|
||||
partner_id: serverState.partnerId,
|
||||
group_ids: [10],
|
||||
},
|
||||
{ id: 2, name: "Joseph", group_ids: [] },
|
||||
],
|
||||
},
|
||||
"res.group": {
|
||||
|
|
@ -58,5 +84,6 @@ export function getMenuServerData() {
|
|||
records: [{ id: 10, name: "test group" }],
|
||||
},
|
||||
};
|
||||
serverState.userId = 1;
|
||||
return serverData;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { Model } from "@odoo/o-spreadsheet";
|
||||
import { defineSpreadsheetModels } from "@spreadsheet/../tests/helpers/data";
|
||||
import { makeSpreadsheetMockEnv } from "@spreadsheet/../tests/helpers/model";
|
||||
|
||||
import { setCellContent } from "@spreadsheet/../tests/helpers/commands";
|
||||
import { getCell, getEvaluatedCell } from "@spreadsheet/../tests/helpers/getters";
|
||||
import { getMenuServerData } from "../menu_data_utils";
|
||||
|
||||
describe.current.tags("headless");
|
||||
defineSpreadsheetModels();
|
||||
|
||||
test("ir.menu linked based on xml id", async function () {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_xml_id/test_menu)");
|
||||
const cell = getCell(model, "A1");
|
||||
const evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
expect(evaluatedCell.value).toBe("label", { message: "The value should be the menu name" });
|
||||
expect(cell.content).toBe("[label](odoo://ir_menu_xml_id/test_menu)", {
|
||||
message: "The content should be the complete markdown link",
|
||||
});
|
||||
expect(evaluatedCell.link.label).toBe("label", {
|
||||
message: "The link label should be the menu name",
|
||||
});
|
||||
expect(evaluatedCell.link.url).toBe("odoo://ir_menu_xml_id/test_menu", {
|
||||
message: "The link url should reference the correct menu",
|
||||
});
|
||||
});
|
||||
|
||||
test("ir.menu linked based on record id", async function () {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/12)");
|
||||
const cell = getCell(model, "A1");
|
||||
const evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
expect(evaluatedCell.value).toBe("label", { message: "The value should be the menu name" });
|
||||
expect(cell.content).toBe("[label](odoo://ir_menu_id/12)", {
|
||||
message: "The content should be the complete markdown link",
|
||||
});
|
||||
expect(evaluatedCell.link.label).toBe("label", {
|
||||
message: "The link label should be the menu name",
|
||||
});
|
||||
expect(evaluatedCell.link.url).toBe("odoo://ir_menu_id/12", {
|
||||
message: "The link url should reference the correct menu",
|
||||
});
|
||||
});
|
||||
|
||||
test("ir.menu linked based on xml id which does not exists", async function () {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_xml_id/does_not_exists)");
|
||||
expect(getCell(model, "A1").content).toBe("[label](odoo://ir_menu_xml_id/does_not_exists)");
|
||||
expect(getEvaluatedCell(model, "A1").value).toBe("#LINK");
|
||||
expect(getEvaluatedCell(model, "A1").message).toBe(
|
||||
"Menu does_not_exists not found. You may not have the required access rights."
|
||||
);
|
||||
});
|
||||
|
||||
test("ir.menu linked based on record id which does not exists", async function () {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/9999)");
|
||||
expect(getCell(model, "A1").content).toBe("[label](odoo://ir_menu_id/9999)");
|
||||
expect(getEvaluatedCell(model, "A1").value).toBe("#LINK");
|
||||
expect(getEvaluatedCell(model, "A1").message).toBe(
|
||||
"Menu 9999 not found. You may not have the required access rights."
|
||||
);
|
||||
});
|
||||
|
||||
test("Odoo link cells can be imported/exported", async function () {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/12)");
|
||||
let cell = getCell(model, "A1");
|
||||
let evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
expect(evaluatedCell.value).toBe("label", { message: "The value should be the menu name" });
|
||||
expect(cell.content).toBe("[label](odoo://ir_menu_id/12)", {
|
||||
message: "The content should be the complete markdown link",
|
||||
});
|
||||
expect(evaluatedCell.link.label).toBe("label", {
|
||||
message: "The link label should be the menu name",
|
||||
});
|
||||
expect(evaluatedCell.link.url).toBe("odoo://ir_menu_id/12", {
|
||||
message: "The link url should reference the correct menu",
|
||||
});
|
||||
const model2 = new Model(model.exportData(), { custom: { env } });
|
||||
cell = getCell(model2, "A1");
|
||||
evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
expect(evaluatedCell.value).toBe("label", { message: "The value should be the menu name" });
|
||||
expect(cell.content).toBe("[label](odoo://ir_menu_id/12)", {
|
||||
message: "The content should be the complete markdown link",
|
||||
});
|
||||
expect(evaluatedCell.link.label).toBe("label", {
|
||||
message: "The link label should be the menu name",
|
||||
});
|
||||
expect(evaluatedCell.link.url).toBe("odoo://ir_menu_id/12", {
|
||||
message: "The link url should reference the correct menu",
|
||||
});
|
||||
});
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
/** @odoo-module */
|
||||
import { spreadsheetLinkMenuCellService } from "@spreadsheet/ir_ui_menu/index";
|
||||
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { actionService } from "@web/webclient/actions/action_service";
|
||||
import { ormService } from "@web/core/orm_service";
|
||||
import { viewService } from "@web/views/view_service";
|
||||
import { menuService } from "@web/webclient/menus/menu_service";
|
||||
import { makeTestEnv } from "@web/../tests/helpers/mock_env";
|
||||
import { setCellContent } from "@spreadsheet/../tests/utils/commands";
|
||||
import { getCell } from "@spreadsheet/../tests/utils/getters";
|
||||
import { getMenuServerData } from "../menu_data_utils";
|
||||
|
||||
const { Model } = spreadsheet;
|
||||
|
||||
function beforeEach() {
|
||||
registry
|
||||
.category("services")
|
||||
.add("menu", menuService)
|
||||
.add("action", actionService)
|
||||
.add("spreadsheetLinkMenuCell", spreadsheetLinkMenuCellService);
|
||||
registry.category("services").add("view", viewService, { force: true }); // #action-serv-leg-compat-js-class
|
||||
registry.category("services").add("orm", ormService, { force: true }); // #action-serv-leg-compat-js-class
|
||||
}
|
||||
|
||||
QUnit.module("spreadsheet > menu link cells", { beforeEach }, () => {
|
||||
QUnit.test("ir.menu linked based on xml id", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { evalContext: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_xml_id/test_menu)");
|
||||
const cell = getCell(model, "A1");
|
||||
assert.equal(cell.evaluated.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_xml_id/test_menu)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(cell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
cell.link.url,
|
||||
"odoo://ir_menu_xml_id/test_menu",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("ir.menu linked based on record id", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { evalContext: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/2)");
|
||||
const cell = getCell(model, "A1");
|
||||
assert.equal(cell.evaluated.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(cell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
cell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("ir.menu linked based on xml id which does not exists", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { evalContext: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_xml_id/does_not_exists)");
|
||||
const cell = getCell(model, "A1");
|
||||
assert.equal(cell.content, "[label](odoo://ir_menu_xml_id/does_not_exists)");
|
||||
assert.equal(cell.evaluated.value, "#BAD_EXPR");
|
||||
});
|
||||
|
||||
QUnit.test("ir.menu linked based on record id which does not exists", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { evalContext: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/9999)");
|
||||
const cell = getCell(model, "A1");
|
||||
assert.equal(cell.content, "[label](odoo://ir_menu_id/9999)");
|
||||
assert.equal(cell.evaluated.value, "#BAD_EXPR");
|
||||
});
|
||||
|
||||
QUnit.test("Odoo link cells can be imported/exported", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { evalContext: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/2)");
|
||||
let cell = getCell(model, "A1");
|
||||
assert.equal(cell.evaluated.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(cell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
cell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
const model2 = new Model(model.exportData(), { evalContext: { env } });
|
||||
cell = getCell(model2, "A1");
|
||||
assert.equal(cell.evaluated.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(cell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
cell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import * as spreadsheet from "@odoo/o-spreadsheet";
|
||||
import { defineSpreadsheetModels } from "@spreadsheet/../tests/helpers/data";
|
||||
import { makeSpreadsheetMockEnv } from "@spreadsheet/../tests/helpers/model";
|
||||
import { makeMockEnv, mockService, patchWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
|
||||
import { getMenuServerData } from "@spreadsheet/../tests/links/menu_data_utils";
|
||||
|
||||
import { setCellContent } from "@spreadsheet/../tests/helpers/commands";
|
||||
import { getEvaluatedCell } from "@spreadsheet/../tests/helpers/getters";
|
||||
|
||||
describe.current.tags("headless");
|
||||
defineSpreadsheetModels();
|
||||
|
||||
const { Model } = spreadsheet;
|
||||
const { urlRepresentation, openLink } = spreadsheet.links;
|
||||
|
||||
test("click a web link", async () => {
|
||||
patchWithCleanup(window, {
|
||||
open: (href) => {
|
||||
expect.step(href.toString());
|
||||
},
|
||||
});
|
||||
const env = await makeMockEnv();
|
||||
const data = {
|
||||
sheets: [
|
||||
{
|
||||
cells: { A1: "[Odoo](https://odoo.com)" },
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = new Model(data, { custom: { env } });
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("https://odoo.com");
|
||||
openLink(cell.link, env);
|
||||
expect.verifySteps(["https://odoo.com"]);
|
||||
});
|
||||
|
||||
test("click a menu link", async () => {
|
||||
const fakeActionService = {
|
||||
doAction(action) {
|
||||
expect.step(action);
|
||||
},
|
||||
// TODO: this is the conversion 1/1 of the old test, where the mock action service didn't contain a loadAction
|
||||
// method, but that's not something that happens in the real world, so we should probably refactor this test
|
||||
loadAction: undefined,
|
||||
};
|
||||
mockService("action", fakeActionService);
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const data = {
|
||||
sheets: [
|
||||
{
|
||||
cells: { A1: "[label](odoo://ir_menu_xml_id/test_menu)" },
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = new Model(data, { custom: { env } });
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("menu with xmlid");
|
||||
openLink(cell.link, env);
|
||||
expect.verifySteps(["spreadsheet.action1"]);
|
||||
});
|
||||
|
||||
test("middle-click a menu link", async () => {
|
||||
mockService("action", {
|
||||
doAction(_, options) {
|
||||
expect.step("doAction");
|
||||
expect(options).toEqual({
|
||||
newWindow: true,
|
||||
});
|
||||
return Promise.resolve(true);
|
||||
},
|
||||
});
|
||||
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const data = {
|
||||
sheets: [
|
||||
{
|
||||
cells: { A1: "[label](odoo://ir_menu_xml_id/test_menu)" },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const model = new Model(data, { custom: { env } });
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("menu with xmlid");
|
||||
openLink(cell.link, env, true);
|
||||
expect.verifySteps(["doAction"]);
|
||||
});
|
||||
|
||||
test("click a menu link [2]", async () => {
|
||||
const fakeActionService = {
|
||||
doAction(action) {
|
||||
expect.step("do-action");
|
||||
expect(action).toEqual({
|
||||
name: "an odoo view",
|
||||
res_model: "partner",
|
||||
target: "current",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"]],
|
||||
});
|
||||
},
|
||||
// TODO: same as the above test
|
||||
loadAction: undefined,
|
||||
};
|
||||
mockService("action", fakeActionService);
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
const view = {
|
||||
name: "an odoo view",
|
||||
viewType: "list",
|
||||
action: {
|
||||
modelName: "partner",
|
||||
views: [[false, "list"]],
|
||||
},
|
||||
};
|
||||
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", `[a view](odoo://view/${JSON.stringify(view)})`);
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("an odoo view");
|
||||
openLink(cell.link, env);
|
||||
expect.verifySteps(["do-action"]);
|
||||
});
|
||||
|
||||
test("Click a link containing an action xml id", async () => {
|
||||
mockService("action", {
|
||||
doAction: (action) => {
|
||||
expect.step("do-action");
|
||||
expect(action.name).toBe("My Action Name");
|
||||
expect(action.res_model).toBe("ir.ui.menu");
|
||||
expect(action.target).toBe("current");
|
||||
expect(action.type).toBe("ir.actions.act_window");
|
||||
expect(action.views).toEqual([[false, "list"]]);
|
||||
expect(action.domain).toEqual([[1, "=", 1]]);
|
||||
},
|
||||
});
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
|
||||
const view = {
|
||||
name: "My Action Name",
|
||||
viewType: "list",
|
||||
action: {
|
||||
modelName: "ir.ui.menu",
|
||||
views: [[false, "list"]],
|
||||
domain: [[1, "=", 1]],
|
||||
xmlId: "spreadsheet.action1",
|
||||
},
|
||||
};
|
||||
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", `[an action link](odoo://view/${JSON.stringify(view)})`);
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("My Action Name");
|
||||
await openLink(cell.link, env);
|
||||
await animationFrame();
|
||||
expect.verifySteps(["do-action"]);
|
||||
});
|
||||
|
||||
test("Can open link when some views are absent from the referred action", async () => {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
env.services.action = {
|
||||
...env.services.action,
|
||||
doAction(action) {
|
||||
expect.step("do-action");
|
||||
expect(action.name).toBe("My Action Name");
|
||||
expect(action.res_model).toBe("ir.ui.menu");
|
||||
expect(action.target).toBe("current");
|
||||
expect(action.type).toBe("ir.actions.act_window");
|
||||
expect(action.views).toEqual([
|
||||
[false, "list"],
|
||||
[false, "form"],
|
||||
]);
|
||||
expect(action.domain).toEqual([(1, "=", 1)]);
|
||||
},
|
||||
};
|
||||
|
||||
const view = {
|
||||
name: "My Action Name",
|
||||
viewType: "list",
|
||||
action: {
|
||||
modelName: "ir.ui.menu",
|
||||
views: [
|
||||
[false, "list"],
|
||||
[false, "form"],
|
||||
],
|
||||
domain: [(1, "=", 1)],
|
||||
xmlId: "spreadsheet.action2",
|
||||
},
|
||||
};
|
||||
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", `[an action link](odoo://view/${JSON.stringify(view)})`);
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("My Action Name");
|
||||
await openLink(cell.link, env);
|
||||
await animationFrame();
|
||||
expect.verifySteps(["do-action"]);
|
||||
});
|
||||
|
||||
test("Context is passed correctly to the action service", async () => {
|
||||
const env = await makeSpreadsheetMockEnv({ serverData: getMenuServerData() });
|
||||
env.services.action = {
|
||||
...env.services.action,
|
||||
loadAction(_, context) {
|
||||
expect.step("load-action");
|
||||
expect(context).toEqual({ search_default_partner: 1 });
|
||||
},
|
||||
};
|
||||
|
||||
const view = {
|
||||
name: "My Action Name",
|
||||
viewType: "list",
|
||||
action: {
|
||||
modelName: "ir.ui.menu",
|
||||
views: [[false, "list"]],
|
||||
domain: [(1, "=", 1)],
|
||||
xmlId: "spreadsheet.action1",
|
||||
context: { search_default_partner: 1 },
|
||||
},
|
||||
};
|
||||
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", `[an action link](odoo://view/${JSON.stringify(view)})`);
|
||||
const cell = getEvaluatedCell(model, "A1");
|
||||
expect(urlRepresentation(cell.link, model.getters)).toBe("My Action Name");
|
||||
await openLink(cell.link, env);
|
||||
await animationFrame();
|
||||
expect.verifySteps(["load-action"]);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue