From 096aadc10ac194e46aaf207d13c38f10b741a2f2 Mon Sep 17 00:00:00 2001 From: Kiran Siluveru Date: Thu, 2 Jan 2025 10:09:00 +0530 Subject: [PATCH 1/2] File upload unit test cases is in progress --- App/frontend-app/__mocks__/react-dropzone.ts | 14 + App/frontend-app/jest.config.ts | 2 +- .../uploadButton/uploadButton.test.tsx | 255 ++++++++++++++++++ .../components/uploadButton/uploadButton.tsx | 1 + 4 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 App/frontend-app/__mocks__/react-dropzone.ts create mode 100644 App/frontend-app/src/components/uploadButton/uploadButton.test.tsx diff --git a/App/frontend-app/__mocks__/react-dropzone.ts b/App/frontend-app/__mocks__/react-dropzone.ts new file mode 100644 index 00000000..18268f09 --- /dev/null +++ b/App/frontend-app/__mocks__/react-dropzone.ts @@ -0,0 +1,14 @@ +import { jest } from "@jest/globals"; + +const useDropzone = jest.fn() +// .mockReturnValue({ +// getRootProps: jest.fn().mockReturnValue({ "data-testid": "dropzone-root" }), +// getInputProps: jest.fn().mockReturnValue({ "data-testid": "dropzone-input" }), +// open: jest.fn(), +// acceptedFiles: [], +// }); + +// export default useDropzone; +// export default { useDropzone }; +export default useDropzone + diff --git a/App/frontend-app/jest.config.ts b/App/frontend-app/jest.config.ts index 9107e20d..cad33522 100644 --- a/App/frontend-app/jest.config.ts +++ b/App/frontend-app/jest.config.ts @@ -15,7 +15,7 @@ const config: Config.InitialOptions = { '^dompurify$': '/__mocks__/dompurify.js', // Point to the mock '\\.(jpg|jpeg|png|gif|svg)$': '/__mocks__/fileMock.ts', "^i18next$": "/__mocks__/i18n.ts", - + "react-dropzone":"/__mocks__/react-dropzone.ts", }, setupFilesAfterEnv: ['/src/test/setupTests.ts'], // For setting up testing environment like jest-dom transform: { diff --git a/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx b/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx new file mode 100644 index 00000000..1b43a727 --- /dev/null +++ b/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx @@ -0,0 +1,255 @@ +// import { useDropzone } from "react-dropzone"; +import { render, screen, fireEvent, waitFor } from "@testing-library/react"; +import UploadButton from "./uploadButton"; +import { jest } from "@jest/globals"; +import { useDropzone } from "react-dropzone"; + +const mockDropZoneFunctions = () => { + const mockOpen = jest.fn(); + const mockGetRootProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-root", + refKey: "dropzone-root-ref", + }); + const mockGetInputProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-input", + refKey: "dropzone-input-ref", + }); + (useDropzone as jest.Mock).mockReturnValue({ + getRootProps: mockGetRootProps, + getInputProps: mockGetInputProps, + open: mockOpen, + acceptedFiles: [], + }); +}; + +// Mock the react-dropzone module +jest.mock("react-dropzone", () => ({ + // Mock the useDropzone hook + useDropzone: jest.fn(), +})); + +describe("Upload Button Component", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it.skip("renders and displays the Upload Button correctly", async () => { + mockDropZoneFunctions(); + + render(); + + const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); + expect(uploadDocumentsButton).toBeInTheDocument(); + }); + + it.skip("On click close upload dialog should close", async () => { + mockDropZoneFunctions(); + + render(); + + // Click event for upload button we are doing here + const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); + fireEvent.click(uploadDocumentsButton); + + // In upload dialog + const headingWithUploadDocumentsText = await screen.findByRole("heading", { name: /upload Documents/i }); + expect(headingWithUploadDocumentsText).toBeInTheDocument(); + + const closeUploadDialogBtn = screen.getByTestId("closeUploadDialogBtn"); + fireEvent.click(closeUploadDialogBtn); + + await waitFor(() => { + expect(screen.queryByRole("button", { name: /browse files/i })).not.toBeInTheDocument(); + }); + }); + + it.skip("On click of Upload Button Dialog should open", async () => { + mockDropZoneFunctions(); + + render(); + + // Click event for upload button we are doing here + const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); + fireEvent.click(uploadDocumentsButton); + + // In upload dialog + const headingWithUploadDocumentsText = await screen.findByRole("heading", { name: /upload Documents/i }); + expect(headingWithUploadDocumentsText).toBeInTheDocument(); + + const dragAndDropArea = await screen.findByText(/drag and drop files/i); + expect(dragAndDropArea).toBeInTheDocument(); + + const browseFiles = await screen.findByRole("button", { name: /browse files/i }); + expect(browseFiles).toBeInTheDocument(); + }); + + it("Browser file button to be handled correctly", async () => { + const mockOpen = jest.fn(); + const mockGetRootProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-root", + }); + const mockGetInputProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-input", + }); + const mockOnDrop = jest.fn(); + + (useDropzone as jest.Mock).mockReturnValue({ + getRootProps: mockGetRootProps, + getInputProps: mockGetInputProps, + open: mockOpen, + onDrop: mockOnDrop, + }); + render(); + + // Click event for upload button we are doing here + const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); + fireEvent.click(uploadDocumentsButton); + + const browseFilesButton = await screen.findByRole("button", { name: /browse files/i }); + expect(browseFilesButton).toBeInTheDocument(); + fireEvent.click(browseFilesButton); + expect(mockOpen).toHaveBeenCalled(); + + const fileInput = screen.getByTestId("dropzone-input"); + console.log(fileInput); + + // Create a mock file to simulate file selection + const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + + // Trigger the change event on the input field to simulate file selection + + fireEvent.change(fileInput, { + target: { files: [file] }, + }); + + await waitFor(() => { + console.log(mockOnDrop.mock.calls); + expect(mockOnDrop).toHaveBeenCalledWith([file]); // Assert onDrop is called with the file + }); + + await waitFor( + () => { + screen.debug(); + // console.log("upload dialog end"); + // You can add any checks to ensure the file selection was handled properly. + // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); // Ensure the file is being uploaded + }, + { timeout: 5000 } + ); + }, 6000); + + // it.skip("should select a file via clicking and call onDrop method", async () => { + // const mockOpen = jest.fn(); + // const mockGetRootProps = jest.fn().mockReturnValue({ + // "data-testid": "dropzone-root", + // }); + // const mockGetInputProps = jest.fn().mockReturnValue({ + // "data-testid": "dropzone-input", + // }); + // const mockOnDrop = jest.fn(); + + // (useDropzone as jest.Mock).mockReturnValue({ + // getRootProps: mockGetRootProps, + // getInputProps: mockGetInputProps, + // open: mockOpen, + // onDrop: mockOnDrop, + // }); + + // render(); + + // // Trigger the dialog open by clicking the Upload button + // const uploadButton = screen.getByRole("button", { name: /upload documents/i }); + // fireEvent.click(uploadButton); + + // // Get the file input element and create a mock file + // const fileInput = screen.getByTestId("dropzone-input"); + // const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + + // // Simulate file selection by changing the input value + // fireEvent.change(fileInput, { + // target: { files: [file] }, + // }); + + // // Check that the file was added to the uploading files + // await waitFor(() => { + // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); + // expect(screen.getByText("example.pdf")).toBeInTheDocument(); + // }); + + // // Ensure that the onDrop method was called with the selected file + // // const onDrop = useDropzone().onDrop; + // expect(mockOnDrop).toHaveBeenCalledWith([file]); + // }); + + it.only("input should handle File Drop correctly and upload file", async () => { + const mockOpen = jest.fn(); + const mockOnDrop = jest.fn(); + const mockGetRootProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-root", + onKeyDown: jest.fn(), + onFocus: jest.fn(), + onBlur: jest.fn(), + onClick: jest.fn(), + onDragEnter: jest.fn(), + onDragOver: jest.fn(), + onDragLeave: jest.fn(), + onDrop: mockOnDrop, + role: "presentation", // or use the appropriate role as needed + ref: jest.fn(), // this can be used for a ref callback or other purposes + }); + const mockGetInputProps = jest.fn().mockReturnValue({ + "data-testid": "dropzone-input", + onKeyDown: jest.fn(), + onFocus: jest.fn(), + onBlur: jest.fn(), + onClick: jest.fn(), + onDragEnter: jest.fn(), + onDragOver: jest.fn(), + onDragLeave: jest.fn(), + onDrop: mockOnDrop, + role: "presentation", // or use the appropriate role as needed + ref: jest.fn(), // this can be used for a ref callback or other purposes + }); + + (useDropzone as jest.Mock).mockReturnValue({ + getRootProps: mockGetRootProps, + getInputProps: mockGetInputProps, + open: mockOpen, + onDrop: mockOnDrop, + }); + + render(); + + // Trigger the dialog open by clicking the Upload button + const uploadButton = screen.getByRole("button", { name: /upload documents/i }); + fireEvent.click(uploadButton); + + // Get the file input element and create a mock file + // Get the file input element (though this is not used for a "drop") + const dropzoneRoot = screen.getByTestId("dropzone-root"); + console.log("dropzoneRoot debug start"); + screen.debug(dropzoneRoot); + console.log("dropzoneRoot debug end"); + // console.log("dropzoneRoot", dropzoneRoot); + // Create a mock file + const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + + // Simulate file drop by manually calling onDrop with the file + fireEvent.drop(dropzoneRoot, { + dataTransfer: { + files: [file], + }, + }); + + expect(mockOnDrop).toHaveBeenCalledWith([file]); + + // // Check that the file was added to the uploading files + // await waitFor(() => { + // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); + // expect(screen.getByText("example.pdf")).toBeInTheDocument(); + // }); + + // Ensure that the onDrop method was called with the selected file + // const onDrop = useDropzone().onDrop; + }); +}); diff --git a/App/frontend-app/src/components/uploadButton/uploadButton.tsx b/App/frontend-app/src/components/uploadButton/uploadButton.tsx index 0ec6e182..dda91a85 100644 --- a/App/frontend-app/src/components/uploadButton/uploadButton.tsx +++ b/App/frontend-app/src/components/uploadButton/uploadButton.tsx @@ -95,6 +95,7 @@ const UploadDocumentsDialog = () => { appearance="subtle" onClick={() => setIsOpen(false)} style={{ position: "absolute", right: 20, top: 20 }} + data-testid="closeUploadDialogBtn" /> From e9c086d42b7afa97619ca9c0f56f5d0cfb51afea Mon Sep 17 00:00:00 2001 From: Kiran Siluveru Date: Thu, 2 Jan 2025 16:24:46 +0530 Subject: [PATCH 2/2] File upload test cases completed --- App/frontend-app/__mocks__/react-dropzone.ts | 14 - App/frontend-app/jest.config.ts | 1 - .../uploadButton/uploadButton.test.tsx | 264 ++++-------------- .../components/uploadButton/uploadButton.tsx | 3 +- 4 files changed, 64 insertions(+), 218 deletions(-) delete mode 100644 App/frontend-app/__mocks__/react-dropzone.ts diff --git a/App/frontend-app/__mocks__/react-dropzone.ts b/App/frontend-app/__mocks__/react-dropzone.ts deleted file mode 100644 index 18268f09..00000000 --- a/App/frontend-app/__mocks__/react-dropzone.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { jest } from "@jest/globals"; - -const useDropzone = jest.fn() -// .mockReturnValue({ -// getRootProps: jest.fn().mockReturnValue({ "data-testid": "dropzone-root" }), -// getInputProps: jest.fn().mockReturnValue({ "data-testid": "dropzone-input" }), -// open: jest.fn(), -// acceptedFiles: [], -// }); - -// export default useDropzone; -// export default { useDropzone }; -export default useDropzone - diff --git a/App/frontend-app/jest.config.ts b/App/frontend-app/jest.config.ts index cad33522..cedd636c 100644 --- a/App/frontend-app/jest.config.ts +++ b/App/frontend-app/jest.config.ts @@ -15,7 +15,6 @@ const config: Config.InitialOptions = { '^dompurify$': '/__mocks__/dompurify.js', // Point to the mock '\\.(jpg|jpeg|png|gif|svg)$': '/__mocks__/fileMock.ts', "^i18next$": "/__mocks__/i18n.ts", - "react-dropzone":"/__mocks__/react-dropzone.ts", }, setupFilesAfterEnv: ['/src/test/setupTests.ts'], // For setting up testing environment like jest-dom transform: { diff --git a/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx b/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx index 1b43a727..f9c7405e 100644 --- a/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx +++ b/App/frontend-app/src/components/uploadButton/uploadButton.test.tsx @@ -1,50 +1,38 @@ -// import { useDropzone } from "react-dropzone"; import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import UploadButton from "./uploadButton"; import { jest } from "@jest/globals"; -import { useDropzone } from "react-dropzone"; +import { act } from "react-dom/test-utils"; +import { importDocuments } from "../../api/documentsService"; -const mockDropZoneFunctions = () => { - const mockOpen = jest.fn(); - const mockGetRootProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-root", - refKey: "dropzone-root-ref", - }); - const mockGetInputProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-input", - refKey: "dropzone-input-ref", - }); - (useDropzone as jest.Mock).mockReturnValue({ - getRootProps: mockGetRootProps, - getInputProps: mockGetInputProps, - open: mockOpen, - acceptedFiles: [], - }); +jest.mock("../../api/documentsService", () => ({ + importDocuments: jest.fn(), +})); + +const testIDS = { + FILE_DROP_AREA: "file-drop-area", + UPLOAD_DIALOG_CLOSE_BTN: "upload-dialog-close-btn", }; -// Mock the react-dropzone module -jest.mock("react-dropzone", () => ({ - // Mock the useDropzone hook - useDropzone: jest.fn(), -})); +function mockData(files: any[]) { + return { + dataTransfer: { + files, + items: files.map((file) => ({ + kind: "file", + type: file.type, + getAsFile: () => file, + })), + types: ["Files"], + }, + }; +} describe("Upload Button Component", () => { beforeEach(() => { jest.clearAllMocks(); }); - it.skip("renders and displays the Upload Button correctly", async () => { - mockDropZoneFunctions(); - - render(); - - const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); - expect(uploadDocumentsButton).toBeInTheDocument(); - }); - - it.skip("On click close upload dialog should close", async () => { - mockDropZoneFunctions(); - + it("On click close upload dialog should close", async () => { render(); // Click event for upload button we are doing here @@ -55,7 +43,7 @@ describe("Upload Button Component", () => { const headingWithUploadDocumentsText = await screen.findByRole("heading", { name: /upload Documents/i }); expect(headingWithUploadDocumentsText).toBeInTheDocument(); - const closeUploadDialogBtn = screen.getByTestId("closeUploadDialogBtn"); + const closeUploadDialogBtn = screen.getByTestId(testIDS.UPLOAD_DIALOG_CLOSE_BTN); fireEvent.click(closeUploadDialogBtn); await waitFor(() => { @@ -63,193 +51,65 @@ describe("Upload Button Component", () => { }); }); - it.skip("On click of Upload Button Dialog should open", async () => { - mockDropZoneFunctions(); - - render(); - - // Click event for upload button we are doing here - const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); - fireEvent.click(uploadDocumentsButton); - - // In upload dialog - const headingWithUploadDocumentsText = await screen.findByRole("heading", { name: /upload Documents/i }); - expect(headingWithUploadDocumentsText).toBeInTheDocument(); - - const dragAndDropArea = await screen.findByText(/drag and drop files/i); - expect(dragAndDropArea).toBeInTheDocument(); - - const browseFiles = await screen.findByRole("button", { name: /browse files/i }); - expect(browseFiles).toBeInTheDocument(); - }); - - it("Browser file button to be handled correctly", async () => { - const mockOpen = jest.fn(); - const mockGetRootProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-root", - }); - const mockGetInputProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-input", - }); - const mockOnDrop = jest.fn(); + it("input should handle File Drop correctly and upload file >", async () => { + (importDocuments as jest.Mock).mockReturnValue({ status: "success" }); - (useDropzone as jest.Mock).mockReturnValue({ - getRootProps: mockGetRootProps, - getInputProps: mockGetInputProps, - open: mockOpen, - onDrop: mockOnDrop, - }); render(); - // Click event for upload button we are doing here - const uploadDocumentsButton = await screen.findByRole("button", { name: /upload documents/i }); - fireEvent.click(uploadDocumentsButton); - - const browseFilesButton = await screen.findByRole("button", { name: /browse files/i }); - expect(browseFilesButton).toBeInTheDocument(); - fireEvent.click(browseFilesButton); - expect(mockOpen).toHaveBeenCalled(); - - const fileInput = screen.getByTestId("dropzone-input"); - console.log(fileInput); - - // Create a mock file to simulate file selection - const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + const uploadButton = screen.getByRole("button", { name: /upload documents/i }); + fireEvent.click(uploadButton); - // Trigger the change event on the input field to simulate file selection + await act(() => { + const dropElement = screen.getByTestId(testIDS.FILE_DROP_AREA); + const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + const dropEventData = mockData([file]); - fireEvent.change(fileInput, { - target: { files: [file] }, - }); + fireEvent.dragEnter(dropElement, dropEventData); - await waitFor(() => { - console.log(mockOnDrop.mock.calls); - expect(mockOnDrop).toHaveBeenCalledWith([file]); // Assert onDrop is called with the file + fireEvent.drop(dropElement, dropEventData); }); await waitFor( () => { - screen.debug(); - // console.log("upload dialog end"); - // You can add any checks to ensure the file selection was handled properly. - // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); // Ensure the file is being uploaded + expect(importDocuments).toHaveBeenCalledTimes(1); + const fileNameElement = screen.queryByText("example.pdf"); + expect(fileNameElement).toBeInTheDocument(); + const uploadCompleteText = screen.queryByText("Upload complete"); + expect(uploadCompleteText).toBeInTheDocument(); }, - { timeout: 5000 } + { timeout: 3000 } ); - }, 6000); - - // it.skip("should select a file via clicking and call onDrop method", async () => { - // const mockOpen = jest.fn(); - // const mockGetRootProps = jest.fn().mockReturnValue({ - // "data-testid": "dropzone-root", - // }); - // const mockGetInputProps = jest.fn().mockReturnValue({ - // "data-testid": "dropzone-input", - // }); - // const mockOnDrop = jest.fn(); - - // (useDropzone as jest.Mock).mockReturnValue({ - // getRootProps: mockGetRootProps, - // getInputProps: mockGetInputProps, - // open: mockOpen, - // onDrop: mockOnDrop, - // }); - - // render(); - - // // Trigger the dialog open by clicking the Upload button - // const uploadButton = screen.getByRole("button", { name: /upload documents/i }); - // fireEvent.click(uploadButton); - - // // Get the file input element and create a mock file - // const fileInput = screen.getByTestId("dropzone-input"); - // const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); - - // // Simulate file selection by changing the input value - // fireEvent.change(fileInput, { - // target: { files: [file] }, - // }); - - // // Check that the file was added to the uploading files - // await waitFor(() => { - // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); - // expect(screen.getByText("example.pdf")).toBeInTheDocument(); - // }); - - // // Ensure that the onDrop method was called with the selected file - // // const onDrop = useDropzone().onDrop; - // expect(mockOnDrop).toHaveBeenCalledWith([file]); - // }); - - it.only("input should handle File Drop correctly and upload file", async () => { - const mockOpen = jest.fn(); - const mockOnDrop = jest.fn(); - const mockGetRootProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-root", - onKeyDown: jest.fn(), - onFocus: jest.fn(), - onBlur: jest.fn(), - onClick: jest.fn(), - onDragEnter: jest.fn(), - onDragOver: jest.fn(), - onDragLeave: jest.fn(), - onDrop: mockOnDrop, - role: "presentation", // or use the appropriate role as needed - ref: jest.fn(), // this can be used for a ref callback or other purposes - }); - const mockGetInputProps = jest.fn().mockReturnValue({ - "data-testid": "dropzone-input", - onKeyDown: jest.fn(), - onFocus: jest.fn(), - onBlur: jest.fn(), - onClick: jest.fn(), - onDragEnter: jest.fn(), - onDragOver: jest.fn(), - onDragLeave: jest.fn(), - onDrop: mockOnDrop, - role: "presentation", // or use the appropriate role as needed - ref: jest.fn(), // this can be used for a ref callback or other purposes - }); + }); - (useDropzone as jest.Mock).mockReturnValue({ - getRootProps: mockGetRootProps, - getInputProps: mockGetInputProps, - open: mockOpen, - onDrop: mockOnDrop, - }); + it("Upload fail should handle properly", async () => { + (importDocuments as jest.Mock).mockReturnValue({ status: "success" }); render(); - // Trigger the dialog open by clicking the Upload button const uploadButton = screen.getByRole("button", { name: /upload documents/i }); fireEvent.click(uploadButton); - // Get the file input element and create a mock file - // Get the file input element (though this is not used for a "drop") - const dropzoneRoot = screen.getByTestId("dropzone-root"); - console.log("dropzoneRoot debug start"); - screen.debug(dropzoneRoot); - console.log("dropzoneRoot debug end"); - // console.log("dropzoneRoot", dropzoneRoot); - // Create a mock file - const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); - - // Simulate file drop by manually calling onDrop with the file - fireEvent.drop(dropzoneRoot, { - dataTransfer: { - files: [file], - }, - }); + await act(() => { + const dropElement = screen.getByTestId(testIDS.FILE_DROP_AREA); + const file = new File(["file content"], "example.pdf", { type: "application/pdf" }); + const dropEventData = mockData([file]); - expect(mockOnDrop).toHaveBeenCalledWith([file]); + fireEvent.dragEnter(dropElement, dropEventData); - // // Check that the file was added to the uploading files - // await waitFor(() => { - // expect(screen.getByText(/uploading/i)).toBeInTheDocument(); - // expect(screen.getByText("example.pdf")).toBeInTheDocument(); - // }); + fireEvent.drop(dropElement, dropEventData); + }); + + (importDocuments as jest.Mock).mockRejectedValueOnce(new Error("Upload document failed ") as never); - // Ensure that the onDrop method was called with the selected file - // const onDrop = useDropzone().onDrop; + await waitFor( + () => { + expect(importDocuments).toHaveBeenCalledTimes(1); + const fileNameElement = screen.queryByText("example.pdf"); + expect(fileNameElement).toBeInTheDocument(); + const uploadCompleteText = screen.queryByText("Upload failed"); + expect(uploadCompleteText).toBeInTheDocument(); + }, + { timeout: 3000 } + ); }); }); diff --git a/App/frontend-app/src/components/uploadButton/uploadButton.tsx b/App/frontend-app/src/components/uploadButton/uploadButton.tsx index dda91a85..1c978bf1 100644 --- a/App/frontend-app/src/components/uploadButton/uploadButton.tsx +++ b/App/frontend-app/src/components/uploadButton/uploadButton.tsx @@ -95,7 +95,7 @@ const UploadDocumentsDialog = () => { appearance="subtle" onClick={() => setIsOpen(false)} style={{ position: "absolute", right: 20, top: 20 }} - data-testid="closeUploadDialogBtn" + data-testid="upload-dialog-close-btn" /> @@ -117,6 +117,7 @@ const UploadDocumentsDialog = () => { textAlign: "center", marginBottom: "20px", }} + data-testid="file-drop-area" >