mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
|
|
import { fireEvent, screen } from "@testing-library/react";
|
||
|
|
import { describe, expect, it, vi } from "vitest";
|
||
|
|
import { DuplicateWoNumberDialog } from "@/app/(protected)/workorders/_components/list/duplicate-wo-number-dialog";
|
||
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
||
|
|
import { renderWithProviders } from "@/test/test-utils";
|
||
|
|
|
||
|
|
const existingRow = { id: "wo-99", woNumber: "12345678901" } as WorkOrderTableRow;
|
||
|
|
|
||
|
|
describe("DuplicateWoNumberDialog", () => {
|
||
|
|
it("shows the duplicate title and work order number when open", () => {
|
||
|
|
renderWithProviders(
|
||
|
|
<DuplicateWoNumberDialog
|
||
|
|
open
|
||
|
|
existing={existingRow}
|
||
|
|
onDismiss={vi.fn()}
|
||
|
|
onViewExisting={vi.fn()}
|
||
|
|
/>,
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
||
|
|
expect(screen.getByText("Duplicate Work Order Number")).toBeInTheDocument();
|
||
|
|
expect(screen.getByText(/12345678901/)).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it("calls onViewExisting when View existing is clicked", () => {
|
||
|
|
const onViewExisting = vi.fn();
|
||
|
|
|
||
|
|
renderWithProviders(
|
||
|
|
<DuplicateWoNumberDialog
|
||
|
|
open
|
||
|
|
existing={existingRow}
|
||
|
|
onDismiss={vi.fn()}
|
||
|
|
onViewExisting={onViewExisting}
|
||
|
|
/>,
|
||
|
|
);
|
||
|
|
|
||
|
|
fireEvent.click(screen.getByRole("button", { name: "View existing" }));
|
||
|
|
|
||
|
|
expect(onViewExisting).toHaveBeenCalledWith(existingRow);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("calls onDismiss when Dismiss is clicked", () => {
|
||
|
|
const onDismiss = vi.fn();
|
||
|
|
|
||
|
|
renderWithProviders(
|
||
|
|
<DuplicateWoNumberDialog
|
||
|
|
open
|
||
|
|
existing={existingRow}
|
||
|
|
onDismiss={onDismiss}
|
||
|
|
onViewExisting={vi.fn()}
|
||
|
|
/>,
|
||
|
|
);
|
||
|
|
|
||
|
|
fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));
|
||
|
|
|
||
|
|
expect(onDismiss).toHaveBeenCalledTimes(1);
|
||
|
|
});
|
||
|
|
});
|