diff --git a/src/test.util.tsx b/src/__mocks__/test.util.ts similarity index 100% rename from src/test.util.tsx rename to src/__mocks__/test.util.ts diff --git a/src/constants.ts b/src/constants.ts index 7c57473..337a656 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,3 @@ export const spaRoot = window['getOpenmrsSpaBase'](); export const historyBasePath = '/patient/:patientUuid/chart'; -export const historyDashboardPath = `${historyBasePath}/:view/*`; \ No newline at end of file +export const historyDashboardPath = `${historyBasePath}/:view/*`; diff --git a/src/dashboard.meta.ts b/src/dashboard.meta.ts index 0a88499..7bed5b7 100644 --- a/src/dashboard.meta.ts +++ b/src/dashboard.meta.ts @@ -3,4 +3,3 @@ export const dashboardMeta = { path: 'Patient History', title: 'Patient History', }; - diff --git a/src/history/history-detail-overview.component.tsx b/src/history/history-detail-overview.component.tsx index c9ffece..f7b5cf1 100644 --- a/src/history/history-detail-overview.component.tsx +++ b/src/history/history-detail-overview.component.tsx @@ -52,33 +52,30 @@ const HistoryDetailOverview: React.FC = () => { setIsSubmitting(true); createIpsResource(uuid, abortController) .then((response) => { - if (response.status === 200) { - setIps((ps) => ({ ...ps, history: history, isLoading: isLoading, error: error?.message })); - setIsSubmitting(false); - showSnackbar({ - isLowContrast: true, - kind: 'success', - title: t('ipsCreated', 'IPS'), - subtitle: t('ipsNowAvailable', 'The IPS has been updated and is now visible in the Patient History.'), - }); - } + setIps((ps) => ({ ...ps, history: history, isLoading: isLoading, error: error?.message })); + setIsSubmitting(false); + showSnackbar({ + isLowContrast: true, + kind: 'success', + title: t('ipsCreated', 'IPS'), + subtitle: t('ipsNowAvailable', 'The IPS has been updated and is now visible in the Patient History.'), + }); }) .catch((err) => { setIps((ps) => ({ ...ps, history: null, isLoading: false, error: err?.message || 'Failed to fetch IPS' })); setIsSubmitting(false); showSnackbar({ - title: t('ipsCreationError', 'IPS'), + title: t('ipsCreationError', 'Error updating IPS'), kind: 'error', isLowContrast: false, subtitle: t( 'checkForServerAvailability', - 'The Fhir server maybe unreachable or the IPS generation process exited with an error!', + 'The FHIR server maybe unreachable or the IPS generation process exited with an error!', ), }); + console.error(err?.message); }) - .finally(() => { - abortController.abort(); - }); + .finally(() => {}); }; return ( diff --git a/src/history/patient-history.component.tsx b/src/history/patient-history.component.tsx index 6611150..4bb88e9 100644 --- a/src/history/patient-history.component.tsx +++ b/src/history/patient-history.component.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from 'react'; import { useParams } from 'react-router-dom'; import HistoryDetailOverview from './history-detail-overview.component'; @@ -6,9 +6,9 @@ const PatientHistory: React.FC = () => { const { patientUuid } = useParams(); return ( <> - + ); -} +}; export default PatientHistory; diff --git a/src/history/patient-history.test.tsx b/src/history/patient-history.test.tsx index 3181450..2062927 100644 --- a/src/history/patient-history.test.tsx +++ b/src/history/patient-history.test.tsx @@ -4,7 +4,10 @@ import HistoryDetailOverview from './history-detail-overview.component'; import React from 'react'; import { FetchResponse, usePatient } from '@openmrs/esm-framework'; import { createIpsResource, useIpsResource } from '../common/history.resource'; -import { mockIPS, mockPUTResponse } from '../test.util'; +import { mockIPS, mockPUTResponse } from '../__mocks__/test.util'; + +const mockUsePatient = jest.mocked(usePatient); +const mockUseIpsResource = jest.mocked(useIpsResource); jest.mock('../common/history.resource'); @@ -19,14 +22,11 @@ jest.mock('react-router-dom', () => ({ describe('Display patient IPS', () => { beforeEach(() => { - const mockUseParams = useParams as jest.Mock; + const mockUseParams = jest.mocked(useParams); mockUseParams.mockReturnValue({ patientUuid: 'mock-uuid' }); }); it('renders without crashing', () => { - const mockUsePatient = jest.mocked(usePatient); - const mockUseIpsResource = jest.mocked(useIpsResource); - mockUsePatient.mockReturnValue({ isLoading: false, patient: undefined, @@ -43,9 +43,6 @@ describe('Display patient IPS', () => { }); it('renders loading before resolving ips', async () => { - const mockUsePatient = jest.mocked(usePatient); - const mockUseIpsResource = jest.mocked(useIpsResource); - mockUsePatient.mockReturnValue({ isLoading: false, patient: undefined, @@ -65,9 +62,6 @@ describe('Display patient IPS', () => { }); it('renders the ips', async () => { - const mockUsePatient = jest.mocked(usePatient); - const mockUseIpsResource = jest.mocked(useIpsResource); - mockUsePatient.mockReturnValue({ isLoading: false, patient: undefined, @@ -96,8 +90,6 @@ describe('Display patient IPS', () => { }); it('refresh button triggers downloading new ips', async () => { - const mockUsePatient = jest.mocked(usePatient); - const mockUseIpsResource = jest.mocked(useIpsResource); const mockCreateIpsResource = jest.mocked(createIpsResource); mockCreateIpsResource.mockReturnValue({ diff --git a/src/root.component.tsx b/src/root.component.tsx index b2966c2..c2ad065 100644 --- a/src/root.component.tsx +++ b/src/root.component.tsx @@ -11,8 +11,8 @@ const Root: React.FC = () => {
- } /> - } /> + } /> + } />
diff --git a/translations/am.json b/translations/am.json index 6311dd5..59054da 100644 --- a/translations/am.json +++ b/translations/am.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Patient History", "criticality": "Criticality", diff --git a/translations/en.json b/translations/en.json index 6311dd5..59054da 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Patient History", "criticality": "Criticality", diff --git a/translations/es.json b/translations/es.json index 6311dd5..59054da 100644 --- a/translations/es.json +++ b/translations/es.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Patient History", "criticality": "Criticality", diff --git a/translations/fr.json b/translations/fr.json index e3b7b0d..c0eb192 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Antécédents du patient", "criticality": "Criticality", diff --git a/translations/he.json b/translations/he.json index 6311dd5..59054da 100644 --- a/translations/he.json +++ b/translations/he.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Patient History", "criticality": "Criticality", diff --git a/translations/km.json b/translations/km.json index 6311dd5..59054da 100644 --- a/translations/km.json +++ b/translations/km.json @@ -1,8 +1,8 @@ { "ipsCreated": "IPS", "ipsNowAvailable": "The IPS has been updated and is now visible in the Patient History.", - "ipsCreationError": "IPS", - "checkForServerAvailability": "The Fhir server maybe unreachable or the IPS generation process exited with an error!", + "ipsCreationError": "Error updating IPS", + "checkForServerAvailability": "The FHIR server maybe unreachable or the IPS generation process exited with an error!", "refresh": "Refresh", "patientHistory": "Patient History", "criticality": "Criticality",