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

fix(labs): Cleanup small issues with lab section #2010

Merged
merged 31 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
08df8c5
fix(#1946): patients can also be related person
alti21 Apr 2, 2020
82f3c98
Merge branch 'master' into master
Apr 3, 2020
cdd1be8
Merge branch 'master' into master
Apr 3, 2020
c6d2b83
Merge branch 'master' into master
Apr 3, 2020
60e18fc
Merge branch 'master' into master
Apr 3, 2020
51771de
Merge branch 'master' into master
Apr 3, 2020
476de1a
Merge branch 'master' into master
Apr 3, 2020
534c9de
fix(patients): current patient can't be related person
alti21 Apr 4, 2020
2985c00
Merge branch 'master' of https://github.com/alti21/hospitalrun-frontend
alti21 Apr 4, 2020
32a568e
Merge branch 'master' into master
Apr 6, 2020
b4c31dc
Merge branch 'master' into master
Apr 6, 2020
666a9b8
Merge branch 'master' into master
Apr 7, 2020
46f72e9
Merge branch 'master' into master
Apr 8, 2020
3c403bc
Merge branch 'master' into master
Apr 8, 2020
4a168ed
Merge branch 'master' into master
Apr 8, 2020
27ad2b7
Merge branch 'master' into master
Apr 9, 2020
af67dac
Merge branch 'master' into master
Apr 9, 2020
fd195f2
fix(patients): added test for patient not showing in list
alti21 Apr 10, 2020
d36bcc0
Merge branch 'master' of https://github.com/alti21/hospitalrun-frontend
alti21 Apr 10, 2020
6ad726a
fix(patient): removed unnecessary comment
alti21 Apr 10, 2020
746b828
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
62dc561
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
5a8d701
Merge remote-tracking branch 'upstream/master'
alti21 Apr 10, 2020
91e74e9
Merge remote-tracking branch 'upstream/master'
alti21 Apr 15, 2020
97ea2ab
Merge remote-tracking branch 'upstream/master'
alti21 Apr 22, 2020
8f49b46
fix((labs): cleanup small issues with lab section
alti21 Apr 23, 2020
c4ebefe
Merge remote-tracking branch 'upstream/master'
alti21 Apr 23, 2020
c6a8dc4
Merge branch 'master' into master
Apr 24, 2020
a502e0d
Merge branch 'master' into master
Apr 24, 2020
b4411a9
Merge branch 'master' into master
Apr 24, 2020
ac123e2
fix(labs): fix linter issues
alti21 Apr 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions src/__tests__/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(1).text().trim()).toEqual('dashboard.label')
expect(
listItems
.at(1)
.text()
.trim(),
).toEqual('dashboard.label')
})

it('should be active when the current path is /', () => {
Expand Down Expand Up @@ -66,23 +71,38 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(2).text().trim()).toEqual('patients.label')
expect(
listItems
.at(2)
.text()
.trim(),
).toEqual('patients.label')
})

it('should render the new_patient link', () => {
const wrapper = setup('/patients')

const listItems = wrapper.find(ListItem)

expect(listItems.at(3).text().trim()).toEqual('patients.newPatient')
expect(
listItems
.at(3)
.text()
.trim(),
).toEqual('patients.newPatient')
})

it('should render the patients_list link', () => {
const wrapper = setup('/patients')

const listItems = wrapper.find(ListItem)

expect(listItems.at(4).text().trim()).toEqual('patients.patientsList')
expect(
listItems
.at(4)
.text()
.trim(),
).toEqual('patients.patientsList')
})

it('main patients link should be active when the current path is /patients', () => {
Expand Down Expand Up @@ -155,23 +175,38 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(3).text().trim()).toEqual('scheduling.label')
expect(
listItems
.at(3)
.text()
.trim(),
).toEqual('scheduling.label')
})

it('should render the new appointment link', () => {
const wrapper = setup('/appointments/new')

const listItems = wrapper.find(ListItem)

expect(listItems.at(4).text().trim()).toEqual('scheduling.appointments.new')
expect(
listItems
.at(4)
.text()
.trim(),
).toEqual('scheduling.appointments.new')
})

it('should render the appointments schedule link', () => {
const wrapper = setup('/appointments')

const listItems = wrapper.find(ListItem)

expect(listItems.at(5).text().trim()).toEqual('scheduling.appointments.schedule')
expect(
listItems
.at(5)
.text()
.trim(),
).toEqual('scheduling.appointments.schedule')
})

it('main scheduling link should be active when the current path is /appointments', () => {
Expand Down Expand Up @@ -244,23 +279,38 @@ describe('Sidebar', () => {

const listItems = wrapper.find(ListItem)

expect(listItems.at(4).text().trim()).toEqual('labs.label')
expect(
listItems
.at(4)
.text()
.trim(),
).toEqual('labs.label')
})

it('should render the new labs request link', () => {
const wrapper = setup('/labs')

const listItems = wrapper.find(ListItem)

expect(listItems.at(5).text().trim()).toEqual('labs.requests.new')
expect(
listItems
.at(5)
.text()
.trim(),
).toEqual('labs.requests.new')
})

it('should render the labs list link', () => {
const wrapper = setup('/labs')

const listItems = wrapper.find(ListItem)

expect(listItems.at(6).text().trim()).toEqual('labs.requests.label')
expect(
listItems
.at(6)
.text()
.trim(),
).toEqual('labs.requests.label')
})

it('main labs link should be active when the current path is /labs', () => {
Expand Down
132 changes: 103 additions & 29 deletions src/__tests__/labs/ViewLab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,57 @@ describe('View Labs', () => {
const expectedLab = { ...mockLab } as Lab
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const forPatientDiv = wrapper.find('.for-patient')
expect(forPatientDiv.find('h4').text().trim()).toEqual('labs.lab.for')

expect(forPatientDiv.find('h5').text().trim()).toEqual(mockPatient.fullName)
expect(
forPatientDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.for')

expect(
forPatientDiv
.find('h5')
.text()
.trim(),
).toEqual(mockPatient.fullName)
})

it('should display the lab type for type', async () => {
const expectedLab = { ...mockLab, type: 'expected type' } as Lab
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const labTypeDiv = wrapper.find('.lab-type')
expect(labTypeDiv.find('h4').text().trim()).toEqual('labs.lab.type')

expect(labTypeDiv.find('h5').text().trim()).toEqual(expectedLab.type)
expect(
labTypeDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.type')

expect(
labTypeDiv
.find('h5')
.text()
.trim(),
).toEqual(expectedLab.type)
})

it('should display the requested on date', async () => {
const expectedLab = { ...mockLab, requestedOn: '2020-03-30T04:43:20.102Z' } as Lab
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const requestedOnDiv = wrapper.find('.requested-on')
expect(requestedOnDiv.find('h4').text().trim()).toEqual('labs.lab.requestedOn')

expect(requestedOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'),
)
expect(
requestedOnDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.requestedOn')

expect(
requestedOnDiv
.find('h5')
.text()
.trim(),
).toEqual(format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'))
})

it('should not display the completed date if the lab is not completed', async () => {
Expand Down Expand Up @@ -177,7 +205,12 @@ describe('View Labs', () => {
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const labStatusDiv = wrapper.find('.lab-status')
const badge = labStatusDiv.find(Badge)
expect(labStatusDiv.find('h4').text().trim()).toEqual('labs.lab.status')
expect(
labStatusDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.status')

expect(badge.prop('color')).toEqual('warning')
expect(badge.text().trim()).toEqual(expectedLab.status)
Expand All @@ -193,11 +226,26 @@ describe('View Labs', () => {
])

const buttons = wrapper.find(Button)
expect(buttons.at(0).text().trim()).toEqual('actions.update')

expect(buttons.at(1).text().trim()).toEqual('labs.requests.complete')

expect(buttons.at(2).text().trim()).toEqual('labs.requests.cancel')
expect(
buttons
.at(0)
.text()
.trim(),
).toEqual('actions.update')

expect(
buttons
.at(1)
.text()
.trim(),
).toEqual('labs.requests.complete')

expect(
buttons
.at(2)
.text()
.trim(),
).toEqual('labs.requests.cancel')
})
})

Expand All @@ -208,7 +256,12 @@ describe('View Labs', () => {

const labStatusDiv = wrapper.find('.lab-status')
const badge = labStatusDiv.find(Badge)
expect(labStatusDiv.find('h4').text().trim()).toEqual('labs.lab.status')
expect(
labStatusDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.status')

expect(badge.prop('color')).toEqual('danger')
expect(badge.text().trim()).toEqual(expectedLab.status)
Expand All @@ -223,11 +276,19 @@ describe('View Labs', () => {
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const canceledOnDiv = wrapper.find('.canceled-on')

expect(canceledOnDiv.find('h4').text().trim()).toEqual('labs.lab.canceledOn')

expect(canceledOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.canceledOn as string), 'yyyy-MM-dd hh:mm a'),
)
expect(
canceledOnDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.canceledOn')

expect(
canceledOnDiv
.find('h5')
.text()
.trim(),
).toEqual(format(new Date(expectedLab.canceledOn as string), 'yyyy-MM-dd hh:mm a'))
})

it('should not display update, complete, and cancel button if the lab is canceled', async () => {
Expand Down Expand Up @@ -259,7 +320,12 @@ describe('View Labs', () => {
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const labStatusDiv = wrapper.find('.lab-status')
const badge = labStatusDiv.find(Badge)
expect(labStatusDiv.find('h4').text().trim()).toEqual('labs.lab.status')
expect(
labStatusDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.status')

expect(badge.prop('color')).toEqual('primary')
expect(badge.text().trim()).toEqual(expectedLab.status)
Expand All @@ -274,11 +340,19 @@ describe('View Labs', () => {
const wrapper = await setup(expectedLab, [Permissions.ViewLab])
const completedOnDiv = wrapper.find('.completed-on')

expect(completedOnDiv.find('h4').text().trim()).toEqual('labs.lab.completedOn')

expect(completedOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.completedOn as string), 'yyyy-MM-dd hh:mm a'),
)
expect(
completedOnDiv
.find('h4')
.text()
.trim(),
).toEqual('labs.lab.completedOn')

expect(
completedOnDiv
.find('h5')
.text()
.trim(),
).toEqual(format(new Date(expectedLab.completedOn as string), 'yyyy-MM-dd hh:mm a'))
})

it('should not display update, complete, and cancel buttons if the lab is completed', async () => {
Expand Down
54 changes: 41 additions & 13 deletions src/__tests__/labs/ViewLabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,47 @@ describe('View Labs', () => {
expect(table).toBeDefined()
expect(tableHeader).toBeDefined()
expect(tableBody).toBeDefined()
expect(tableColumnHeaders.at(0).text().trim()).toEqual('labs.lab.type')

expect(tableColumnHeaders.at(1).text().trim()).toEqual('labs.lab.requestedOn')

expect(tableColumnHeaders.at(2).text().trim()).toEqual('labs.lab.status')

expect(tableDataColumns.at(0).text().trim()).toEqual(expectedLab.type)

expect(tableDataColumns.at(1).text().trim()).toEqual(
format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'),
)

expect(tableDataColumns.at(2).text().trim()).toEqual(expectedLab.status)
expect(
tableColumnHeaders
.at(0)
.text()
.trim(),
).toEqual('labs.lab.type')

expect(
tableColumnHeaders
.at(1)
.text()
.trim(),
).toEqual('labs.lab.requestedOn')

expect(
tableColumnHeaders
.at(2)
.text()
.trim(),
).toEqual('labs.lab.status')

expect(
tableDataColumns
.at(0)
.text()
.trim(),
).toEqual(expectedLab.type)

expect(
tableDataColumns
.at(1)
.text()
.trim(),
).toEqual(format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'))

expect(
tableDataColumns
.at(2)
.text()
.trim(),
).toEqual(expectedLab.status)
})

it('should navigate to the lab when the row is clicked', () => {
Expand Down
Loading