From 7b5f1df3d1224378fe5ca0fed0589d653437623e Mon Sep 17 00:00:00 2001 From: "Rmi Rahir (rar)" Date: Thu, 22 Jun 2023 11:50:49 +0000 Subject: [PATCH] [FIX] spreadsheet: Fix bad serverData in js tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../static/tests/links/menu_data_utils.js | 16 +++++++++++----- .../tests/links/model/link_menu_cells_test.js | 16 ++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/addons/spreadsheet/static/tests/links/menu_data_utils.js b/addons/spreadsheet/static/tests/links/menu_data_utils.js index 846bd8b8487..acb687e4e12 100644 --- a/addons/spreadsheet/static/tests/links/menu_data_utils.js +++ b/addons/spreadsheet/static/tests/links/menu_data_utils.js @@ -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": { diff --git a/addons/spreadsheet/static/tests/links/model/link_menu_cells_test.js b/addons/spreadsheet/static/tests/links/model/link_menu_cells_test.js index 257233d3353..4133a3d25fc 100644 --- a/addons/spreadsheet/static/tests/links/model/link_menu_cells_test.js +++ b/addons/spreadsheet/static/tests/links/model/link_menu_cells_test.js @@ -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" ); });