@openmrs/esm-appointments-app 9.2.1-pre.7290 → 9.2.1-pre.7303
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 +3 -3
- package/dist/1431.js +1 -1
- package/dist/1431.js.map +1 -1
- package/dist/3092.js +1 -1
- package/dist/3092.js.map +1 -1
- package/dist/4889.js +1 -1
- package/dist/4889.js.map +1 -1
- package/dist/525.js +1 -1
- package/dist/525.js.map +1 -1
- package/dist/7026.js +1 -1
- package/dist/7026.js.map +1 -1
- package/dist/openmrs-esm-appointments-app.js.buildmanifest.json +15 -15
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/appointments/common-components/appointments-table.component.tsx +3 -3
- package/src/form/appointments-form.test.tsx +35 -56
- package/src/form/appointments-form.workspace.tsx +419 -427
- package/src/metrics/metrics-header.component.tsx +2 -2
- package/src/patient-appointments/patient-appointments-action-menu.component.tsx +3 -3
- package/src/patient-appointments/patient-appointments-base.component.tsx +4 -4
- package/src/patient-search/patient-search.component.tsx +2 -2
- package/src/routes.json +3 -14
|
@@ -2,14 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { fireEvent, screen } from '@testing-library/react';
|
|
4
4
|
import {
|
|
5
|
+
type FetchResponse,
|
|
5
6
|
getDefaultsFromConfigSchema,
|
|
6
7
|
openmrsFetch,
|
|
7
8
|
showSnackbar,
|
|
8
9
|
useConfig,
|
|
9
10
|
useLocations,
|
|
10
11
|
useSession,
|
|
11
|
-
type FetchResponse,
|
|
12
|
-
type Workspace2DefinitionProps,
|
|
13
12
|
} from '@openmrs/esm-framework';
|
|
14
13
|
import { configSchema, type ConfigObject } from '../config-schema';
|
|
15
14
|
import { mockUseAppointmentServiceData, mockSession, mockLocations, mockProviders } from '__mocks__';
|
|
@@ -17,33 +16,15 @@ import { mockPatient, renderWithSwr, waitForLoadingToFinish } from 'tools';
|
|
|
17
16
|
import { saveAppointment, checkAppointmentConflict } from './appointments-form.resource';
|
|
18
17
|
import { useProviders } from '../hooks/useProviders';
|
|
19
18
|
import type { AppointmentKind, AppointmentStatus } from '../types';
|
|
20
|
-
import AppointmentForm
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
...props.workspaceProps,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const defaultProps: Workspace2DefinitionProps<AppointmentsFormProps> = {
|
|
34
|
-
closeWorkspace,
|
|
35
|
-
workspaceProps,
|
|
36
|
-
groupProps: props.groupProps || { collapsed: false, name: 'appointmentsFormWorkspaceGroup', overlay: false },
|
|
37
|
-
windowProps: props.windowProps || { group: 'appointmentsFormWorkspaceGroup', name: 'appointments-form-window' },
|
|
38
|
-
workspaceName: props.workspaceName || 'appointments-form-workspace',
|
|
39
|
-
launchChildWorkspace: jest.fn(),
|
|
40
|
-
windowName: 'appointments-form-window',
|
|
41
|
-
|
|
42
|
-
isRootWorkspace: false,
|
|
43
|
-
...props,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
19
|
+
import AppointmentForm from './appointments-form.workspace';
|
|
20
|
+
|
|
21
|
+
const defaultProps = {
|
|
22
|
+
context: 'creating',
|
|
23
|
+
closeWorkspace: jest.fn(),
|
|
24
|
+
patientUuid: mockPatient.id,
|
|
25
|
+
promptBeforeClosing: jest.fn(),
|
|
26
|
+
closeWorkspaceWithSavedChanges: jest.fn(),
|
|
27
|
+
setTitle: jest.fn(),
|
|
47
28
|
};
|
|
48
29
|
|
|
49
30
|
const mockOpenmrsFetch = jest.mocked(openmrsFetch);
|
|
@@ -76,7 +57,7 @@ jest.mock('../workload/workload.resource', () => ({
|
|
|
76
57
|
}));
|
|
77
58
|
|
|
78
59
|
describe('AppointmentForm', () => {
|
|
79
|
-
const dateTimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3}
|
|
60
|
+
const dateTimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3}Z|\+00:00)$/;
|
|
80
61
|
|
|
81
62
|
beforeEach(() => {
|
|
82
63
|
mockUseConfig.mockReturnValue({
|
|
@@ -100,7 +81,7 @@ describe('AppointmentForm', () => {
|
|
|
100
81
|
it('renders the appointments form', async () => {
|
|
101
82
|
mockOpenmrsFetch.mockResolvedValue(mockUseAppointmentServiceData as unknown as FetchResponse);
|
|
102
83
|
|
|
103
|
-
|
|
84
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
104
85
|
|
|
105
86
|
await waitForLoadingToFinish();
|
|
106
87
|
|
|
@@ -123,18 +104,17 @@ describe('AppointmentForm', () => {
|
|
|
123
104
|
|
|
124
105
|
it('closes the workspace when the cancel button is clicked', async () => {
|
|
125
106
|
const user = userEvent.setup();
|
|
126
|
-
const mockCloseWorkspace = jest.fn();
|
|
127
107
|
|
|
128
108
|
mockOpenmrsFetch.mockResolvedValueOnce(mockUseAppointmentServiceData as unknown as FetchResponse);
|
|
129
109
|
|
|
130
|
-
|
|
110
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
131
111
|
|
|
132
112
|
await waitForLoadingToFinish();
|
|
133
113
|
|
|
134
114
|
const cancelButton = screen.getByRole('button', { name: /Discard/i });
|
|
135
115
|
await user.click(cancelButton);
|
|
136
116
|
|
|
137
|
-
expect(
|
|
117
|
+
expect(defaultProps.closeWorkspace).toHaveBeenCalledTimes(1);
|
|
138
118
|
});
|
|
139
119
|
|
|
140
120
|
it('renders a success snackbar upon successfully scheduling an appointment', async () => {
|
|
@@ -144,7 +124,7 @@ describe('AppointmentForm', () => {
|
|
|
144
124
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
145
125
|
mockSaveAppointment.mockResolvedValue({ status: 200, statusText: 'Ok' } as FetchResponse);
|
|
146
126
|
|
|
147
|
-
|
|
127
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
148
128
|
|
|
149
129
|
await waitForLoadingToFinish();
|
|
150
130
|
|
|
@@ -222,7 +202,7 @@ describe('AppointmentForm', () => {
|
|
|
222
202
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
223
203
|
mockSaveAppointment.mockRejectedValue(error);
|
|
224
204
|
|
|
225
|
-
|
|
205
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
226
206
|
|
|
227
207
|
await waitForLoadingToFinish();
|
|
228
208
|
|
|
@@ -294,7 +274,7 @@ describe('AppointmentForm', () => {
|
|
|
294
274
|
});
|
|
295
275
|
mockOpenmrsFetch.mockResolvedValue(mockUseAppointmentServiceData as unknown as FetchResponse);
|
|
296
276
|
|
|
297
|
-
|
|
277
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
298
278
|
|
|
299
279
|
await waitForLoadingToFinish();
|
|
300
280
|
|
|
@@ -312,7 +292,7 @@ describe('AppointmentForm', () => {
|
|
|
312
292
|
|
|
313
293
|
mockOpenmrsFetch.mockResolvedValue(mockUseAppointmentServiceData as unknown as FetchResponse);
|
|
314
294
|
|
|
315
|
-
|
|
295
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
316
296
|
|
|
317
297
|
await waitForLoadingToFinish();
|
|
318
298
|
|
|
@@ -333,7 +313,7 @@ describe('AppointmentForm', () => {
|
|
|
333
313
|
const user = userEvent.setup();
|
|
334
314
|
mockOpenmrsFetch.mockResolvedValue(mockUseAppointmentServiceData as unknown as FetchResponse);
|
|
335
315
|
|
|
336
|
-
|
|
316
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
337
317
|
|
|
338
318
|
await waitForLoadingToFinish();
|
|
339
319
|
|
|
@@ -374,7 +354,7 @@ describe('AppointmentForm', () => {
|
|
|
374
354
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
375
355
|
mockSaveAppointment.mockResolvedValue({ status: 200, statusText: 'Ok' } as FetchResponse);
|
|
376
356
|
|
|
377
|
-
|
|
357
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
378
358
|
|
|
379
359
|
await waitForLoadingToFinish();
|
|
380
360
|
|
|
@@ -415,7 +395,7 @@ describe('AppointmentForm', () => {
|
|
|
415
395
|
|
|
416
396
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
417
397
|
|
|
418
|
-
|
|
398
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
419
399
|
|
|
420
400
|
await waitForLoadingToFinish();
|
|
421
401
|
|
|
@@ -445,7 +425,7 @@ describe('AppointmentForm', () => {
|
|
|
445
425
|
|
|
446
426
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
447
427
|
|
|
448
|
-
|
|
428
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
449
429
|
|
|
450
430
|
await waitForLoadingToFinish();
|
|
451
431
|
|
|
@@ -477,7 +457,7 @@ describe('AppointmentForm', () => {
|
|
|
477
457
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
478
458
|
mockSaveAppointment.mockResolvedValue({ status: 200, statusText: 'Ok' } as FetchResponse);
|
|
479
459
|
|
|
480
|
-
|
|
460
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
481
461
|
|
|
482
462
|
await waitForLoadingToFinish();
|
|
483
463
|
|
|
@@ -532,7 +512,7 @@ describe('AppointmentForm', () => {
|
|
|
532
512
|
|
|
533
513
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
534
514
|
|
|
535
|
-
|
|
515
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
536
516
|
|
|
537
517
|
await waitForLoadingToFinish();
|
|
538
518
|
|
|
@@ -568,7 +548,7 @@ describe('AppointmentForm', () => {
|
|
|
568
548
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
569
549
|
mockSaveAppointment.mockResolvedValue({ status: 200, statusText: 'Ok' } as FetchResponse);
|
|
570
550
|
|
|
571
|
-
|
|
551
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
572
552
|
|
|
573
553
|
await waitForLoadingToFinish();
|
|
574
554
|
|
|
@@ -636,7 +616,7 @@ describe('AppointmentForm', () => {
|
|
|
636
616
|
|
|
637
617
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
638
618
|
|
|
639
|
-
|
|
619
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
640
620
|
|
|
641
621
|
await waitForLoadingToFinish();
|
|
642
622
|
|
|
@@ -669,7 +649,7 @@ describe('AppointmentForm', () => {
|
|
|
669
649
|
data: { SERVICE_UNAVAILABLE: true },
|
|
670
650
|
} as FetchResponse);
|
|
671
651
|
|
|
672
|
-
|
|
652
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
673
653
|
|
|
674
654
|
await waitForLoadingToFinish();
|
|
675
655
|
|
|
@@ -723,7 +703,7 @@ describe('AppointmentForm', () => {
|
|
|
723
703
|
data: { PATIENT_DOUBLE_BOOKING: true },
|
|
724
704
|
} as FetchResponse);
|
|
725
705
|
|
|
726
|
-
|
|
706
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
727
707
|
|
|
728
708
|
await waitForLoadingToFinish();
|
|
729
709
|
|
|
@@ -803,13 +783,13 @@ describe('AppointmentForm', () => {
|
|
|
803
783
|
|
|
804
784
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
805
785
|
|
|
806
|
-
|
|
786
|
+
renderWithSwr(<AppointmentForm {...defaultProps} appointment={existingAppointment} context="editing" />);
|
|
807
787
|
|
|
808
788
|
await waitForLoadingToFinish();
|
|
809
789
|
|
|
810
790
|
// Check that form fields are pre-populated
|
|
811
791
|
expect(screen.getByDisplayValue('Existing appointment note')).toBeInTheDocument();
|
|
812
|
-
expect(screen.
|
|
792
|
+
expect(screen.getByDisplayValue('Outpatient')).toBeInTheDocument();
|
|
813
793
|
expect(screen.getByRole('combobox', { name: /select the type of appointment/i })).toHaveValue('Scheduled');
|
|
814
794
|
});
|
|
815
795
|
|
|
@@ -849,7 +829,7 @@ describe('AppointmentForm', () => {
|
|
|
849
829
|
mockCheckAppointmentConflict.mockResolvedValue({ status: 204, data: {} } as FetchResponse);
|
|
850
830
|
mockSaveAppointment.mockResolvedValue({ status: 200, statusText: 'Ok' } as FetchResponse);
|
|
851
831
|
|
|
852
|
-
|
|
832
|
+
renderWithSwr(<AppointmentForm {...defaultProps} appointment={existingAppointment} context="editing" />);
|
|
853
833
|
|
|
854
834
|
await waitForLoadingToFinish();
|
|
855
835
|
|
|
@@ -886,7 +866,7 @@ describe('AppointmentForm', () => {
|
|
|
886
866
|
|
|
887
867
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
888
868
|
|
|
889
|
-
|
|
869
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
890
870
|
|
|
891
871
|
await waitForLoadingToFinish();
|
|
892
872
|
|
|
@@ -902,11 +882,10 @@ describe('AppointmentForm', () => {
|
|
|
902
882
|
|
|
903
883
|
it('should warn before closing with unsaved changes', async () => {
|
|
904
884
|
const user = userEvent.setup();
|
|
905
|
-
const mockCloseWorkspace = jest.fn();
|
|
906
885
|
|
|
907
886
|
mockOpenmrsFetch.mockResolvedValue({ data: mockUseAppointmentServiceData } as unknown as FetchResponse);
|
|
908
887
|
|
|
909
|
-
|
|
888
|
+
renderWithSwr(<AppointmentForm {...defaultProps} />);
|
|
910
889
|
|
|
911
890
|
await waitForLoadingToFinish();
|
|
912
891
|
|
|
@@ -919,8 +898,8 @@ describe('AppointmentForm', () => {
|
|
|
919
898
|
// Try to cancel
|
|
920
899
|
await user.click(cancelButton);
|
|
921
900
|
|
|
922
|
-
// Should call
|
|
923
|
-
expect(
|
|
901
|
+
// Should call promptBeforeClosing if there are unsaved changes
|
|
902
|
+
expect(defaultProps.promptBeforeClosing).toHaveBeenCalled();
|
|
924
903
|
});
|
|
925
904
|
});
|
|
926
905
|
});
|