Skip to content

Commit

Permalink
chore,fix(frontend/tests): more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoltCode committed Dec 26, 2024
1 parent f8258a0 commit 59ada54
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions frontend/src/components/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ const DropdownContent = forwardRef<HTMLDivElement, DropdownContentProps>((props,
}
};

console.log("OPTIONS!!!", props.options);

return (
<div
ref={ref}
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/taskSelection/actionSidebars.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function CompletionTabForMapping({
if (err.response?.data?.SubCode === 'SmallToSplit') {
setSplitTaskError(true);
} else {
console.log("TOAST ERROR", err);
toast.error(<FormattedMessage {...messages.splitTaskGenericError} />);
}
},
Expand All @@ -94,6 +95,7 @@ export function CompletionTabForMapping({
navigateToTasksPage(tasksIds);
},
onError: () => {
console.log("TOAST ERROR 2");
toast.error(<FormattedMessage {...messages.stopMappingError} />);
},
});
Expand All @@ -109,6 +111,7 @@ export function CompletionTabForMapping({
navigateToTasksPage(tasksIds);
},
onError: () => {
console.log("TOAST ERROR 3");
toast.error(
<FormattedMessage {...messages.submitTaskError} values={{ numTasks: tasksIds.length }} />,
);
Expand Down Expand Up @@ -365,6 +368,7 @@ export function CompletionTabForValidation({
navigateToTasksPage();
},
onError: () => {
console.log("TOAST ERROR 4");
toast.error(<FormattedMessage {...messages.stopValidationError} />);
},
});
Expand All @@ -377,6 +381,7 @@ export function CompletionTabForValidation({
navigateToTasksPage(true);
},
onError: () => {
console.log("TOAST ERROR 5");
toast.error(
<FormattedMessage {...messages.submitTaskError} values={{ numTasks: tasksIds.length }} />,
);
Expand Down Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/taskSelection/map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ export const TasksMap = ({
disableScrollZoom,
navigate,
animateZoom,
authDetails.id,
authDetails?.id,
showTaskIds,
zoomedTaskId,
authDetails.username,
authDetails?.username,
intl,
]);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/taskSelection/taskActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const TaskHistory = ({ projectId, taskId }) => {
return res;
};

if (status === 'loading') {
if (status === 'pending') {
return (
<div className="ma4">
<ReactPlaceholder type="media" showLoadingAnimation delay={300} />
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(),
}));

Expand Down Expand Up @@ -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));
});

Expand Down
4 changes: 0 additions & 4 deletions frontend/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/tests/taskAction.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 59ada54

Please sign in to comment.