Skip to content

Commit

Permalink
test: renewal test validations
Browse files Browse the repository at this point in the history
  • Loading branch information
asharonbaltazar committed Sep 16, 2024
1 parent f98720d commit 800d110
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions react-app/src/features/forms/waiver/capitated/renewal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { screen } from "@testing-library/react";
import { beforeAll, describe, expect, test, vi } from "vitest";
import userEvent from "@testing-library/user-event";
import { renderForm } from "@/utils/test-helpers/renderForm";
import { skipCleanup } from "@/utils/test-helpers/skipCleanup";
import {
mockApiRefinements,
skipCleanup,
} from "@/utils/test-helpers/skipCleanup";
import { Renewal } from "./Renewal";
import { uploadFiles } from "@/utils/test-helpers/uploadFiles";
import { formSchemas } from "@/formSchemas";
Expand All @@ -20,6 +23,7 @@ let container: HTMLElement;
describe("Capitated Renewal", () => {
beforeAll(() => {
skipCleanup();
mockApiRefinements();

const { container: renderedContainer } = renderForm(<Renewal />);

Expand All @@ -31,15 +35,56 @@ describe("Capitated Renewal", () => {
/Existing Waiver Number to Renew/,
);
const existingWaiverLabel = screen.getByTestId("existing-waiver-label");
await userEvent.type(existingWaiverInput, "MD-24-9291");

// test record does not exist error occurs
await userEvent.type(existingWaiverInput, "MD-0004.R00.00");
const recordDoesNotExistError = screen.getByText(
"According to our records, this 1915(b) Waiver Number does not yet exist. Please check the 1915(b) Initial or Renewal Waiver Number and try entering it again.",
);
expect(recordDoesNotExistError).toBeInTheDocument();
await userEvent.clear(existingWaiverInput);
// test record is not approved error occurs
await userEvent.type(existingWaiverInput, "MD-0002.R00.00");
const recordIsNotApproved = screen.getByText(
"According to our records, this 1915(b) Waiver Number is not approved. You must supply an approved 1915(b) Initial or Renewal Waiver Number.",
);
expect(recordIsNotApproved).toBeInTheDocument();
await userEvent.clear(existingWaiverInput);
// test record is not able to be renewed or amended error occurs
await userEvent.type(existingWaiverInput, "MD-0001.R00.00");
const recordCanNotBeRenewed = screen.getByText(
"The 1915(b) Waiver Number entered does not seem to match our records. Please enter an approved 1915(b) Initial or Renewal Waiver Number, using a dash after the two character state abbreviation.",
);
expect(recordCanNotBeRenewed).toBeInTheDocument();
await userEvent.clear(existingWaiverInput);
//valid id is entered
await userEvent.type(existingWaiverInput, "MD-0000.R00.00");

expect(existingWaiverLabel).not.toHaveClass("text-destructive");
});

test("1915(B) WAIVER RENEWAL NUMBER", async () => {
const waiverRenewalInput = screen.getByLabelText(/Waiver Renewal Number/);
const waiverRenewalLabel = screen.getByTestId("1915b-waiver-renewal-label");
await userEvent.type(waiverRenewalInput, "SS-8382.R98.01");

// validate id errors
// item exists validation error occurs
await userEvent.type(waiverRenewalInput, "MD-0005.R01.00");
const itemExistsErrorMessage = screen.getByText(
"According to our records, this 1915(b) Waiver Number already exists. Please check the 1915(b) Waiver Number and try entering it again.",
);
expect(itemExistsErrorMessage).toBeInTheDocument();
await userEvent.clear(waiverRenewalInput);
// state error occurs
await userEvent.type(waiverRenewalInput, "AK-0005.R01.00");
const invalidStateErrorMessage = screen.getByText(
"You can only submit for a state you have access to. If you need to add another state, visit your IDM user profile to request access.",
);
expect(invalidStateErrorMessage).toBeInTheDocument();
await userEvent.clear(waiverRenewalInput);
// end of error validations

await userEvent.type(waiverRenewalInput, "MD-0005.R01.01");

expect(waiverRenewalLabel).not.toHaveClass("text-destructive");
});
Expand Down

0 comments on commit 800d110

Please sign in to comment.