Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaitasaini committed Dec 9, 2024
1 parent b042a2e commit 2fb3aed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import { axe } from "jest-axe";
//components
import { AddEditReportModal } from "components";
import {
mockStateUserStore,
RouterWrappedComponent,
} from "utils/testing/setupJest";
import { useStore } from "utils";
import userEvent from "@testing-library/user-event";

const mockCloseHandler = jest.fn();
const mockReportHandler = jest.fn();
Expand Down Expand Up @@ -39,17 +39,17 @@ describe("Test AddEditProgramModal", () => {
});

test("AddEditReportModal shows the contents", () => {
expect(screen.getByText("QMS report name")).toBeTruthy();
expect(screen.getByText("Start new")).toBeTruthy();
expect(screen.getByText("QMS report name")).toBeVisible();
expect(screen.getByText("Start new")).toBeVisible();
});

test("AddEditReportModal top close button can be clicked", () => {
fireEvent.click(screen.getByText("Close"));
userEvent.click(screen.getByText("Close"));
expect(mockCloseHandler).toHaveBeenCalledTimes(1);
});

test("AddEditReportModal bottom cancel button can be clicked", () => {
fireEvent.click(screen.getByText("Cancel"));
userEvent.click(screen.getByText("Cancel"));
expect(mockCloseHandler).toHaveBeenCalledTimes(1);
});
});
Expand Down
8 changes: 4 additions & 4 deletions services/ui-src/src/components/modals/AddEditReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const AddEditReportModal = ({
const onSubmit = async (formData: any) => {
setSubmitting(true);

const reportOptions: any = {
const reportOptions: ReportOptions = {
name: "",
} as ReportOptions;
};

if (formData["reportTitle"]) {
reportOptions["name"] = formData["reportTitle"].answer;
if (formData.reportTitle) {
reportOptions.name = formData.reportTitle.answer;
}

await createReport(reportType, activeState, reportOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export const DashboardPage = () => {
const { intro, body } = dashboardVerbiage;
const fullStateName = StateNames[state as keyof typeof StateNames];

// TO-DO: update accordingly - if a user is an admin or a read-only type, use the selected state, otherwise use their assigned state
const activeState = state;

useEffect(() => {
if (!isReportType(reportType) || !isStateAbbr(state)) {
return;
Expand Down Expand Up @@ -97,7 +94,7 @@ export const DashboardPage = () => {
</Flex>
</Flex>
<AddEditReportModal
activeState={activeState!}
activeState={state!}
reportType={reportType!}
modalDisclosure={{
isOpen: addEditReportModalIsOpen,
Expand Down

0 comments on commit 2fb3aed

Please sign in to comment.