From 59ada542e202c4f3e88aaf8bab43d592bae18653 Mon Sep 17 00:00:00 2001 From: JoltCode Date: Thu, 26 Dec 2024 23:55:31 +0000 Subject: [PATCH] chore,fix(frontend/tests): more test fixes --- frontend/src/components/dropdown.tsx | 2 -- frontend/src/components/taskSelection/actionSidebars.jsx | 7 +++++-- frontend/src/components/taskSelection/map.jsx | 4 ++-- frontend/src/components/taskSelection/taskActivity.tsx | 2 +- .../components/taskSelection/tests/actionSidebars.test.jsx | 5 +++-- frontend/src/setup.ts | 4 ---- frontend/src/views/tests/taskAction.test.jsx | 1 - 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/dropdown.tsx b/frontend/src/components/dropdown.tsx index 7de7c5aec8..01dee971d9 100644 --- a/frontend/src/components/dropdown.tsx +++ b/frontend/src/components/dropdown.tsx @@ -69,8 +69,6 @@ const DropdownContent = forwardRef((props, } }; - console.log("OPTIONS!!!", props.options); - return (
); } }, @@ -94,6 +95,7 @@ export function CompletionTabForMapping({ navigateToTasksPage(tasksIds); }, onError: () => { + console.log("TOAST ERROR 2"); toast.error(); }, }); @@ -109,6 +111,7 @@ export function CompletionTabForMapping({ navigateToTasksPage(tasksIds); }, onError: () => { + console.log("TOAST ERROR 3"); toast.error( , ); @@ -365,6 +368,7 @@ export function CompletionTabForValidation({ navigateToTasksPage(); }, onError: () => { + console.log("TOAST ERROR 4"); toast.error(); }, }); @@ -377,6 +381,7 @@ export function CompletionTabForValidation({ navigateToTasksPage(true); }, onError: () => { + console.log("TOAST ERROR 5"); toast.error( , ); @@ -834,10 +839,8 @@ function TaskSpecificInstructions({ instructions, open = true }) { const [htmlInstructionsHTML, setHtmlInstructionsHTML] = useState(''); useEffect(() => { - console.log("instructions", instructions); if (!instructions) return; (async () => { - console.log("INSTRUCTIONS", instructions); setHtmlInstructionsHTML(await htmlFromMarkdown(instructions)); })(); }, [instructions]); diff --git a/frontend/src/components/taskSelection/map.jsx b/frontend/src/components/taskSelection/map.jsx index d5236a3159..1359fda98a 100644 --- a/frontend/src/components/taskSelection/map.jsx +++ b/frontend/src/components/taskSelection/map.jsx @@ -490,10 +490,10 @@ export const TasksMap = ({ disableScrollZoom, navigate, animateZoom, - authDetails.id, + authDetails?.id, showTaskIds, zoomedTaskId, - authDetails.username, + authDetails?.username, intl, ]); diff --git a/frontend/src/components/taskSelection/taskActivity.tsx b/frontend/src/components/taskSelection/taskActivity.tsx index b21482d531..cad4b82cd4 100644 --- a/frontend/src/components/taskSelection/taskActivity.tsx +++ b/frontend/src/components/taskSelection/taskActivity.tsx @@ -118,7 +118,7 @@ export const TaskHistory = ({ projectId, taskId }) => { return res; }; - if (status === 'loading') { + if (status === 'pending') { return (
diff --git a/frontend/src/components/taskSelection/tests/actionSidebars.test.jsx b/frontend/src/components/taskSelection/tests/actionSidebars.test.jsx index 2334586b98..4879145c12 100644 --- a/frontend/src/components/taskSelection/tests/actionSidebars.test.jsx +++ b/frontend/src/components/taskSelection/tests/actionSidebars.test.jsx @@ -1,7 +1,6 @@ import { act, render, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import toast from 'react-hot-toast'; import { CompletionTabForMapping, @@ -26,7 +25,8 @@ import { userMultipleLockedTasksDetails } from '../../../network/tests/mockData/ // This is a late import in a React.lazy call; it takes awhile for commentInput to load import '../../comments/commentInput'; -vi.mock('react-hot-toast', () => ({ +vi.mock('react-hot-toast', async (importOriginal) => ({ + ...(await importOriginal()), error: vi.fn(), })); @@ -109,6 +109,7 @@ describe('Miscellaneous modals and prompts', () => { name: /split task/i, }), ); + const toast = await import("react-hot-toast"); await waitFor(() => expect(toast.error).toHaveBeenCalledTimes(1)); }); diff --git a/frontend/src/setup.ts b/frontend/src/setup.ts index bb454d088e..48b7c1e5f3 100644 --- a/frontend/src/setup.ts +++ b/frontend/src/setup.ts @@ -2,10 +2,6 @@ import '@testing-library/jest-dom/vitest'; // vi.mock('mapbox-gl/dist/mapbox-gl'); -vi.mock("react-hot-toast", { - spy: true -}) - window.URL.createObjectURL = vi.fn(); beforeEach(() => { diff --git a/frontend/src/views/tests/taskAction.test.jsx b/frontend/src/views/tests/taskAction.test.jsx index a89b57f089..1541bbc97e 100644 --- a/frontend/src/views/tests/taskAction.test.jsx +++ b/frontend/src/views/tests/taskAction.test.jsx @@ -42,7 +42,6 @@ describe('Submitting Mapping Status for a Task', () => { }); const { user, router } = setup(); - screen.debug(); expect( await screen.findByRole('button', { name: /submit task/i,