shoc-frontend-new/src/test/app/(protected)/workorders/comp-doc-dialog-footer-exclusive.test.tsx
Arthur Bassi d72be8c505 fix(work-orders): use local calendar day for slide-over completedDate
[recover] remove malicious eslint payload (was 6a278c01)
2026-08-10 17:12:13 -03:00

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();
});
});