From 8f100d35a0eef86637804b0db1be79308e17e551 Mon Sep 17 00:00:00 2001 From: Hemant Pandey Date: Tue, 31 Mar 2020 01:50:14 -0700 Subject: [PATCH] style(component): change New Related Person Button to Add : #1856 Added label in English for Add Related person button, Added label to modal and renamed NewRelatedPersonModal to AddRelatedPersonModal fix #1856 --- ...l.test.tsx => AddRelatedPersonModal.test.tsx} | 14 ++++++++------ .../related-persons/RelatedPersons.test.tsx | 16 ++++++++-------- src/locales/enUs/translations/patient/index.ts | 1 + ...PersonModal.tsx => AddRelatedPersonModal.tsx} | 8 ++++---- .../related-persons/RelatedPersonTab.tsx | 6 +++--- 5 files changed, 24 insertions(+), 21 deletions(-) rename src/__tests__/patients/related-persons/{NewRelatedPersonModal.test.tsx => AddRelatedPersonModal.test.tsx} (91%) rename src/patients/related-persons/{NewRelatedPersonModal.tsx => AddRelatedPersonModal.tsx} (94%) diff --git a/src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx similarity index 91% rename from src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx rename to src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx index 1f7b48a2f3..19a0ae75c4 100644 --- a/src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx +++ b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx @@ -3,15 +3,15 @@ import React from 'react' import { ReactWrapper, mount } from 'enzyme' import { Modal, Alert, Typeahead } from '@hospitalrun/components' import { act } from '@testing-library/react' -import NewRelatedPersonModal from '../../../patients/related-persons/NewRelatedPersonModal' +import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -describe('New Related Person Modal', () => { +describe('Add Related Person Modal', () => { describe('layout', () => { let wrapper: ReactWrapper beforeEach(() => { wrapper = mount( - { }) it('should render a cancel button', () => { - const cancelButton = wrapper.findWhere((w) => w.text() === 'actions.cancel') + const cancelButton = wrapper.findWhere( + (w: { text: () => string }) => w.text() === 'actions.cancel', + ) expect(cancelButton).toHaveLength(1) }) it('should render an add new related person button button', () => { const modal = wrapper.find(Modal) - expect(modal.prop('successButton').children).toEqual('patient.relatedPersons.new') + expect(modal.prop('successButton').children).toEqual('patient.relatedPersons.add') }) }) @@ -63,7 +65,7 @@ describe('New Related Person Modal', () => { beforeEach(() => { onSaveSpy = jest.fn() wrapper = mount( - { const newRelatedPersonButton = wrapper.find(components.Button) expect(newRelatedPersonButton).toHaveLength(1) - expect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.new') + expect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.add') }) it('should not render a New Related Person button if the user does not have write privileges for a patient', () => { @@ -77,7 +77,7 @@ describe('Related Persons Tab', () => { }) it('should render a New Related Person modal', () => { - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) expect(newRelatedPersonModal.prop('show')).toBeFalsy() expect(newRelatedPersonModal).toHaveLength(1) @@ -92,7 +92,7 @@ describe('Related Persons Tab', () => { wrapper.update() - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) expect(newRelatedPersonModal.prop('show')).toBeTruthy() }) @@ -124,7 +124,7 @@ describe('Related Persons Tab', () => { wrapper.update() await act(async () => { - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) const onSave = newRelatedPersonModal.prop('onSave') as any onSave(expectedRelatedPerson) }) @@ -145,20 +145,20 @@ describe('Related Persons Tab', () => { wrapper.update() act(() => { - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) const onSave = newRelatedPersonModal.prop('onSave') as any onSave({ patientId: '123', type: 'type' }) }) wrapper.update() - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) expect(newRelatedPersonModal.prop('show')).toBeFalsy() }) it('should display a success message when the new related person is added', async () => { await act(async () => { - const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal) + const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal) const onSave = newRelatedPersonModal.prop('onSave') as any await onSave({ patientId: 'testMessage', type: 'type' }) }) diff --git a/src/locales/enUs/translations/patient/index.ts b/src/locales/enUs/translations/patient/index.ts index cd0a98c971..52b4d0fda8 100644 --- a/src/locales/enUs/translations/patient/index.ts +++ b/src/locales/enUs/translations/patient/index.ts @@ -30,6 +30,7 @@ export default { }, label: 'Related Persons', new: 'New Related Person', + add: 'Add Related Person', relationshipType: 'Relationship Type', warning: { noRelatedPersons: 'No related persons', diff --git a/src/patients/related-persons/NewRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx similarity index 94% rename from src/patients/related-persons/NewRelatedPersonModal.tsx rename to src/patients/related-persons/AddRelatedPersonModal.tsx index 53ad24a2d5..d4e652fd28 100644 --- a/src/patients/related-persons/NewRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -13,7 +13,7 @@ interface Props { onSave: (relatedPerson: RelatedPerson) => void } -const NewRelatedPersonModal = (props: Props) => { +const AddRelatedPersonModal = (props: Props) => { const { show, toggle, onCloseButtonClick, onSave } = props const { t } = useTranslation() const [errorMessage, setErrorMessage] = useState('') @@ -78,7 +78,7 @@ const NewRelatedPersonModal = (props: Props) => { { onClick: onCloseButtonClick, }} successButton={{ - children: t('patient.relatedPersons.new'), + children: t('patient.relatedPersons.add'), color: 'success', icon: 'add', iconLocation: 'left', @@ -111,4 +111,4 @@ const NewRelatedPersonModal = (props: Props) => { ) } -export default NewRelatedPersonModal +export default AddRelatedPersonModal diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index 7e8aad4d9b..47b7ea6c6a 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react' import { Button, Panel, List, ListItem, Alert, Spinner, Toast } from '@hospitalrun/components' -import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal' +import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModal' import RelatedPerson from 'model/RelatedPerson' import { useTranslation } from 'react-i18next' import { useHistory } from 'react-router' @@ -100,7 +100,7 @@ const RelatedPersonTab = (props: Props) => { iconLocation="left" onClick={onNewRelatedPersonClick} > - {t('patient.relatedPersons.new')} + {t('patient.relatedPersons.add')} )} @@ -132,7 +132,7 @@ const RelatedPersonTab = (props: Props) => { -