[FIX] spreadsheet: Fix bad serverData in js tests
The menus added in the server data which are used in mockServer did not reflect a realistic menu configuration. This was brought to light when trying to fix the addition of links to ir.ui.menu inside a spreadsheet. See task 2821480 Related ENT pr: https://github.com/odoo/enterprise/pull/42885 closes odoo/odoo#126497 X-original-commit: 128475e8c29f8493b01710342179a5c468897c61 Related: odoo/enterprise#43209 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
@@ -2,20 +2,26 @@
|
||||
|
||||
import { getBasicData } from "@spreadsheet/../tests/utils/data";
|
||||
|
||||
|
||||
export function getMenuServerData() {
|
||||
const serverData = {};
|
||||
serverData.menus = {
|
||||
root: { id: "root", children: [1, 2], name: "root", appID: "root" },
|
||||
root: { id: "root", children: [1], name: "root", appID: "root" },
|
||||
1: {
|
||||
id: 1,
|
||||
children: [11, 12],
|
||||
name: "App_1",
|
||||
appID: 1,
|
||||
xmlid: "app_1",
|
||||
},
|
||||
11: {
|
||||
id: 11,
|
||||
children: [],
|
||||
name: "menu with xmlid",
|
||||
appID: 1,
|
||||
xmlid: "test_menu",
|
||||
actionID: "action1",
|
||||
},
|
||||
2: { id: 2, children: [], name: "menu without xmlid", appID: 2 },
|
||||
12: { id: 12, children: [], name: "menu without xmlid", actionID: "action1", appID: 1 },
|
||||
};
|
||||
serverData.actions = {
|
||||
action1: {
|
||||
@@ -39,8 +45,8 @@ export function getMenuServerData() {
|
||||
groups_id: { 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", groups_id: [10] },
|
||||
{ id: 12, name: "menu without xmlid", action: "action1", groups_id: [10] },
|
||||
],
|
||||
},
|
||||
"res.users": {
|
||||
|
||||
@@ -41,19 +41,19 @@ QUnit.module("spreadsheet > menu link cells", { beforeEach }, () => {
|
||||
QUnit.test("ir.menu linked based on record id", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/2)");
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/12)");
|
||||
const cell = getCell(model, "A1");
|
||||
const evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
assert.equal(evaluatedCell.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"[label](odoo://ir_menu_id/12)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(evaluatedCell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
evaluatedCell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"odoo://ir_menu_id/12",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
});
|
||||
@@ -88,19 +88,19 @@ QUnit.module("spreadsheet > menu link cells", { beforeEach }, () => {
|
||||
QUnit.test("Odoo link cells can be imported/exported", async function (assert) {
|
||||
const env = await makeTestEnv({ serverData: getMenuServerData() });
|
||||
const model = new Model({}, { custom: { env } });
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/2)");
|
||||
setCellContent(model, "A1", "[label](odoo://ir_menu_id/12)");
|
||||
let cell = getCell(model, "A1");
|
||||
let evaluatedCell = getEvaluatedCell(model, "A1");
|
||||
assert.equal(evaluatedCell.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"[label](odoo://ir_menu_id/12)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(evaluatedCell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
evaluatedCell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"odoo://ir_menu_id/12",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
const model2 = new Model(model.exportData(), { custom: { env } });
|
||||
@@ -109,13 +109,13 @@ QUnit.module("spreadsheet > menu link cells", { beforeEach }, () => {
|
||||
assert.equal(evaluatedCell.value, "label", "The value should be the menu name");
|
||||
assert.equal(
|
||||
cell.content,
|
||||
"[label](odoo://ir_menu_id/2)",
|
||||
"[label](odoo://ir_menu_id/12)",
|
||||
"The content should be the complete markdown link"
|
||||
);
|
||||
assert.equal(evaluatedCell.link.label, "label", "The link label should be the menu name");
|
||||
assert.equal(
|
||||
evaluatedCell.link.url,
|
||||
"odoo://ir_menu_id/2",
|
||||
"odoo://ir_menu_id/12",
|
||||
"The link url should reference the correct menu"
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user