[FIX] spreadsheet: don't use constant uid in tests

Most tests that need the user id simply use `uid=7`, which will fail
if the default user id ever change in the tests. This commit replaces
it by `sessuin.user_context.uid`.

closes odoo/odoo#138733

Task: 3553122
Related: odoo/enterprise#48965
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit is contained in:
Adrien Minne (adrm)
2023-10-23 20:07:26 +00:00
parent 0d9e4804b1
commit 783a1dfeba
3 changed files with 7 additions and 3 deletions
@@ -8,6 +8,7 @@ import { createSpreadsheetWithChart, insertChartInSpreadsheet } from "../../util
import { createModelWithDataSource, waitForDataSourcesLoaded } from "../../utils/model";
import * as spreadsheet from "@odoo/o-spreadsheet";
import { makeServerError } from "@web/../tests/helpers/mock_server";
import { session } from "@web/session";
const { toZone } = spreadsheet.helpers;
@@ -216,6 +217,7 @@ QUnit.module("spreadsheet > odoo chart plugin", {}, () => {
QUnit.test("can import (export) contextual domain", async function (assert) {
const chartId = "1";
const uid = session.user_context.uid;
const spreadsheetData = {
sheets: [
{
@@ -251,7 +253,7 @@ QUnit.module("spreadsheet > odoo chart plugin", {}, () => {
spreadsheetData,
mockRPC: function (route, args) {
if (args.method === "web_read_group") {
assert.deepEqual(args.kwargs.domain, [["foo", "=", 7]]);
assert.deepEqual(args.kwargs.domain, [["foo", "=", uid]]);
assert.step("web_read_group");
}
},
@@ -583,6 +583,7 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
);
QUnit.test("can import (export) contextual domain", async function (assert) {
const uid = session.user_context.uid;
const spreadsheetData = {
lists: {
1: {
@@ -598,7 +599,7 @@ QUnit.module("spreadsheet > list plugin", {}, () => {
spreadsheetData,
mockRPC: function (route, args) {
if (args.method === "search_read") {
assert.deepEqual(args.kwargs.domain, [["foo", "=", 7]]);
assert.deepEqual(args.kwargs.domain, [["foo", "=", uid]]);
assert.step("search_read");
}
},
@@ -537,6 +537,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
});
QUnit.test("can import (export) contextual domain", async (assert) => {
const uid = session.user_context.uid;
const spreadsheetData = {
pivots: {
1: {
@@ -554,7 +555,7 @@ QUnit.module("spreadsheet > pivot plugin", {}, () => {
spreadsheetData,
mockRPC: function (route, args) {
if (args.method === "read_group") {
assert.deepEqual(args.kwargs.domain, [["foo", "=", 7]]);
assert.deepEqual(args.kwargs.domain, [["foo", "=", uid]]);
assert.step("read_group");
}
},