supersam/src/components/client/DeliveryChoiceFlow.test.jsx

106 lines
3.7 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 { DeliveryChoiceFlow } from "./DeliveryChoiceFlow";
describe("DeliveryChoiceFlow", () => {
it("renders the active delivery choice with half-day actions", () => {
const markup = renderToStaticMarkup(
<DeliveryChoiceFlow
invitation={{
state: "awaiting_choice",
orderNumber: "CD-240031",
customerName: "Мария Волкова",
availableSlots: ["Первая половина дня", "Вторая половина дня"],
}}
onConfirmChoice={() => {}}
onRequestNewLink={() => {}}
/>,
);
expect(markup).toContain("Выберите время доставки");
expect(markup).toContain("Первая половина дня");
expect(markup).toContain("Вторая половина дня");
expect(markup).toContain("Ожидает ответа клиента");
});
it("renders order items with quantities when they are provided", () => {
const markup = renderToStaticMarkup(
<DeliveryChoiceFlow
invitation={{
state: "awaiting_choice",
orderNumber: "CD-240031",
customerName: "Мария Волкова",
orderItems: [
{ name: "Кухонный гарнитур", quantity: "1 комплект" },
{ name: "Фурнитура Blum", quantity: "12 шт" },
{ name: "Монтажный комплект" },
],
availableSlots: ["Первая половина дня", "Вторая половина дня"],
}}
onConfirmChoice={() => {}}
onRequestNewLink={() => {}}
/>,
);
expect(markup).toContain("Состав заказа");
expect(markup).toContain("Кухонный гарнитур");
expect(markup).toContain("1 комплект");
expect(markup).toContain("Фурнитура Blum");
expect(markup).toContain("12 шт");
expect(markup).toContain("Монтажный комплект");
});
it("renders a logistics notice when the order is transferred", () => {
const markup = renderToStaticMarkup(
<DeliveryChoiceFlow
invitation={{
state: "transferred_to_logistics",
orderNumber: "CD-240031",
customerName: "Мария Волкова",
}}
onConfirmChoice={() => {}}
onRequestNewLink={() => {}}
/>,
);
expect(markup).toContain("С вами свяжется логист");
expect(markup).not.toContain("Выберите время доставки");
});
it("renders a paid storage notice when delivery is not coordinated", () => {
const markup = renderToStaticMarkup(
<DeliveryChoiceFlow
invitation={{
state: "paid_storage",
orderNumber: "CD-240031",
customerName: "Мария Волкова",
}}
onConfirmChoice={() => {}}
onRequestNewLink={() => {}}
/>,
);
expect(markup).toContain("Платное хранение");
expect(markup).toContain("Заказ переведен на платное хранение");
});
it("renders awaiting choice state with slot info", () => {
const markup = renderToStaticMarkup(
<DeliveryChoiceFlow
invitation={{
state: "opened",
orderNumber: "CD-240032",
customerName: "Александр Савин",
availableSlots: ["15 апреля, первая половина дня"],
}}
onConfirmChoice={() => {}}
onRequestNewLink={() => {}}
/>,
);
expect(markup).toContain("CD-240032");
expect(markup).toContain("Александр Савин");
});
});