mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 05:33:14 +00:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { fireEvent, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { ServiceNotesDialog } from "@/app/(protected)/workorders/_components/list/table/cells/service-notes-dialog";
|
|
import { SiteDialog } from "@/app/(protected)/workorders/_components/list/table/cells/site-dialog";
|
|
import { renderWithProviders } from "@/test/test-utils";
|
|
|
|
describe("Completed view-only dialogs", () => {
|
|
it("hides Save on a view-only site dialog", () => {
|
|
const onSave = vi.fn();
|
|
|
|
renderWithProviders(
|
|
<SiteDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
value="BK5"
|
|
locationId="loc-1"
|
|
sites={[{ id: "loc-1", name: "BK5" }]}
|
|
viewOnly
|
|
onSave={onSave}
|
|
/>,
|
|
{ withAuth: false },
|
|
);
|
|
|
|
expect(screen.getByRole("button", { name: /^close$/i })).toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: /^save$/i })).not.toBeInTheDocument();
|
|
fireEvent.click(screen.getByRole("button", { name: /^close$/i }));
|
|
expect(onSave).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("hides Save on a view-only service notes dialog", () => {
|
|
const onSave = vi.fn();
|
|
|
|
renderWithProviders(
|
|
<ServiceNotesDialog
|
|
open
|
|
onOpenChange={vi.fn()}
|
|
pm="HVAC"
|
|
extraServices={[]}
|
|
serviceNotes="Check filters"
|
|
pmTypes={["HVAC"]}
|
|
viewOnly
|
|
onSave={onSave}
|
|
/>,
|
|
{ withAuth: false },
|
|
);
|
|
|
|
expect(screen.getByRole("button", { name: /^close$/i })).toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: /^save$/i })).not.toBeInTheDocument();
|
|
});
|
|
});
|