mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 17:02:05 +00:00
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { createRef } from "react";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { CompDocDialogFooter } from "@/app/(protected)/workorders/_components/comp-doc/comp-doc-dialog-footer";
|
|
|
|
describe("CompDocDialogFooter exclusive states", () => {
|
|
const pdfInputRef = createRef<HTMLInputElement | null>();
|
|
const handlers = {
|
|
onMarkNotRequired: vi.fn(),
|
|
onSaveDraft: vi.fn(),
|
|
onGenerate: vi.fn(),
|
|
onUndo: vi.fn(),
|
|
onDownloadPdf: vi.fn(),
|
|
onUploadPdf: vi.fn(),
|
|
};
|
|
|
|
it("does not render draft actions when a signed PDF is on file while docState is still draft", () => {
|
|
render(
|
|
<CompDocDialogFooter
|
|
docState="draft"
|
|
isDocumentsReadOnly={false}
|
|
rowVersion="1"
|
|
isUploading={false}
|
|
signOffAttachment="https://example.com/doc.pdf"
|
|
generatedAt=""
|
|
pdfInputRef={pdfInputRef}
|
|
{...handlers}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.queryByRole("button", { name: /save draft/i })).not.toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: /mark as not required/i })).not.toBeInTheDocument();
|
|
expect(screen.getByText(/document on file/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders only draft actions for a clean draft without attachment", () => {
|
|
render(
|
|
<CompDocDialogFooter
|
|
docState="draft"
|
|
isDocumentsReadOnly={false}
|
|
rowVersion="1"
|
|
isUploading={false}
|
|
signOffAttachment={null}
|
|
generatedAt=""
|
|
pdfInputRef={pdfInputRef}
|
|
{...handlers}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole("button", { name: /save draft/i })).toBeInTheDocument();
|
|
expect(screen.queryByText(/document on file/i)).not.toBeInTheDocument();
|
|
});
|
|
});
|