supersam/src/components/orders/OrdersKanbanBoard.test.jsx

87 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { OrdersKanbanBoard } from "./OrdersKanbanBoard";
const kanbanColumns = [
{
key: "logistics",
title: "Логистика",
stageKey: "logistics",
statuses: ["Ожидает согласования доставки", "Проблема доставки"],
warningCount: 1,
criticalCount: 1,
items: [
{
id: "1",
orderNumber: "CD-240031",
customer: { name: "Мария Волкова", address: "Симферополь, ул. Тургенева, 18" },
items: ["Кухня | 1 шт"],
status: "Ожидает согласования доставки",
ownerRole: "logistician",
stageLabel: "Логистика",
agingState: "warning",
statusAgeLabel: "2д в статусе",
},
{
id: "2",
orderNumber: "CD-240033",
customer: { name: "Александр Савин", address: "Ялта, ул. Чехова, 9" },
items: ["Стеклопакет | 2 шт"],
status: "Проблема доставки",
ownerRole: "logistician",
stageLabel: "Логистика",
agingState: "critical",
statusAgeLabel: "3д в статусе",
},
],
},
];
describe("OrdersKanbanBoard", () => {
it("renders mode switch, responsibility marker and stalled labels", () => {
const markup = renderToStaticMarkup(
<OrdersKanbanBoard
columns={kanbanColumns}
currentMode="by_stage"
departmentFilter="all"
notice={{
tone: "warning",
title: "Перенос недоступен",
description: "Сначала назначьте водителя, потом заказ можно передать в доставку.",
}}
onDepartmentFilterChange={() => {}}
onModeChange={() => {}}
onOpenOrder={() => {}}
onDragStart={() => {}}
onDragEnd={() => {}}
onDropColumn={() => {}}
dropColumnKey={null}
/>,
);
expect(markup).toContain("По этапам");
expect(markup).toContain("По статусам");
expect(markup).toContain("Все отделы");
expect(markup).toContain("Зависают: 1");
expect(markup).toContain("Просрочено: 1");
expect(markup).toContain("Логистика");
expect(markup).toContain("2д в статусе");
expect(markup).toContain("3д в статусе");
expect(markup).toContain("Симферополь");
expect(markup).toContain("Ялта");
expect(markup).toContain("data-stage=\"logistics\"");
expect(markup).toContain("bg-[rgba(18,128,92,0.09)]");
expect(markup).toContain("overflow-x-auto");
expect(markup).toContain("max-w-full");
expect(markup).toContain("w-[280px]");
expect(markup).toContain("aria-label=\"Прокрутить канбан влево\"");
expect(markup).toContain("aria-label=\"Прокрутить канбан вправо\"");
expect(markup).toContain("Канбан-лента");
expect(markup).toContain("Перенос недоступен");
expect(markup).toContain("Сначала назначьте водителя");
expect(markup).not.toContain(">Логист<");
expect(markup).not.toContain("Кухня");
});
});