Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(lab): required visit not enforced
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Qian authored and Samuel Qian committed Feb 24, 2021
1 parent 10c3324 commit df56f03
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": false,
"license": "MIT",
"dependencies": {
"@hospitalrun/components": "~3.3.0",
"@hospitalrun/components": "~3.4.0",
"@reduxjs/toolkit": "~1.5.0",
"@types/escape-string-regexp": "~2.0.1",
"@types/json2csv": "~5.0.1",
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/labs/requests/NewLabRequest.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ describe('New Lab Request', () => {
message: 'some message',
patient: 'some patient message',
type: 'some type error',
visit: 'some visit error',
} as LabError

it('should display errors', async () => {
Expand All @@ -198,13 +199,16 @@ describe('New Lab Request', () => {
const alert = await screen.findByRole('alert')
const patientInput = screen.getByPlaceholderText(/labs\.lab\.patient/i)
const typeInput = screen.getByLabelText(/labs\.lab\.type/i)
const visit = screen.getByPlaceholderText('-- Choose --')

expect(within(alert).getByText(error.message)).toBeInTheDocument()
expect(within(alert).getByText(/states\.error/i)).toBeInTheDocument()
expect(alert).toHaveClass('alert-danger')
expect(patientInput).toHaveClass('is-invalid')
expect(typeInput).toHaveClass('is-invalid')
expect(typeInput.nextSibling).toHaveTextContent(error.type as string)
expect(visit).toHaveClass('is-invalid')
screen.getByText(error.visit as string)
})
})

Expand Down
1 change: 1 addition & 0 deletions src/labs/requests/NewLabRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const NewLabRequest = () => {
isRequired
isEditable={newLabRequest.patient !== undefined}
isInvalid={!!error?.visit}
feedback={t(error?.visit as string)}
options={visitOptions || []}
defaultSelected={defaultSelectedVisitsOption()}
onChange={(values) => {
Expand Down
3 changes: 3 additions & 0 deletions src/shared/components/input/SelectWithLabelFormGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Props {
multiple?: boolean
isEditable?: boolean
isInvalid?: boolean
feedback?: string
}

const SelectWithLabelFormGroup = (props: Props) => {
Expand All @@ -32,6 +33,7 @@ const SelectWithLabelFormGroup = (props: Props) => {
multiple,
isEditable,
isInvalid,
feedback,
} = props
const id = `${name}Select`
return (
Expand All @@ -46,6 +48,7 @@ const SelectWithLabelFormGroup = (props: Props) => {
multiple={multiple}
disabled={!isEditable}
isInvalid={isInvalid}
feedback={feedback}
/>
</div>
)
Expand Down

0 comments on commit df56f03

Please sign in to comment.