-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
2,206 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ describe("Add Patient: All required fields entered and submitting address verifi | |
"Email address": "[email protected]", | ||
"Street address 1": "25 Shattuck St", | ||
City: "Boston", | ||
|
||
"ZIP code": "02115", | ||
Notes: "Green tent", | ||
}, | ||
{ Facility: mockFacilityID, State: "MA", Country: "USA" }, | ||
{ | ||
|
@@ -155,7 +155,6 @@ describe("Add Patient: All required fields entered and submitting address verifi | |
"Email address": "[email protected]", | ||
"Street address 1": "25 Shattuck St", | ||
City: "Boston", | ||
|
||
"ZIP code": "02115", | ||
}, | ||
{ Facility: mockFacilityID, State: "MA", Country: "USA" }, | ||
|
178 changes: 178 additions & 0 deletions
178
frontend/src/app/patients/AddPatientStartsTest.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import { screen, waitFor, within } from "@testing-library/react"; | ||
import * as router from "react-router"; | ||
|
||
import * as smartyStreets from "../utils/smartyStreets"; | ||
|
||
import { | ||
fillOutForm, | ||
mockFacilityID, | ||
renderWithUserWithFacility, | ||
} from "./AddPatientTestUtils"; | ||
|
||
describe("Add Patient: saving changes and starting a test", () => { | ||
const mockNavigate = jest.fn(); | ||
beforeEach(async () => { | ||
jest.spyOn(smartyStreets, "getBestSuggestion").mockImplementation(); | ||
jest.spyOn(smartyStreets, "suggestionIsCloseEnough").mockReturnValue(false); | ||
jest.spyOn(smartyStreets, "getZipCodeData").mockResolvedValue(undefined); | ||
|
||
jest.spyOn(router, "useNavigate").mockImplementation(() => mockNavigate); | ||
}); | ||
|
||
it("redirects to the queue after address validation", async () => { | ||
jest.spyOn(smartyStreets, "suggestionIsCloseEnough").mockReturnValue(true); | ||
const { user } = renderWithUserWithFacility(); | ||
await fillOutForm( | ||
{ | ||
"First Name": "Alice", | ||
"Last Name": "Hamilton", | ||
"Date of birth": "1970-09-22", | ||
"Primary phone number": "617-432-1000", | ||
"Email address": "[email protected]", | ||
"Street address 1": "25 Shattuck St", | ||
City: "Boston", | ||
"ZIP code": "02115", | ||
notes: "Green tent", | ||
}, | ||
{ Facility: mockFacilityID, State: "MA", Country: "USA" }, | ||
{ | ||
"Phone type": { | ||
label: "Mobile", | ||
value: "MOBILE", | ||
exact: true, | ||
}, | ||
"Would you like to receive your results via text message?": { | ||
label: "Yes", | ||
value: "SMS", | ||
exact: false, | ||
}, | ||
Race: { | ||
label: "Other", | ||
value: "other", | ||
exact: true, | ||
}, | ||
"Are you Hispanic or Latino?": { | ||
label: "Prefer not to answer", | ||
value: "refused", | ||
exact: true, | ||
}, | ||
"Sex assigned at birth": { | ||
label: "Female", | ||
value: "female", | ||
exact: true, | ||
}, | ||
"What's your gender identity?": { | ||
label: "Female", | ||
value: "female", | ||
exact: true, | ||
}, | ||
} | ||
); | ||
|
||
await user.click( | ||
screen.queryAllByText("Save and start test", { | ||
exact: false, | ||
})[0] | ||
); | ||
|
||
expect( | ||
screen.queryByText("Address validation", { | ||
exact: false, | ||
}) | ||
).not.toBeInTheDocument(); | ||
|
||
await waitFor(() => | ||
expect(mockNavigate).toHaveBeenCalledWith( | ||
"/queue?facility=facility-id-001", | ||
{ | ||
state: { | ||
patientId: "153f661f-b6ea-4711-b9ab-487b95198cce", | ||
}, | ||
} | ||
) | ||
); | ||
}); | ||
|
||
it("redirects to the queue with a patient id and selected facility id", async () => { | ||
const { user } = renderWithUserWithFacility(); | ||
await fillOutForm( | ||
{ | ||
"First Name": "Alice", | ||
"Last Name": "Hamilton", | ||
"Date of birth": "1970-09-22", | ||
"Primary phone number": "617-432-1000", | ||
"Email address": "[email protected]", | ||
"Street address 1": "25 Shattuck St", | ||
City: "Boston", | ||
"ZIP code": "02115", | ||
notes: "Green tent", | ||
}, | ||
{ Facility: mockFacilityID, State: "MA", Country: "USA" }, | ||
{ | ||
"Phone type": { | ||
label: "Mobile", | ||
value: "MOBILE", | ||
exact: true, | ||
}, | ||
"Would you like to receive your results via text message?": { | ||
label: "Yes", | ||
value: "SMS", | ||
exact: false, | ||
}, | ||
Race: { | ||
label: "Other", | ||
value: "other", | ||
exact: true, | ||
}, | ||
"Are you Hispanic or Latino?": { | ||
label: "Prefer not to answer", | ||
value: "refused", | ||
exact: true, | ||
}, | ||
"Sex assigned at birth": { | ||
label: "Female", | ||
value: "female", | ||
exact: true, | ||
}, | ||
"What's your gender identity?": { | ||
label: "Female", | ||
value: "female", | ||
exact: true, | ||
}, | ||
} | ||
); | ||
await user.click( | ||
screen.queryAllByText("Save and start test", { | ||
exact: false, | ||
})[0] | ||
); | ||
expect( | ||
await screen.findByText("Address validation", { | ||
exact: false, | ||
}) | ||
).toBeInTheDocument(); | ||
|
||
const modal = screen.getByRole("dialog"); | ||
|
||
await user.click( | ||
within(modal).getByLabelText("Use address as entered", { | ||
exact: false, | ||
}) | ||
); | ||
await user.click( | ||
within(modal).getByText("Save changes", { | ||
exact: false, | ||
}) | ||
); | ||
await waitFor(() => | ||
expect(mockNavigate).toHaveBeenCalledWith( | ||
"/queue?facility=facility-id-001", | ||
{ | ||
state: { | ||
patientId: "153f661f-b6ea-4711-b9ab-487b95198cce", | ||
}, | ||
} | ||
) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.