Skip to content

Commit 58aebc4

Browse files
nunesmlucasLucas Nunes
andauthored
DEMOS-2256 - Remove BN Attestation Dialog from Final Budget Neutrality Formulation Workbook (#1456)
DEMOS-2256 Co-authored-by: Lucas Nunes <lucas.nunes@icf.com>
1 parent 364ff20 commit 58aebc4

2 files changed

Lines changed: 43 additions & 23 deletions

File tree

client/src/components/dialog/document/DocumentDialog.test.tsx

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,21 @@ describe("checkFormHasChanges", () => {
6060
});
6161

6262
describe("documentTypeRequiresAttestation", () => {
63-
it("requires attestation for BN notebook document types", () => {
64-
expect(documentTypeRequiresAttestation("Final Budget Neutrality Formulation Workbook")).toBe(
65-
true
66-
);
63+
it("requires attestation for the BN Workbook document type", () => {
6764
expect(documentTypeRequiresAttestation("BN Workbook")).toBe(true);
6865
});
6966

7067
it("does not require attestation for other document types", () => {
68+
expect(documentTypeRequiresAttestation("Final Budget Neutrality Formulation Workbook")).toBe(
69+
false
70+
);
7171
expect(documentTypeRequiresAttestation("General File")).toBe(false);
7272
expect(documentTypeRequiresAttestation("Approval Letter")).toBe(false);
7373
});
7474
});
7575

7676
const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
77+
const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
7778

7879
const renderAddDialog = (
7980
documentType: DocumentType,
@@ -96,12 +97,28 @@ const selectFile = (fileName: string) => {
9697
fireEvent.change(screen.getByTestId("input-file"), { target: { files: [file] } });
9798
};
9899

100+
const selectWorkbook = (fileName = "wb.xlsx") => {
101+
const file = new File(["xlsx-bytes"], fileName, { type: XLSX_MIME });
102+
fireEvent.change(screen.getByTestId("input-file"), { target: { files: [file] } });
103+
};
104+
105+
// BN Workbook uploads run async pre-validation that disables the upload button until it settles.
106+
const waitForUploadEnabled = () =>
107+
waitFor(() => expect(screen.getByTestId("button-confirm-upload-document")).not.toBeDisabled());
108+
99109
describe("DocumentDialog attestation gating", () => {
100-
it("shows the attestation dialog and defers upload for a BN notebook", async () => {
110+
// BN Workbook pre-validation passes by default since parseBNFile/rule mocks return undefined.
111+
beforeEach(() => {
112+
parseBNFile.mockReset();
113+
rule.mockReset();
114+
});
115+
116+
it("shows the attestation dialog and defers upload for a BN Workbook", async () => {
101117
const onSubmit = vi.fn(() => Promise.resolve<DocumentUploadResult>("succeeded"));
102-
renderAddDialog("Final Budget Neutrality Formulation Workbook", onSubmit);
118+
renderAddDialog("BN Workbook", onSubmit);
103119

104-
selectFile("bn-notebook.docx");
120+
selectWorkbook();
121+
await waitForUploadEnabled();
105122
fireEvent.click(screen.getByTestId("button-confirm-upload-document"));
106123

107124
expect(
@@ -112,9 +129,10 @@ describe("DocumentDialog attestation gating", () => {
112129

113130
it("proceeds with the upload after the attestation is confirmed", async () => {
114131
const onSubmit = vi.fn(() => Promise.resolve<DocumentUploadResult>("succeeded"));
115-
renderAddDialog("Final Budget Neutrality Formulation Workbook", onSubmit);
132+
renderAddDialog("BN Workbook", onSubmit);
116133

117-
selectFile("bn-notebook.docx");
134+
selectWorkbook();
135+
await waitForUploadEnabled();
118136
fireEvent.click(screen.getByTestId("button-confirm-upload-document"));
119137

120138
fireEvent.click(await screen.findByTestId("attestation-acknowledge"));
@@ -126,9 +144,10 @@ describe("DocumentDialog attestation gating", () => {
126144
it("confirms before cancelling the upload when the attestation is dismissed", async () => {
127145
const onSubmit = vi.fn(() => Promise.resolve<DocumentUploadResult>("succeeded"));
128146
const onClose = vi.fn();
129-
renderAddDialog("Final Budget Neutrality Formulation Workbook", onSubmit, onClose);
147+
renderAddDialog("BN Workbook", onSubmit, onClose);
130148

131-
selectFile("bn-notebook.docx");
149+
selectWorkbook();
150+
await waitForUploadEnabled();
132151
fireEvent.click(screen.getByTestId("button-confirm-upload-document"));
133152

134153
const cancelButtons = await screen.findAllByTestId("button-dialog-cancel");
@@ -144,6 +163,17 @@ describe("DocumentDialog attestation gating", () => {
144163
expect(onSubmit).not.toHaveBeenCalled();
145164
});
146165

166+
it("uploads a Final Budget Neutrality Formulation Workbook directly without an attestation", async () => {
167+
const onSubmit = vi.fn(() => Promise.resolve<DocumentUploadResult>("succeeded"));
168+
renderAddDialog("Final Budget Neutrality Formulation Workbook", onSubmit);
169+
170+
selectFile("bn-formulation-workbook.docx");
171+
fireEvent.click(screen.getByTestId("button-confirm-upload-document"));
172+
173+
expect(onSubmit).toHaveBeenCalledOnce();
174+
expect(screen.queryByRole("heading", { name: "Attestation Required" })).not.toBeInTheDocument();
175+
});
176+
147177
it("uploads non-BN documents directly without an attestation", async () => {
148178
const onSubmit = vi.fn(() => Promise.resolve<DocumentUploadResult>("succeeded"));
149179
renderAddDialog("General File", onSubmit);
@@ -156,13 +186,6 @@ describe("DocumentDialog attestation gating", () => {
156186
});
157187
});
158188

159-
const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
160-
161-
const selectWorkbook = (fileName = "wb.xlsx") => {
162-
const file = new File(["xlsx-bytes"], fileName, { type: XLSX_MIME });
163-
fireEvent.change(screen.getByTestId("input-file"), { target: { files: [file] } });
164-
};
165-
166189
describe("DocumentDialog BN Workbook pre-validation", () => {
167190
beforeEach(() => {
168191
parseBNFile.mockReset();

client/src/components/dialog/document/DocumentDialog.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ import { DocumentChip } from "components/document/documentChip";
1919

2020
type DocumentDialogType = "add" | "edit";
2121

22-
// BN notebook uploads require the user to attest to the content before submitting.
23-
const ATTESTATION_DOCUMENT_TYPES: DocumentType[] = [
24-
"Final Budget Neutrality Formulation Workbook",
25-
"BN Workbook",
26-
];
22+
// BN Workbook uploads require the user to attest to the content before submitting.
23+
const ATTESTATION_DOCUMENT_TYPES: DocumentType[] = ["BN Workbook"];
2724

2825
export const documentTypeRequiresAttestation = (documentType: DocumentType): boolean =>
2926
ATTESTATION_DOCUMENT_TYPES.includes(documentType);

0 commit comments

Comments
 (0)