@pih/esm-referrals-queue-app 2.1.1-pre.138 → 2.1.1-pre.142
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 +2 -2
- package/dist/0.js +1 -1
- package/dist/0.js.map +1 -1
- package/dist/117.js +1 -1
- package/dist/117.js.map +1 -1
- package/dist/986.js +49 -0
- package/dist/986.js.map +1 -0
- package/dist/main.js +3 -6
- package/dist/main.js.map +1 -1
- package/dist/pih-esm-referrals-queue-app.js +3 -6
- package/dist/pih-esm-referrals-queue-app.js.buildmanifest.json +41 -41
- package/dist/pih-esm-referrals-queue-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/referrals-queue/referrals-queue.component.tsx +45 -4
- package/src/referrals-queue/referrals-queue.resource.test.tsx +98 -0
- package/src/referrals-queue/referrals-queue.resource.tsx +41 -3
- package/src/referrals-queue/referrals-queue.test.tsx +54 -2
- package/translations/en.json +2 -0
- package/dist/291.js +0 -49
- package/dist/291.js.map +0 -1
|
@@ -3,17 +3,27 @@ import { of } from 'rxjs';
|
|
|
3
3
|
import { render, fireEvent, screen, within, waitFor } from '@testing-library/react';
|
|
4
4
|
import MockDate from 'mockdate';
|
|
5
5
|
import ReferralsQueue from './referrals-queue.component';
|
|
6
|
-
import { getReferrals } from './referrals-queue.resource';
|
|
6
|
+
import { findNearestVisitLocationUuid, getReferrals } from './referrals-queue.resource';
|
|
7
7
|
|
|
8
8
|
const mockedUseConfig = jest.fn();
|
|
9
|
+
const mockedUseLocations = jest.fn();
|
|
10
|
+
const mockedUseSession = jest.fn();
|
|
9
11
|
|
|
10
12
|
jest.mock('./referrals-queue.resource');
|
|
11
13
|
jest.mock('@openmrs/esm-framework', () => ({
|
|
12
14
|
...jest.requireActual('@openmrs/esm-framework'),
|
|
13
15
|
useConfig: () => mockedUseConfig(),
|
|
16
|
+
useLocations: () => mockedUseLocations(),
|
|
17
|
+
useSession: () => mockedUseSession(),
|
|
14
18
|
}));
|
|
15
19
|
|
|
16
20
|
const mockedGetReferrals = getReferrals as jest.Mock;
|
|
21
|
+
const mockedFindNearestVisitLocationUuid = findNearestVisitLocationUuid as jest.Mock;
|
|
22
|
+
|
|
23
|
+
const locations = [
|
|
24
|
+
{ uuid: 'location-uuid-1', display: 'Mirebalais Hospital' },
|
|
25
|
+
{ uuid: 'location-uuid-2', display: 'Cange Clinic' },
|
|
26
|
+
];
|
|
17
27
|
|
|
18
28
|
const referrals = [
|
|
19
29
|
{
|
|
@@ -62,6 +72,8 @@ window.location = { href: '/referrals-queue' };
|
|
|
62
72
|
|
|
63
73
|
describe('referrals queue', () => {
|
|
64
74
|
const todayString = '2020-10-31';
|
|
75
|
+
let view: ReturnType<typeof render>;
|
|
76
|
+
|
|
65
77
|
beforeAll(() => {
|
|
66
78
|
mockedUseConfig.mockReturnValue({
|
|
67
79
|
links: {
|
|
@@ -79,7 +91,11 @@ describe('referrals queue', () => {
|
|
|
79
91
|
MockDate.set(todayString + 'T10:00:00.000-0400');
|
|
80
92
|
mockedGetReferrals.mockReset();
|
|
81
93
|
mockedGetReferrals.mockReturnValue(of(referrals));
|
|
82
|
-
|
|
94
|
+
mockedUseLocations.mockReturnValue(locations);
|
|
95
|
+
mockedUseSession.mockReturnValue({ sessionLocation: locations[0] });
|
|
96
|
+
mockedFindNearestVisitLocationUuid.mockReset();
|
|
97
|
+
mockedFindNearestVisitLocationUuid.mockResolvedValue(undefined);
|
|
98
|
+
view = render(<ReferralsQueue />);
|
|
83
99
|
});
|
|
84
100
|
|
|
85
101
|
afterEach(() => {
|
|
@@ -166,6 +182,42 @@ describe('referrals queue', () => {
|
|
|
166
182
|
expect(screen.queryByText('Test Referral Type', { selector: 'span' })).not.toBeNull();
|
|
167
183
|
});
|
|
168
184
|
|
|
185
|
+
it('defaults the location dropdown to the session location', () => {
|
|
186
|
+
screen.getByText(locations[0].display, { selector: 'span' });
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('resolves the location dropdown to the nearest visit-location ancestor when the session location is a descendant', async () => {
|
|
190
|
+
view.unmount();
|
|
191
|
+
const deskLocation = { uuid: 'desk-uuid', display: 'Front Desk' };
|
|
192
|
+
mockedUseSession.mockReturnValue({ sessionLocation: deskLocation });
|
|
193
|
+
mockedFindNearestVisitLocationUuid.mockResolvedValue(locations[1].uuid);
|
|
194
|
+
|
|
195
|
+
render(<ReferralsQueue />);
|
|
196
|
+
|
|
197
|
+
await waitFor(() => {
|
|
198
|
+
screen.getByText(locations[1].display, { selector: 'span' });
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
expect(mockedFindNearestVisitLocationUuid).toHaveBeenCalledWith(
|
|
202
|
+
deskLocation.uuid,
|
|
203
|
+
new Set(locations.map((location) => location.uuid)),
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('refetches referrals for the newly selected location', () => {
|
|
208
|
+
fireEvent.click(
|
|
209
|
+
screen.getByLabelText('Location', {
|
|
210
|
+
selector: 'button',
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
213
|
+
fireEvent.click(
|
|
214
|
+
screen.getByText(locations[1].display, {
|
|
215
|
+
selector: 'div',
|
|
216
|
+
}),
|
|
217
|
+
);
|
|
218
|
+
expect(mockedGetReferrals).toHaveBeenLastCalledWith(expect.objectContaining({ locationUuid: locations[1].uuid }));
|
|
219
|
+
});
|
|
220
|
+
|
|
169
221
|
it('filters by statuses, with dropdown inferred from data', () => {
|
|
170
222
|
fireEvent.click(
|
|
171
223
|
screen.getByLabelText('Status', {
|
package/translations/en.json
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
"emr-id": "EMR ID",
|
|
5
5
|
"filter-by-patient": "Filter by patient",
|
|
6
6
|
"from": "From",
|
|
7
|
+
"location": "Location",
|
|
7
8
|
"name": "Name",
|
|
8
9
|
"referral-date": "Referral Date",
|
|
9
10
|
"referral-type": "Referral Type",
|
|
10
11
|
"referrals-queue": "Referrals Queue",
|
|
12
|
+
"select-location": "Select Location",
|
|
11
13
|
"select-referral-type": "Select Referral Type",
|
|
12
14
|
"select-status": "Select Status",
|
|
13
15
|
"status": "Status",
|