Skip to content

Commit

Permalink
[QMR] Cypress Test Refactor 1/x - Adult Measures (#2101)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaitasaini committed Mar 27, 2024
1 parent af554ba commit 7c7af0c
Show file tree
Hide file tree
Showing 38 changed files with 70 additions and 5,220 deletions.
42 changes: 42 additions & 0 deletions services/ui-src/src/components/Rate/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ describe("Test the Rate component", () => {

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

test("rounds auto-calculated rate up or down as expected", async () => {
const numeratorTextBox = await screen.findByLabelText("Numerator");
const denominatorTextBox = await screen.findByLabelText("Denominator");
const rateTextBox = await screen.findByLabelText("Rate");

// 3/9*100 = 3.333... -> 33.3
fireEvent.type(numeratorTextBox, "3");
fireEvent.type(denominatorTextBox, "9");

expect(rateTextBox).toHaveDisplayValue("33.3");

// 6/9*100 = 66.666... -> 66.7
fireEvent.type(numeratorTextBox, "6");
fireEvent.type(denominatorTextBox, "9");

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

describe("Test non-readonly rate component", () => {
Expand All @@ -109,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 All @@ -63,7 +63,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {
fireEvent.type(rateTextBox, "99.9");
expect(rateTextBox).toHaveDisplayValue("99.9");

// last NDR in categroy should not total
// last NDR in category should not total
const lastNumeratorTextBox = screen.queryAllByLabelText("Numerator")[1];
const lastDenominatorTextBox = screen.queryAllByLabelText("Denominator")[1];
const lastRateTextBox = screen.queryAllByLabelText("Rate")[1];
Expand All @@ -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,7 +89,7 @@ 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];
Expand All @@ -115,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 @@ -144,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
15 changes: 13 additions & 2 deletions services/ui-src/src/measures/2024/AMMAD/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
expect(screen.queryByTestId("reporting"));
});

it("shows corresponding questions if yes to reporting then ", async () => {
it("shows corresponding questions if yes to reporting then", async () => {
apiData.useGetMeasureValues.data.Item.data = completedMeasureData;
useApiMock(apiData);
renderWithHookForm(component);
Expand All @@ -107,7 +107,7 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
).toBeInTheDocument();
});

it("does not show corresponding questions if no to reporting then ", async () => {
it("does not show corresponding questions if not reporting", async () => {
apiData.useGetMeasureValues.data.Item.data = notReportingData;
useApiMock(apiData);
renderWithHookForm(component);
Expand All @@ -127,6 +127,10 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
useApiMock(apiData);
renderWithHookForm(component);
expect(screen.queryByTestId("performance-measure")).toBeInTheDocument();
await waitFor(() => {
expect(screen.getAllByText("Ages 18 to 64"));
expect(screen.getAllByText("Age 65 and older"));
});
expect(
screen.queryByTestId("deviation-from-measure-specification")
).toBeInTheDocument();
Expand All @@ -142,6 +146,13 @@ describe(`Test FFY ${year} ${measureAbbr}`, () => {
expect(
screen.queryByTestId("deviation-from-measure-specification")
).not.toBeInTheDocument();

expect(
screen.queryByTestId("measurement-specification")
).toBeInTheDocument();
await waitFor(() => {
expect(screen.getByText("Other Performance Measure"));
});
});

it("shows OMS when performance measure data has been entered", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {

mockLDFlags.setDefault({ periodOfHealthEmergency2024: false });

const renderComponet = ({
const renderComponent = ({
component,
calcTotal,
data,
Expand Down Expand Up @@ -52,7 +52,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 @@ -87,7 +87,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 @@ -102,7 +102,7 @@ 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];
Expand Down Expand Up @@ -132,7 +132,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 @@ -163,7 +163,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 All @@ -186,7 +186,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {
test("periodOfHealthEmergency2024 flag is set to false, covid text and textbox should not render", () => {
props.data = CBPdata;
props.hybridMeasure = true;
renderComponet(props);
renderComponent(props);
const covidText = screen.queryByLabelText(
"Describe any COVID-related difficulties encountered while collecting this data:"
);
Expand All @@ -197,7 +197,7 @@ describe("Test the PerformanceMeasure RateComponent prop", () => {
mockLDFlags.set({ periodOfHealthEmergency2024: true });
props.data = CBPdata;
props.hybridMeasure = true;
renderComponet(props);
renderComponent(props);
const covidText = screen.getByLabelText(
"Describe any COVID-related difficulties encountered while collecting this data:"
);
Expand Down
98 changes: 0 additions & 98 deletions tests/cypress/cypress/e2e/measures/adult/AMMAD.spec.ts

This file was deleted.

Loading

0 comments on commit 7c7af0c

Please sign in to comment.