Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaitasaini committed Mar 26, 2024
1 parent ef45ed0 commit 603d25e
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 1,012 deletions.
24 changes: 24 additions & 0 deletions services/ui-src/src/components/Rate/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ describe("Test non-readonly rate component", () => {

expect(rateTextBox).toHaveDisplayValue("43");
});

test("Ensure that warning appears if N=0, D>0, then R should be = 0 for user entered rates.", () => {
renderWithHookForm(<TestComponent2 />, {
defaultValues: {
"test-component": [
{
numerator: "1",
denominator: "1",
rate: "1",
},
],
},
});

// Change the numerator from 1 to 0

const numeratorTextBox = screen.getByLabelText("Numerator");

fireEvent.type(numeratorTextBox, "0");

expect(numeratorTextBox).toHaveDisplayValue("0");
const rateTextBox = screen.getByLabelText("Rate");
expect(rateTextBox).toHaveDisplayValue("0.0");
});
});

const TestComponentWithTotal = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Props {
rateReadOnly: undefined | boolean;
}

const renderComponet = ({ component, calcTotal, data, rateReadOnly }: Props) =>
const renderComponent = ({ component, calcTotal, data, rateReadOnly }: Props) =>
renderWithHookForm(
<PerformanceMeasure
data={data}
Expand All @@ -39,7 +39,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {
});

test("(QMR.Rate) Ensure component renders", () => {
renderComponet(props);
renderComponent(props);
// should render QMR.Rate layout using example data
expect(screen.getByText(/Performance Measure/i)).toBeVisible();
expect(screen.getByText(exampleData.questionText![0])).toBeVisible();
Expand Down Expand Up @@ -74,7 +74,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {

test("(QMR.Rate) Rates should not be editable", () => {
props.rateReadOnly = true;
renderComponet(props);
renderComponent(props);

const numeratorTextBox = screen.queryAllByLabelText("Numerator")[0];
const denominatorTextBox = screen.queryAllByLabelText("Denominator")[0];
Expand All @@ -89,32 +89,24 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {

test("(QMR.Rate) Should total in last NDR", () => {
props.calcTotal = true;
renderComponet(props);
renderComponent(props);

const numeratorTextBox = screen.queryAllByLabelText("Numerator")[0];
const denominatorTextBox = screen.queryAllByLabelText("Denominator")[0];
const rateTextBox = screen.queryAllByLabelText("Rate")[0];
fireEvent.type(numeratorTextBox, "1");
fireEvent.type(denominatorTextBox, "2");
expect(numeratorTextBox).toHaveDisplayValue("1");
expect(denominatorTextBox).toHaveDisplayValue("2");
expect(rateTextBox).toHaveDisplayValue("50.0");

// if numerator is greater than denominator,
const secondNumeratorTextBox = screen.queryAllByLabelText("Numerator")[1];
const secondDenominatorTextBox =
screen.queryAllByLabelText("Denominator")[1];
const secondRateTextBox = screen.queryAllByLabelText("Rate")[1];
fireEvent.type(secondNumeratorTextBox, "5");
fireEvent.type(secondDenominatorTextBox, "7");
expect(secondRateTextBox).toHaveDisplayValue("71.4");

const lastRateTextBox = screen.queryAllByLabelText("Rate");
//expect(lastRateTextBox).toHaveDisplayValue("66.7");

fireEvent.type(secondNumeratorTextBox, "55");
expect(secondRateTextBox).toHaveDisplayValue("");
expect(lastRateTextBox).toHaveDisplayValue("50.0");
fireEvent.type(numeratorTextBox, "123");
fireEvent.type(denominatorTextBox, "123");
expect(numeratorTextBox).toHaveDisplayValue("123");
expect(denominatorTextBox).toHaveDisplayValue("123");
expect(rateTextBox).toHaveDisplayValue("100.0");

// last NDR set should not total
const lastNumeratorTextBox = screen.queryAllByLabelText("Numerator")[1];
const lastDenominatorTextBox = screen.queryAllByLabelText("Denominator")[1];
const lastRateTextBox = screen.queryAllByLabelText("Rate")[1];
expect(lastNumeratorTextBox).toHaveDisplayValue("123");
expect(lastDenominatorTextBox).toHaveDisplayValue("123");
expect(lastRateTextBox).toHaveDisplayValue("100.0");
});

test("(PCR-XX) Ensure component renders", () => {
Expand All @@ -123,7 +115,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {

props.component = PCRRate;
props.data = PCRData;
renderComponet(props);
renderComponent(props);

// should render match PCRRate layout using PCR-XX data
expect(screen.getByText(/Performance Measure/i)).toBeVisible();
Expand Down Expand Up @@ -152,7 +144,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {
props.component = PCRRate;
props.data = PCRData;
props.rateReadOnly = true;
renderComponet(props);
renderComponent(props);

// rates should not be editable
const numeratorTextBox = screen.queryAllByLabelText(
Expand Down
13 changes: 0 additions & 13 deletions services/ui-src/src/measures/2024/AMMAD/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,3 @@ const completedMeasureData = {
MeasurementSpecification: "NCQA/HEDIS",
DidReport: "yes",
};

/*
const measureDataWithStandardDataSource = {
DataSource: "Administrative Data",
MeasurementSpecification: "NCQA/HEDIS",
DidReport: "yes",
};
const measureDataWithOtherDataSource = {
DataSource: "Other Data Source",
MeasurementSpecification: "NCQA/HEDIS",
DidReport: "yes",
}; */
32 changes: 2 additions & 30 deletions services/ui-src/src/measures/2024/AMRAD/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Suspense } from "react";
import { MeasuresLoading } from "views";
import { measureDescriptions } from "measures/measureDescriptions";
import { renderWithHookForm } from "utils/testUtils/reactHookFormRenderer";
import fireEvent from "@testing-library/user-event";
import { validationFunctions } from "./validation";
import {
mockValidateAndSetErrors,
Expand Down Expand Up @@ -136,33 +135,6 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
expect(screen.queryByTestId("OPM")).not.toBeInTheDocument();
});

it("(QMR.Rate) should calculate correctly and account for user error", async () => {
apiData.useGetMeasureValues.data.Item.data = completedMeasureData;
useApiMock(apiData);
renderWithHookForm(component);

const numeratorTextBox = screen.queryAllByLabelText("Numerator");
//console.log(numeratorTextBox);
expect(numeratorTextBox).toHaveDisplayValue("55");
const denominatorTextBox = screen.queryAllByLabelText("Denominator")[0];
const rateTextBox = screen.queryAllByLabelText("Rate")[0];
fireEvent.type(numeratorTextBox[0], "1");
fireEvent.type(denominatorTextBox, "2");
console.log(numeratorTextBox);
expect(numeratorTextBox).toHaveDisplayValue("1");
expect(denominatorTextBox).toHaveDisplayValue("2");
expect(rateTextBox).toHaveDisplayValue("50.0");

// if numerator is greater than denominator, the row does not factor into total rate
const secondNumeratorTextBox = screen.queryAllByLabelText("Numerator")[1];
const secondDenominatorTextBox =
screen.queryAllByLabelText("Denominator")[1];
const secondRateTextBox = screen.queryAllByLabelText("Rate")[1];
fireEvent.type(secondNumeratorTextBox, "5");
fireEvent.type(secondDenominatorTextBox, "7");
expect(secondRateTextBox).toHaveDisplayValue("71.4");
});

it("shows corresponding components and hides others when primary measure is NOT selected", async () => {
apiData.useGetMeasureValues.data.Item.data = OPMData;
useApiMock(apiData);
Expand Down Expand Up @@ -267,6 +239,8 @@ const OPMData = {
};

const completedMeasureData = {
MeasurementSpecification: "NCQA/HEDIS",
DidReport: "yes",
PerformanceMeasure: {
rates: {
singleCategory: [
Expand All @@ -292,6 +266,4 @@ const completedMeasureData = {
],
},
},
MeasurementSpecification: "NCQA/HEDIS",
DidReport: "yes",
};
6 changes: 5 additions & 1 deletion services/ui-src/src/measures/2024/PPC2AD/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Suspense } from "react";
import { MeasuresLoading } from "views";
import { measureDescriptions } from "measures/measureDescriptions";
import { renderWithHookForm } from "utils/testUtils/reactHookFormRenderer";
//import fireEvent from "@testing-library/user-event";
import { validationFunctions } from "./validation";
import {
mockValidateAndSetErrors,
Expand Down Expand Up @@ -144,7 +145,10 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
).not.toBeInTheDocument();
});

// TO-DO: it("allows a user to manually override rate when CAHPS 5.1H is selected")
it("allows a user to manually override rate when CAHPS 5.1H is selected", async () => {
useApiMock(apiData);
renderWithHookForm(component);
});

it("shows OMS when performance measure data has been entered", async () => {
apiData.useGetMeasureValues.data.Item.data = completedMeasureData;
Expand Down
118 changes: 0 additions & 118 deletions tests/cypress/cypress/e2e/measures/adult/FUHAD.spec.ts

This file was deleted.

55 changes: 0 additions & 55 deletions tests/cypress/cypress/e2e/measures/adult/HPCAD.spec.ts

This file was deleted.

Loading

0 comments on commit 603d25e

Please sign in to comment.