Skip to content

Commit 1e5a545

Browse files
Merge branch 'main' into fix/AEA-5861_temp_disable_B0401
2 parents f86fa3c + 466a9e1 commit 1e5a545

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/cpt-ui/__tests__/BasicDetailsSearch.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,26 @@ describe("BasicDetailsSearch", () => {
273273
expect(screen.getAllByText(expectedError)).toHaveLength(2)
274274
}
275275
)
276+
277+
it("accepts valid DOB when day and month are single digits (e.g., 1-1-2000", async () => {
278+
const mockNavigate = jest.fn()
279+
;(useNavigate as jest.Mock).mockReturnValue(mockNavigate)
280+
281+
renderWithRouter(<BasicDetailsSearch />, defaultSearchState)
282+
283+
await fillForm({
284+
lastName: "Keary",
285+
dobDay: "1",
286+
dobMonth: "1",
287+
dobYear: "2012",
288+
postcode: "LS6 1JL"
289+
})
290+
await submitForm()
291+
292+
await waitFor(() => {
293+
expect(mockNavigate).toHaveBeenCalledWith(FRONTEND_PATHS.PATIENT_SEARCH_RESULTS)
294+
})
295+
})
276296
})
277297

278298
it("shows error for DOB in the future", async () => {

packages/cpt-ui/src/components/prescriptionSearch/BasicDetailsSearch.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,15 @@ export default function BasicDetailsSearch() {
126126
return
127127
}
128128

129+
//API requires a 2 digit format i.e. 06 instead of 6 for June
130+
const formattedDobDay = dobDay.padStart(2, "0")
131+
const formattedDobMonth = dobMonth.padStart(2, "0")
132+
129133
searchContext.clearSearchParameters()
130134
searchContext.setFirstName(firstName)
131135
searchContext.setLastName(lastName)
132-
searchContext.setDobDay(dobDay)
133-
searchContext.setDobMonth(dobMonth)
136+
searchContext.setDobDay(formattedDobDay)
137+
searchContext.setDobMonth(formattedDobMonth)
134138
searchContext.setDobYear(dobYear)
135139
searchContext.setPostcode(postcode)
136140
navigate(FRONTEND_PATHS.PATIENT_SEARCH_RESULTS)

0 commit comments

Comments
 (0)