import { beforeEach, describe, expect, test } from "@odoo/hoot";
import { click, edit, press } from "@odoo/hoot-dom";
import { animationFrame } from "@odoo/hoot-mock";
import { contains, mailModels } from "@mail/../tests/mail_test_helpers";
import { ProjectProject, defineProjectModels } from "@project/../tests/project_models";
import { onRpc, removeFacet } from "@web/../tests/web_test_helpers";
import { getGridContent, mountGanttView } from "@web_gantt/../tests/web_gantt_test_helpers";
import { ProjectTask } from "./task_gant_model";
defineProjectModels();
describe.current.tags("desktop");
beforeEach(() => {
mailModels.ResUsers._records = [
{ id: 1, name: "User1" },
{ id: 2, name: "User2" },
...mailModels.ResUsers._records,
];
ProjectProject._records = [
{ id: 1, name: "service" },
{ id: 2, name: "sign" },
];
ProjectTask._records = [
{
id: 1,
name: "Task 1",
planned_date_begin: "2019-03-12 06:30:00",
date_deadline: "2019-03-12 12:30:00",
project_id: 1,
user_ids: [1],
planning_overlap: "Task 1 has 1 tasks at the same time.",
},
{
id: 2,
name: "Task 2",
planned_date_begin: "2019-03-12 06:30:00",
date_deadline: "2019-03-12 12:30:00",
project_id: 1,
user_ids: [1],
planning_overlap: "Task 2 has 1 tasks at the same time.",
},
{
id: 3,
name: "Task 3",
planned_date_begin: "2019-03-11 10:30:00",
date_deadline: "2019-03-11 12:30:00",
project_id: 1,
user_ids: [2],
},
{
id: 4,
name: "Task 4",
planned_date_begin: "2019-03-14 10:30:00",
date_deadline: "2019-03-14 12:30:00",
project_id: 2,
user_ids: [2],
},
{
id: 5,
name: "Task 5",
planned_date_begin: "2019-03-13 10:30:00",
date_deadline: "2019-03-13 12:30:00",
project_id: 2,
},
];
});
test("Unassigned tasks will show when search for assignee", async () => {
onRpc("project.task", "get_gantt_data", ({ kwargs }) => {
kwargs.domain = (kwargs.domain || []).map((d) =>
Array.isArray(d) && d.length === 3 && d[0] === "user_ids.name"
? ["user_ids", "=", 1]
: d
);
});
await mountGanttView({
resModel: "project.task",
type: "gantt",
arch: `