@kenyaemr/esm-ward-app 7.0.2-pre.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +37 -0
- package/dist/130.js +2 -0
- package/dist/130.js.LICENSE.txt +3 -0
- package/dist/130.js.map +1 -0
- package/dist/443.js +1 -0
- package/dist/443.js.map +1 -0
- package/dist/49.js +1 -0
- package/dist/49.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/591.js +2 -0
- package/dist/591.js.LICENSE.txt +32 -0
- package/dist/591.js.map +1 -0
- package/dist/697.js +2 -0
- package/dist/697.js.LICENSE.txt +15 -0
- package/dist/697.js.map +1 -0
- package/dist/729.js +1 -0
- package/dist/729.js.map +1 -0
- package/dist/784.js +2 -0
- package/dist/784.js.LICENSE.txt +9 -0
- package/dist/784.js.map +1 -0
- package/dist/kenyaemr-esm-ward-app.js +1 -0
- package/dist/kenyaemr-esm-ward-app.js.buildmanifest.json +284 -0
- package/dist/kenyaemr-esm-ward-app.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +15 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.js +3 -0
- package/package.json +54 -0
- package/src/beds/empty-bed-skeleton.tsx +14 -0
- package/src/beds/empty-bed.component.tsx +24 -0
- package/src/beds/empty-bed.scss +28 -0
- package/src/beds/occupied-bed.component.tsx +40 -0
- package/src/beds/occupied-bed.scss +24 -0
- package/src/beds/occupied-bed.test.tsx +43 -0
- package/src/config-schema.ts +136 -0
- package/src/hooks/useAdmissionLocation.ts +13 -0
- package/src/hooks/useBeds.ts +26 -0
- package/src/index.ts +24 -0
- package/src/root.component.tsx +20 -0
- package/src/routes.json +24 -0
- package/src/types/index.ts +125 -0
- package/src/ward-patient-card/row-elements/row-elements.scss +16 -0
- package/src/ward-patient-card/row-elements/ward-patient-age.tsx +18 -0
- package/src/ward-patient-card/row-elements/ward-patient-bed-number.tsx +13 -0
- package/src/ward-patient-card/row-elements/ward-patient-header-address.tsx +22 -0
- package/src/ward-patient-card/row-elements/ward-patient-name.tsx +13 -0
- package/src/ward-patient-card/ward-patient-card-row.resources.tsx +85 -0
- package/src/ward-patient-card/ward-patient-card.scss +71 -0
- package/src/ward-patient-card/ward-patient-card.tsx +20 -0
- package/src/ward-view/ward-bed.component.tsx +18 -0
- package/src/ward-view/ward-view.component.tsx +100 -0
- package/src/ward-view/ward-view.resource.ts +24 -0
- package/src/ward-view/ward-view.scss +36 -0
- package/src/ward-view/ward-view.test.tsx +98 -0
- package/translations/en.json +9 -0
- package/tsconfig.json +5 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Person,
|
|
3
|
+
type ConfigSchema,
|
|
4
|
+
getDefaultsFromConfigSchema,
|
|
5
|
+
useConfig,
|
|
6
|
+
useSession,
|
|
7
|
+
useFeatureFlag,
|
|
8
|
+
} from '@openmrs/esm-framework';
|
|
9
|
+
import { screen } from '@testing-library/react';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useParams } from 'react-router-dom';
|
|
12
|
+
import { mockLocations } from '../../../../__mocks__/locations.mock';
|
|
13
|
+
import { mockAdmissionLocation } from '../../../../__mocks__/wards.mock';
|
|
14
|
+
import { renderWithSwr } from '../../../../tools/test-utils';
|
|
15
|
+
import { configSchema } from '../config-schema';
|
|
16
|
+
import { useAdmissionLocation } from '../hooks/useAdmissionLocation';
|
|
17
|
+
import WardView from './ward-view.component';
|
|
18
|
+
import { mockPatientAlice } from '../../../../__mocks__/patient.mock';
|
|
19
|
+
|
|
20
|
+
jest.replaceProperty(mockPatientAlice.person as Person, 'preferredName', {
|
|
21
|
+
uuid: '',
|
|
22
|
+
givenName: 'Alice',
|
|
23
|
+
familyName: 'Johnson',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
jest.mocked(useConfig).mockReturnValue({
|
|
27
|
+
...getDefaultsFromConfigSchema<ConfigSchema>(configSchema),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const mockedSessionLocation = { uuid: 'abcd', display: 'mock location', links: [] };
|
|
31
|
+
jest.mocked(useSession).mockReturnValue({
|
|
32
|
+
sessionLocation: mockedSessionLocation,
|
|
33
|
+
authenticated: true,
|
|
34
|
+
sessionId: 'sessionId',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const mockedUseFeatureFlag = useFeatureFlag as jest.Mock;
|
|
38
|
+
|
|
39
|
+
jest.mock('@openmrs/esm-framework', () => {
|
|
40
|
+
return {
|
|
41
|
+
...jest.requireActual('@openmrs/esm-framework'),
|
|
42
|
+
useLocations: jest.fn().mockImplementation(() => mockLocations.data.results),
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
jest.mock('react-router-dom', () => ({
|
|
47
|
+
...jest.requireActual('react-router-dom'),
|
|
48
|
+
useParams: jest.fn().mockReturnValue({}),
|
|
49
|
+
}));
|
|
50
|
+
const mockedUseParams = useParams as jest.Mock;
|
|
51
|
+
|
|
52
|
+
jest.mock('../hooks/useAdmissionLocation', () => ({
|
|
53
|
+
useAdmissionLocation: jest.fn(),
|
|
54
|
+
}));
|
|
55
|
+
jest.mocked(useAdmissionLocation).mockReturnValue({
|
|
56
|
+
error: undefined,
|
|
57
|
+
mutate: jest.fn(),
|
|
58
|
+
isValidating: false,
|
|
59
|
+
isLoading: false,
|
|
60
|
+
admissionLocation: mockAdmissionLocation,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('WardView:', () => {
|
|
64
|
+
it('renders the session location when no location provided in URL', () => {
|
|
65
|
+
renderWithSwr(<WardView />);
|
|
66
|
+
const header = screen.getByRole('heading', { name: mockedSessionLocation.display });
|
|
67
|
+
expect(header).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('renders the location provided in URL', () => {
|
|
71
|
+
const locationToUse = mockLocations.data.results[0];
|
|
72
|
+
mockedUseParams.mockReturnValueOnce({ locationUuid: locationToUse.uuid });
|
|
73
|
+
renderWithSwr(<WardView />);
|
|
74
|
+
const header = screen.getByRole('heading', { name: locationToUse.display });
|
|
75
|
+
expect(header).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('renders the correct number of occupied and empty beds', async () => {
|
|
79
|
+
renderWithSwr(<WardView />);
|
|
80
|
+
const emptyBedCards = await screen.findAllByText(/empty bed/i);
|
|
81
|
+
expect(emptyBedCards).toHaveLength(3);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('renders notification for invalid location uuid', () => {
|
|
85
|
+
mockedUseParams.mockReturnValueOnce({ locationUuid: 'invalid-uuid' });
|
|
86
|
+
renderWithSwr(<WardView />);
|
|
87
|
+
const notification = screen.getByRole('status');
|
|
88
|
+
expect(notification).toBeInTheDocument();
|
|
89
|
+
const invalidText = screen.getByText('Unknown location uuid: invalid-uuid');
|
|
90
|
+
expect(invalidText).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('screen should be empty if backend module is not installed', () => {
|
|
94
|
+
mockedUseFeatureFlag.mockReturnValueOnce(false);
|
|
95
|
+
const { container } = renderWithSwr(<WardView />);
|
|
96
|
+
expect(container.firstChild).not.toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bedShare": "Bed share",
|
|
3
|
+
"emptyBed": "Empty bed",
|
|
4
|
+
"errorLoadingWardLocation": "Error loading ward location",
|
|
5
|
+
"invalidLocationSpecified": "Invalid location specified",
|
|
6
|
+
"invalidWardLocation": "Invalid ward location: {{location}}",
|
|
7
|
+
"noBedsConfigured": "No beds configured for this location",
|
|
8
|
+
"unknownLocationUuid": "Unknown location uuid: {{locationUuidFromUrl}}"
|
|
9
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('openmrs/default-webpack-config');
|