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

82 lines
2.6 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 { OrderDetailPanel } from "./OrderDetailPanel";
const order = {
id: "o-1",
orderNumber: "CD-240031",
status: "Ожидает согласования доставки",
deliveryAgreementStatus: "Ожидание ответа",
managerId: "u-manager",
logisticianIds: ["u-logistics"],
assignedDriverId: null,
createdAt: "2026-03-15T08:00:00Z",
scheduledDelivery: "2026-03-16T09:00:00Z",
customer: {
name: "Мария Волкова",
phone: "+7 978 000-12-31",
address: "Симферополь",
messenger: "Телеграм",
},
items: ["Кухня | 1 шт"],
chatMessages: [],
internalMessages: [],
orderNotes: [],
history: [],
};
describe("OrderDetailPanel", () => {
it("keeps the order card read-first without workflow controls", () => {
const markup = renderToStaticMarkup(
<OrderDetailPanel
order={order}
users={[
{ id: "u-manager", name: "Анна Мельник", role: "manager" },
{ id: "u-logistics", name: "Ольга Синицына", role: "logistician" },
]}
/>,
);
expect(markup).toContain("CD-240031");
expect(markup).toContain("Мария Волкова");
expect(markup).toContain("Кухня");
expect(markup).toContain("1 шт");
expect(markup).not.toContain("Назначение водителя");
expect(markup).not.toContain("Изменить статус");
expect(markup).not.toContain("Чат с клиентом");
expect(markup).not.toContain("Команда");
});
it("does not crash when an order contains invalid date strings", () => {
const markup = renderToStaticMarkup(
<OrderDetailPanel
order={{
...order,
createdAt: "2026-03-18T010:00:00Z",
scheduledDelivery: "not-a-date",
orderNotes: [
{
id: "note-1",
authorName: "Анна",
text: "Проверка даты",
createdAt: "broken-date",
},
],
}}
/>,
);
expect(markup).toContain("Не указано");
});
it("does not expose driver assignment or status controls", () => {
const markup = renderToStaticMarkup(<OrderDetailPanel order={order} users={[]} />);
expect(markup).not.toContain("Назначение водителя");
expect(markup).not.toContain("Изменить статус");
expect(markup).not.toContain("Чат с клиентом");
expect(markup).not.toContain("Команда");
});
});