Skip to content

Commit

Permalink
fix the extra syphilis tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed May 15, 2024
1 parent 56ef6a5 commit 24b2213
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 63 deletions.
12 changes: 12 additions & 0 deletions frontend/src/app/testQueue/TestCard/TestCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ describe("TestCard", () => {
},
}
),
blankUpdateAoeEventMock
];

const props = {
Expand Down Expand Up @@ -845,6 +846,8 @@ describe("TestCard", () => {
},
}
),
blankUpdateAoeEventMock,
blankUpdateAoeEventMock
];

const { user } = await renderQueueItem({ mocks });
Expand Down Expand Up @@ -997,6 +1000,7 @@ describe("TestCard", () => {
},
}
),
blankUpdateAoeEventMock
];

const { user } = await renderQueueItem({ mocks });
Expand Down Expand Up @@ -1031,6 +1035,8 @@ describe("TestCard", () => {
MULTIPLEX_DISEASES.COVID_19,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock

];

const { user } = await renderQueueItem({ mocks });
Expand All @@ -1056,6 +1062,8 @@ describe("TestCard", () => {

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
blankUpdateAoeEventMock

];

const { user } = await renderQueueItem({ mocks });
Expand All @@ -1075,6 +1083,8 @@ describe("TestCard", () => {

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
blankUpdateAoeEventMock

];

const { user } = await renderQueueItem({ mocks });
Expand Down Expand Up @@ -1104,6 +1114,7 @@ describe("TestCard", () => {

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.UNKNOWN),
blankUpdateAoeEventMock
];

const { user } = await renderQueueItem({ mocks });
Expand Down Expand Up @@ -1245,6 +1256,7 @@ describe("TestCard", () => {
MULTIPLEX_DISEASES.COVID_19,
TEST_RESULTS.POSITIVE
),
blankUpdateAoeEventMock
];

const { user } = await renderQueueItem({ mocks });
Expand Down
129 changes: 69 additions & 60 deletions frontend/src/app/testQueue/TestCardForm/TestCardForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { MockedProvider } from "@apollo/client/testing";

import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants";

import TestCardForm, { TestCardFormProps } from "./TestCardForm";
import {
asymptomaticTestOrderInfo,
Expand All @@ -19,8 +21,9 @@ import {
syphilisDeviceName,
} from "./testUtils/testConstants";
import {
generateSubmitQueueMock,
submitEventMock,
TEST_SYMPTOM_ONSET_DATE,
TEST_CARD_SYMPTOM_ONSET_DATE_STRING,
updateAoeMocks,
} from "./testUtils/submissionMocks";

Expand Down Expand Up @@ -214,17 +217,23 @@ describe("TestCardForm", () => {
...testProps,
testOrder: {
...testProps.testOrder,
results: [
{ testResult: "POSITIVE", disease: { name: "COVID-19" } },
{ testResult: "UNKNOWN", disease: { name: "Flu A" } },
{ testResult: "UNKNOWN", disease: { name: "Flu B" } },
],
results: [{ testResult: "POSITIVE", disease: { name: "COVID-19" } }],
},
};

const { user } = await renderTestCardForm({
props,
mocks: [submitEventMock, submitEventMock],
mocks: [
generateSubmitQueueMock(
MULTIPLEX_DISEASES.COVID_19,
TEST_RESULTS.POSITIVE,
{
device: {
deviceId: covidDeviceId,
},
}
),
],
});

// Submit to start form validation
Expand All @@ -239,63 +248,63 @@ describe("TestCardForm", () => {
screen.queryByText("Do you want to submit results anyway?")
).not.toBeInTheDocument();
});
});

it("should show error messages when symptomatic patient doesn't have onset date or symptom list", async () => {
const props = {
...testProps,
testOrder: {
...asymptomaticTestOrderInfo,
results: [
{ testResult: "POSITIVE", disease: { name: "COVID-19" } },
{ testResult: "UNKNOWN", disease: { name: "Flu A" } },
{ testResult: "UNKNOWN", disease: { name: "Flu B" } },
],
},
};
it("should show error messages when symptomatic patient doesn't have onset date or symptom list", async () => {
const props = {
...testProps,
testOrder: {
...asymptomaticTestOrderInfo,
results: [
{ testResult: "POSITIVE", disease: { name: "COVID-19" } },
{ testResult: "UNKNOWN", disease: { name: "Flu A" } },
{ testResult: "UNKNOWN", disease: { name: "Flu B" } },
],
},
};

const { user } = await renderTestCardForm({
props,
mocks: [submitEventMock, submitEventMock, ...updateAoeMocks],
});
const { user } = await renderTestCardForm({
props,
mocks: [submitEventMock, submitEventMock, ...updateAoeMocks],
});

const pregnancyAoeGroup = screen.getByRole("group", {
name: /is the patient pregnant\?/i,
});
await user.click(within(pregnancyAoeGroup).getByText(/yes/i));
const pregnancyAoeGroup = screen.getByRole("group", {
name: /is the patient pregnant\?/i,
});
await user.click(within(pregnancyAoeGroup).getByText(/yes/i));

const symptomsAoeGroup = screen.getByRole("group", {
name: /is the patient currently experiencing any symptoms\?/i,
});
await user.click(within(symptomsAoeGroup).getByText(/yes/i));
await user.click(screen.getByText("Submit results"));
expect(
screen.getAllByText(
"This question is required if the patient has symptoms"
).length
).toBe(2);

await user.click(
screen.getByRole("checkbox", {
name: /cough/i,
})
);
await user.click(screen.getByText("Submit results"));
expect(
screen.getAllByText(
"This question is required if the patient has symptoms"
).length
).toBe(1);

await user.type(
screen.getByLabelText(/when did the patient's symptoms start\?/i),
TEST_SYMPTOM_ONSET_DATE
);
const symptomsAoeGroup = screen.getByRole("group", {
name: /is the patient currently experiencing any symptoms\?/i,
});
await user.click(within(symptomsAoeGroup).getByText(/yes/i));
await user.click(screen.getByText("Submit results"));
expect(
screen.getAllByText(
"This question is required if the patient has symptoms"
).length
).toBe(2);

await user.click(
screen.getByRole("checkbox", {
name: /cough/i,
})
);
await user.click(screen.getByText("Submit results"));
expect(
screen.getAllByText(
"This question is required if the patient has symptoms"
).length
).toBe(1);

expect(
screen.queryByText(
"This question is required if the patient has symptoms"
)
).not.toBeInTheDocument();
await user.type(
screen.getByLabelText(/when did the patient's symptoms start\?/i),
TEST_CARD_SYMPTOM_ONSET_DATE_STRING
);

expect(
screen.queryByText(
"This question is required if the patient has symptoms"
)
).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ export const sharedTestOrderInfo = {
internalId: "1b02363b-ce71-4f30-a2d6-d82b56a91b39",
dateAdded: "2022-11-08 13:33:07.503",
deviceType: {
internalId: device1Id,
name: device1Name,
model: device1Name,
internalId: covidDeviceId,
name: covidDeviceName,
model: covidDeviceName,
testLength: 15,
},
specimenType: {
Expand Down

0 comments on commit 24b2213

Please sign in to comment.