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

feat(patient): add appointment button #1964

Merged
merged 27 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ec5d655
feat(patient): add appointment button
oizuldan Apr 4, 2020
1704ccb
feat(patient): change newAppointment button label and add tests
oizuldan Apr 6, 2020
9b7f416
Merge branch 'master' into master
oizuldan Apr 6, 2020
879cf0c
Merge branch 'master' into master
Apr 6, 2020
efc1f8b
Merge branch 'master' into master
Apr 6, 2020
0fa3378
Merge branch 'master' into master
Apr 7, 2020
af66ec6
fix(patient): appointments list tests
oizuldan Apr 7, 2020
b0ddff7
Merge branch 'master' of https://github.com/oizuldan/hospitalrun-fron…
oizuldan Apr 7, 2020
70d6157
Merge branch 'master' into master
Apr 8, 2020
b332f24
Merge branch 'master' into master
Apr 8, 2020
e7a3e29
Merge branch 'master' into master
Apr 8, 2020
eff89a8
Merge branch 'master' into master
Apr 9, 2020
e4a43ad
Merge branch 'master' into master
Apr 9, 2020
648681b
refactor(patient): rename test and remove mock
oizuldan Apr 10, 2020
f711854
Merge branch 'master' into master
Apr 10, 2020
0c5ffa7
Merge branch 'master' into master
Apr 10, 2020
05e4f03
Merge branch 'master' into master
Apr 10, 2020
fa64765
Merge branch 'master' into master
Apr 11, 2020
41a6c08
Merge branch 'master' into master
Apr 12, 2020
0e05b64
Merge branch 'master' into master
Apr 13, 2020
ba241d2
Merge branch 'master' into master
Apr 13, 2020
21fe92b
style(patient): change new appointment button position
oizuldan Apr 14, 2020
1bfa956
Merge branch 'master' into master
Apr 14, 2020
295b1c0
Merge branch 'master' into master
Apr 15, 2020
9db6cbb
Merge branch 'master' into master
Apr 16, 2020
1fe9281
Merge branch 'master' into master
Apr 16, 2020
06d3c86
chore(lint): lint file
matteovivona Apr 16, 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
72 changes: 72 additions & 0 deletions src/__tests__/patients/appointments/AppointmentsList.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import '../../../__mocks__/matchMediaMock'
import React from 'react'
import { mount } from 'enzyme'
import { createMemoryHistory } from 'history'
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import Patient from 'model/Patient'
import { Router } from 'react-router'
import { Provider } from 'react-redux'
import AppointmentsList from 'patients/appointments/AppointmentsList'
import * as components from '@hospitalrun/components'
import { act } from 'react-dom/test-utils'
import PatientRepository from 'clients/db/PatientRepository'

const expectedPatient = {
id: '123',
} as Patient
const expectedAppointments = [
{
id: '123',
rev: '1',
patientId: '1234',
startDateTime: new Date().toISOString(),
endDateTime: new Date().toISOString(),
location: 'location',
reason: 'reason',
},
]

const mockStore = configureMockStore([thunk])
const history = createMemoryHistory()

let store: any

const setup = (patient = expectedPatient, appointments = expectedAppointments) => {
store = mockStore({ patient, appointments: { appointments } })
const wrapper = mount(
<Router history={history}>
<Provider store={store}>
<AppointmentsList patientId={patient.id} />
</Provider>
</Router>,
)

return wrapper
}

describe('AppointmentsList', () => {
describe('add new appointment button', () => {
it('should render a new appointment button', () => {
const wrapper = setup()

const addNewAppointmentButton = wrapper.find(components.Button).at(0)
expect(addNewAppointmentButton).toHaveLength(1)
expect(addNewAppointmentButton.text().trim()).toEqual('scheduling.appointments.new')
})

it('should navigate to new appointment page', () => {
const wrapper = setup()

act(() => {
wrapper
.find(components.Button)
.at(0)
.prop('onClick')()
})
wrapper.update()

expect(history.location.pathname).toEqual('/appointments/new')
})
})
})
3 changes: 3 additions & 0 deletions src/locales/enUs/translations/patient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default {
},
addRelatedPersonAbove: 'Add a related person using the button above.',
},
appointments: {
new: 'Add Appointment',
},
allergies: {
label: 'Allergies',
allergyName: 'Allergy Name',
Expand Down
64 changes: 40 additions & 24 deletions src/patients/appointments/AppointmentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,48 @@ const AppointmentsList = (props: Props) => {
}

return (
<Container>
<form className="form" onSubmit={onSearchFormSubmit}>
<>
<div className="row">
<div className="col-md-12 d-flex justify-content-end">
<Button
key="newAppointmentButton"
outlined
color="success"
icon="appointment-add"
onClick={() => history.push('/appointments/new')}
>
{t('scheduling.appointments.new')}
</Button>
</div>
</div>
<br />
<Container>
<form className="form" onSubmit={onSearchFormSubmit}>
<Row>
<Column md={10}>
<TextInput
size="lg"
type="text"
onChange={onSearchBoxChange}
value={searchText}
placeholder={t('actions.search')}
/>
</Column>
<Column md={2}>
<Button size="large" onClick={onSearchFormSubmit}>
{t('actions.search')}
</Button>
</Column>
</Row>
</form>

<Row>
<Column md={10}>
<TextInput
size="lg"
type="text"
onChange={onSearchBoxChange}
value={searchText}
placeholder={t('actions.search')}
/>
</Column>
<Column md={2}>
<Button size="large" onClick={onSearchFormSubmit}>
{t('actions.search')}
</Button>
</Column>
<List layout="flush" style={{ width: '100%', marginTop: '10px', marginLeft: '-25px' }}>
{list}
</List>
</Row>
</form>

<Row>
<List layout="flush" style={{ width: '100%', marginTop: '10px', marginLeft: '-25px' }}>
{list}
</List>
</Row>
</Container>
</Container>
</>
)
}

Expand Down