From ec5d655650875024b0bba12d49bc0dfad4c670ab Mon Sep 17 00:00:00 2001 From: aisultankassenov Date: Sat, 4 Apr 2020 18:34:12 +0600 Subject: [PATCH 1/6] feat(patient): add appointment button --- src/locales/enUs/translations/patient/index.ts | 3 +++ src/patients/appointments/AppointmentsList.tsx | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/locales/enUs/translations/patient/index.ts b/src/locales/enUs/translations/patient/index.ts index 5605dc712a..283e8b8e5d 100644 --- a/src/locales/enUs/translations/patient/index.ts +++ b/src/locales/enUs/translations/patient/index.ts @@ -32,6 +32,9 @@ export default { new: 'New Related Person', relationshipType: 'Relationship Type', }, + appointments: { + new: 'Add Appointment', + }, allergies: { label: 'Allergies', new: 'Add Allergy', diff --git a/src/patients/appointments/AppointmentsList.tsx b/src/patients/appointments/AppointmentsList.tsx index 7224bce5f8..15355cd924 100644 --- a/src/patients/appointments/AppointmentsList.tsx +++ b/src/patients/appointments/AppointmentsList.tsx @@ -54,6 +54,20 @@ const AppointmentsList = (props: Props) => { return ( +
+
+ +
+
+
Date: Mon, 6 Apr 2020 15:19:02 +0600 Subject: [PATCH 2/6] feat(patient): change newAppointment button label and add tests --- .../appointments/NewAppointment.test.tsx | 64 +++++++++++++++++++ .../appointments/AppointmentsList.tsx | 6 +- 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/__tests__/patients/appointments/NewAppointment.test.tsx diff --git a/src/__tests__/patients/appointments/NewAppointment.test.tsx b/src/__tests__/patients/appointments/NewAppointment.test.tsx new file mode 100644 index 0000000000..1d7dcfaa56 --- /dev/null +++ b/src/__tests__/patients/appointments/NewAppointment.test.tsx @@ -0,0 +1,64 @@ +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 Permissions from 'model/Permissions' +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 mockStore = configureMockStore([thunk]) +const history = createMemoryHistory() + +let store: any + +const setup = (patient = expectedPatient) => { + store = mockStore({ patient }) + const wrapper = mount( + + + + + , + ) + + return wrapper +} + +describe('AppointmentsList', () => { + describe('add new appointment button', () => { + beforeEach(() => { + jest.resetAllMocks() + jest.spyOn(PatientRepository, 'saveOrUpdate') + }) + + it('should render a new appointment button', () => { + const wrapper = setup() + + const addNewAppointmentButton = wrapper.find(components.Button) + 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).prop('onClick')() + }) + wrapper.update() + + expect(history.location.pathname).toEqual('/appointments/new') + }) + }) +}) diff --git a/src/patients/appointments/AppointmentsList.tsx b/src/patients/appointments/AppointmentsList.tsx index 15355cd924..68152d2eaf 100644 --- a/src/patients/appointments/AppointmentsList.tsx +++ b/src/patients/appointments/AppointmentsList.tsx @@ -57,13 +57,13 @@ const AppointmentsList = (props: Props) => {
From af66ec68c5c34d87755205c3dfab3debce7bd393 Mon Sep 17 00:00:00 2001 From: aisultankassenov Date: Tue, 7 Apr 2020 16:22:19 +0600 Subject: [PATCH 3/6] fix(patient): appointments list tests --- .../appointments/NewAppointment.test.tsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/__tests__/patients/appointments/NewAppointment.test.tsx b/src/__tests__/patients/appointments/NewAppointment.test.tsx index 1d7dcfaa56..532c3c2d65 100644 --- a/src/__tests__/patients/appointments/NewAppointment.test.tsx +++ b/src/__tests__/patients/appointments/NewAppointment.test.tsx @@ -5,7 +5,6 @@ import { createMemoryHistory } from 'history' import configureMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import Patient from 'model/Patient' -import Permissions from 'model/Permissions' import { Router } from 'react-router' import { Provider } from 'react-redux' import AppointmentsList from 'patients/appointments/AppointmentsList' @@ -16,14 +15,25 @@ 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) => { - store = mockStore({ patient }) +const setup = (patient = expectedPatient, appointments = expectedAppointments) => { + store = mockStore({ patient, appointments: { appointments } }) const wrapper = mount( @@ -45,7 +55,7 @@ describe('AppointmentsList', () => { it('should render a new appointment button', () => { const wrapper = setup() - const addNewAppointmentButton = wrapper.find(components.Button) + const addNewAppointmentButton = wrapper.find(components.Button).at(0) expect(addNewAppointmentButton).toHaveLength(1) expect(addNewAppointmentButton.text().trim()).toEqual('scheduling.appointments.new') }) @@ -54,7 +64,10 @@ describe('AppointmentsList', () => { const wrapper = setup() act(() => { - wrapper.find(components.Button).prop('onClick')() + wrapper + .find(components.Button) + .at(0) + .prop('onClick')() }) wrapper.update() From 648681b25adec1897eb5612c322ddcba95afa73f Mon Sep 17 00:00:00 2001 From: aisultankassenov Date: Fri, 10 Apr 2020 13:58:12 +0600 Subject: [PATCH 4/6] refactor(patient): rename test and remove mock --- .../{NewAppointment.test.tsx => AppointmentsList.test.tsx} | 5 ----- 1 file changed, 5 deletions(-) rename src/__tests__/patients/appointments/{NewAppointment.test.tsx => AppointmentsList.test.tsx} (94%) diff --git a/src/__tests__/patients/appointments/NewAppointment.test.tsx b/src/__tests__/patients/appointments/AppointmentsList.test.tsx similarity index 94% rename from src/__tests__/patients/appointments/NewAppointment.test.tsx rename to src/__tests__/patients/appointments/AppointmentsList.test.tsx index 532c3c2d65..9c4187eeee 100644 --- a/src/__tests__/patients/appointments/NewAppointment.test.tsx +++ b/src/__tests__/patients/appointments/AppointmentsList.test.tsx @@ -47,11 +47,6 @@ const setup = (patient = expectedPatient, appointments = expectedAppointments) = describe('AppointmentsList', () => { describe('add new appointment button', () => { - beforeEach(() => { - jest.resetAllMocks() - jest.spyOn(PatientRepository, 'saveOrUpdate') - }) - it('should render a new appointment button', () => { const wrapper = setup() From 21fe92b6c93dfbb7ae31174f4dd723b0256df98d Mon Sep 17 00:00:00 2001 From: aisultankassenov Date: Tue, 14 Apr 2020 14:59:59 +0600 Subject: [PATCH 5/6] style(patient): change new appointment button position --- .../appointments/AppointmentsList.tsx | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/patients/appointments/AppointmentsList.tsx b/src/patients/appointments/AppointmentsList.tsx index 1163793767..4b964fdfba 100644 --- a/src/patients/appointments/AppointmentsList.tsx +++ b/src/patients/appointments/AppointmentsList.tsx @@ -53,7 +53,7 @@ const AppointmentsList = (props: Props) => { } return ( - + <>

+ + + + + + + + + + + -
- - - - - - + + {list} + -
- - - - {list} - - -
+
+ ) } From 06d3c8692733cc0b301bdf4187adfc1f08930e94 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Thu, 16 Apr 2020 19:55:40 +0200 Subject: [PATCH 6/6] chore(lint): lint file --- .../patients/appointments/AppointmentsList.test.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/__tests__/patients/appointments/AppointmentsList.test.tsx b/src/__tests__/patients/appointments/AppointmentsList.test.tsx index 9c4187eeee..55697d7f1b 100644 --- a/src/__tests__/patients/appointments/AppointmentsList.test.tsx +++ b/src/__tests__/patients/appointments/AppointmentsList.test.tsx @@ -10,7 +10,7 @@ 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' +// import PatientRepository from 'clients/db/PatientRepository' # Lint warning: 'PatientRepository' is defined but never used const expectedPatient = { id: '123', @@ -59,10 +59,7 @@ describe('AppointmentsList', () => { const wrapper = setup() act(() => { - wrapper - .find(components.Button) - .at(0) - .prop('onClick')() + wrapper.find(components.Button).at(0).prop('onClick')() }) wrapper.update()