diff --git a/src/components/CancelApplicationButton/index.test.tsx b/src/components/CancelApplicationButton/index.test.tsx new file mode 100644 index 000000000..4366d3804 --- /dev/null +++ b/src/components/CancelApplicationButton/index.test.tsx @@ -0,0 +1,407 @@ +import { render, waitFor, within } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { axe } from "jest-axe"; +import { useMemo } from "react"; +import { MockedProvider, MockedResponse } from "@apollo/client/testing"; +import { GraphQLError } from "graphql"; +import { + Context as AuthContext, + ContextState as AuthContextState, + Status as AuthContextStatus, +} from "../Contexts/AuthContext"; +import { CANCEL_APP, CancelAppInput, CancelAppResp } from "../../graphql"; +import Button from "./index"; + +const baseAuthCtx: AuthContextState = { + status: AuthContextStatus.LOADED, + isLoggedIn: false, + user: null, +}; + +const baseUser: User = { + _id: "", + firstName: "", + lastName: "", + userStatus: "Active", + role: "Submitter", // NOTE: This role has access to the delete button by default + IDP: "nih", + email: "", + studies: null, + dataCommons: [], + createdAt: "", + updateAt: "", + permissions: ["data_submission:view", "data_submission:create"], + notifications: [], +}; + +type TestParentProps = { + user?: Partial; + mocks?: MockedResponse[]; + children: React.ReactNode; +}; + +const TestParent: React.FC = ({ mocks = [], user = {}, children }) => { + const authCtxValue = useMemo( + () => ({ + ...baseAuthCtx, + user: { ...baseUser, ...user }, + }), + [user] + ); + + return ( + + {children} + + ); +}; + +describe("Accessibility", () => { + it("should have no violations for the component", async () => { + const { container, getByTestId } = render( +