From 62785ebd77150edb115851d60173e5579457a0fe Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 21 May 2024 22:16:55 -0700 Subject: [PATCH] test: add test for archived attachments in attachment summary form tests --- .../ProjectAttachmentsFormSummary.test.tsx | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx index 9c8f3f6b81..61e515451e 100644 --- a/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx @@ -34,6 +34,7 @@ const defaultQueryResolver = { node: { id: "test-attachment-form-change-id-1", rowId: 1, + operation: "CREATE", asProjectAttachment: { attachmentByAttachmentId: { id: "test-attachment-id-1", @@ -52,6 +53,7 @@ const defaultQueryResolver = { node: { id: "test-attachment-form-change-id-2", rowId: 2, + operation: "CREATE", asProjectAttachment: { attachmentByAttachmentId: { id: "test-attachment-id-2", @@ -66,6 +68,25 @@ const defaultQueryResolver = { }, }, }, + { + node: { + id: "test-attachment-form-change-id-3", + rowId: 3, + operation: "ARCHIVE", + asProjectAttachment: { + attachmentByAttachmentId: { + id: "test-attachment-id-3", + fileName: "test-attachment-3.jpg", + fileType: "image/jpeg", + fileSize: 123456, + createdAt: "2021-01-03T00:00:00.000Z", + cifUserByCreatedBy: { + fullName: "Test User 2", + }, + }, + }, + }, + }, ], }, }, @@ -111,11 +132,20 @@ describe("The project's attachment page", () => { ).not.toBeInTheDocument(); }); - it("Displays all attachments", () => { + it("Displays all attachments that were created in this revision", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); + expect(screen.getAllByText(/Create/i)).toHaveLength(2); expect(screen.getByText(/test-attachment-1.jpg/i)).toBeInTheDocument(); expect(screen.getByText(/test-attachment-2.jpg/i)).toBeInTheDocument(); }); + + it("Displays all attachments that were archived in this revision", () => { + componentTestingHelper.loadQuery(); + componentTestingHelper.renderComponent(); + + expect(screen.getAllByText(/Archive/i)).toHaveLength(1); + expect(screen.getByText(/test-attachment-3.jpg/i)).toBeInTheDocument(); + }); });