import { describe, test, expect } from "@odoo/hoot";
import {
quickCreateKanbanColumn,
toggleKanbanColumnActions,
mountView,
onRpc,
} from "@web/../tests/web_test_helpers";
import { checkLabels, checkLegend, selectMode } from "@web/../tests/views/graph/graph_test_helpers";
import { defineHelpdeskModels } from "@helpdesk/../tests/helpdesk_test_helpers";
describe.current.tags("desktop");
defineHelpdeskModels();
const kanbanViewArch = `
`;
test("Test group label for empty SLA Deadline in tree", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "list",
groupBy: ["sla_deadline"],
arch: `
`,
});
expect(".o_group_name").toHaveText("Deadline reached (3)");
});
test("Test group label for empty SLA Deadline in kanban", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
groupBy: ["sla_deadline"],
arch: kanbanViewArch,
});
expect(".o_column_title").toHaveCount(1);
});
test("Cannot create group if we are not in tickets of specific helpdesk team", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
arch: kanbanViewArch,
});
expect(".o_kanban_group").toHaveCount(2);
expect(".o_column_quick_create").toHaveCount(0);
});
test("Can create group if we are a specific helpdesk team", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
arch: kanbanViewArch,
context: {
active_model: "helpdesk.team",
active_id: 1,
},
});
expect(".o_kanban_group").toHaveCount(2);
expect(".o_column_quick_create").toHaveCount(1);
await quickCreateKanbanColumn();
expect(".o_column_quick_create input").toHaveCount(1, {
message: "the input should be visible",
});
});
test("Delete a column in grouped on m2o", async (assert) => {
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
arch: kanbanViewArch,
});
onRpc(({ method, model }) => {
if (model === "helpdesk.stage" && method === "action_unlink_wizard") {
expect.step(method);
return {
type: "ir.actions.client",
tag: "reload",
};
}
});
const clickColumnAction = await toggleKanbanColumnActions(1);
await clickColumnAction("Delete");
expect.verifySteps(["action_unlink_wizard"]);
});
test("Test group label for empty SLA Deadline in pivot", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "pivot",
arch: `
`,
});
expect("tr:nth-of-type(2) .o_pivot_header_cell_closed").toHaveText("Deadline reached");
});
test("Test group label for empty SLA Deadline in graph", async () => {
const graph = await mountView({
resModel: "helpdesk.ticket",
type: "graph",
arch: `
`,
searchViewArch: `
`,
groupBy: ["sla_deadline"],
});
expect(".o_helpdesk_ticket_graph_view").toHaveCount(1);
checkLabels(graph, ["Deadline reached"]);
checkLegend(graph, ["Count"]);
await selectMode("pie");
checkLabels(graph, ["Deadline reached"]);
checkLegend(graph, ["Deadline reached"]);
});
test("Prevent helpdesk users from reordering ticket stages", async () => {
onRpc("has_group", (group) => group === "helpdesk.group_helpdesk_user");
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
groupBy: ["stage_id"],
arch: kanbanViewArch,
});
expect(".o_group_draggable").toHaveCount(0);
});
test("Access for helpdesk manager to reordering ticket stages", async () => {
await mountView({
resModel: "helpdesk.ticket",
type: "kanban",
groupBy: ["stage_id"],
arch: kanbanViewArch,
});
expect(".o_group_draggable").toHaveCount(2);
});