@openmrs/esm-appointments-app 5.2.2-pre.2409 → 5.2.2-pre.2415
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 +1 -1
- package/dist/openmrs-esm-appointments-app.js.buildmanifest.json +2 -2
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/appointments/common-components/appointments-table.component.tsx +3 -3
- package/src/appointments/common-components/appointments-table.test.tsx +56 -24
- package/src/appointments/forms/cancel-form/cancel-appointment.test.tsx +8 -7
- package/src/appointments/unscheduled/unscheduled-appointments.test.tsx +8 -3
- package/src/appointments-calendar/daily/daily-view-workload.test.tsx +7 -4
- package/src/appointments-calendar/weekly/weekly-view-workload.test.tsx +7 -4
- package/src/home-appointments/appointment-actions.test.tsx +20 -15
- package/src/home-appointments/check-in-modal/check-in-modal.test.tsx +21 -16
package/.turbo/turbo-build.log
CHANGED
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"auxiliaryFiles": [
|
|
101
101
|
"main.js.map"
|
|
102
102
|
],
|
|
103
|
-
"hash": "
|
|
103
|
+
"hash": "3956ac44d3a6d972",
|
|
104
104
|
"childrenByOrder": {}
|
|
105
105
|
},
|
|
106
106
|
{
|
|
@@ -438,7 +438,7 @@
|
|
|
438
438
|
"auxiliaryFiles": [
|
|
439
439
|
"755.js.map"
|
|
440
440
|
],
|
|
441
|
-
"hash": "
|
|
441
|
+
"hash": "eccfc4d268aed3a9",
|
|
442
442
|
"childrenByOrder": {}
|
|
443
443
|
},
|
|
444
444
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"check-in-appointment-modal","slot":"todays-appointment-slot","component":"checkInModal"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"early-appointments-panel","component":"earlyAppointments"}],"version":"5.2.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0"},"extensions":[{"name":"home-appointments","slot":"homepage-widgets-slot","component":"homeAppointments","order":1},{"name":"clinical-appointments-dashboard-link","slot":"homepage-dashboard-slot","component":"appointmentsDashboardLink","meta":{"name":"appointments","slot":"clinical-appointments-dashboard-slot","title":"Appointments"}},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"check-in-appointment-modal","slot":"todays-appointment-slot","component":"checkInModal"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"expected-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"checked-in-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"completed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"missed-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"cancelled-appointments-panel","slot":"scheduled-appointments-panels-slot","component":"appointmentsByStatus"},{"name":"early-appointments-panel","component":"earlyAppointments"}],"version":"5.2.2-pre.2415"}
|
package/package.json
CHANGED
|
@@ -22,16 +22,16 @@ import {
|
|
|
22
22
|
import { ConfigurableLink, formatDatetime, usePagination, formatDate, useConfig } from '@openmrs/esm-framework';
|
|
23
23
|
import startCase from 'lodash-es/startCase';
|
|
24
24
|
import { Download } from '@carbon/react/icons';
|
|
25
|
-
import AppointmentDetails from '../details/appointment-details.component';
|
|
26
25
|
import { EmptyState } from '../../empty-state/empty-state.component';
|
|
27
26
|
import { downloadAppointmentsAsExcel } from '../../helpers/excel';
|
|
28
27
|
import { launchOverlay } from '../../hooks/useOverlay';
|
|
29
|
-
import PatientSearch from '../../patient-search/patient-search.component';
|
|
30
28
|
import { MappedAppointment } from '../../types';
|
|
31
29
|
import { getPageSizes, useSearchResults } from '../utils';
|
|
30
|
+
import { ConfigObject } from '../../config-schema';
|
|
31
|
+
import AppointmentDetails from '../details/appointment-details.component';
|
|
32
32
|
import AppointmentActions from './appointments-actions.component';
|
|
33
|
+
import PatientSearch from '../../patient-search/patient-search.component';
|
|
33
34
|
import styles from './appointments-table.scss';
|
|
34
|
-
import { ConfigObject } from '../../config-schema';
|
|
35
35
|
|
|
36
36
|
interface AppointmentsTableProps {
|
|
37
37
|
appointments: Array<MappedAppointment>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
4
|
import { MappedAppointment } from '../../types';
|
|
5
5
|
import { usePagination } from '@openmrs/esm-framework';
|
|
6
6
|
import { downloadAppointmentsAsExcel } from '../../helpers/excel';
|
|
7
7
|
import { launchOverlay } from '../../hooks/useOverlay';
|
|
8
|
+
import AppointmentsTable from './appointments-table.component';
|
|
8
9
|
import PatientSearch from '../../patient-search/patient-search.component';
|
|
9
10
|
|
|
10
11
|
// Define mock appointments data for testing purposes
|
|
@@ -59,19 +60,26 @@ describe('AppointmentsBaseTable', () => {
|
|
|
59
60
|
scheduleType: 'Scheduled',
|
|
60
61
|
};
|
|
61
62
|
|
|
62
|
-
it('should render empty state if appointments are not provided', () => {
|
|
63
|
+
it('should render empty state if appointments are not provided', async () => {
|
|
64
|
+
const user = userEvent.setup();
|
|
65
|
+
|
|
63
66
|
render(<AppointmentsTable {...props} />);
|
|
64
|
-
|
|
67
|
+
|
|
68
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
69
|
+
|
|
65
70
|
const emptyScreenText = screen.getByText(/There are no scheduled appointments to display/);
|
|
66
71
|
expect(emptyScreenText).toBeInTheDocument();
|
|
67
72
|
|
|
68
73
|
const launchAppointmentsForm = screen.getByRole('button', { name: /Create appointment/ });
|
|
69
|
-
|
|
74
|
+
|
|
75
|
+
await user.click(launchAppointmentsForm);
|
|
76
|
+
|
|
70
77
|
expect(mockLaunchOverlay).toHaveBeenCalledWith('Search', <PatientSearch />);
|
|
71
78
|
});
|
|
72
79
|
|
|
73
80
|
it('should render loading state when loading data', () => {
|
|
74
81
|
render(<AppointmentsTable {...props} isLoading={true} />);
|
|
82
|
+
|
|
75
83
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
76
84
|
});
|
|
77
85
|
|
|
@@ -83,41 +91,60 @@ describe('AppointmentsBaseTable', () => {
|
|
|
83
91
|
});
|
|
84
92
|
|
|
85
93
|
render(<AppointmentsTable {...props} appointments={appointments} />);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
|
|
95
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
96
|
+
|
|
97
|
+
expect(screen.getByText('Patient name')).toBeInTheDocument();
|
|
98
|
+
expect(screen.getByText('Identifier')).toBeInTheDocument();
|
|
99
|
+
expect(screen.getByText('Service Type')).toBeInTheDocument();
|
|
100
|
+
expect(screen.getByText('Actions')).toBeInTheDocument();
|
|
101
|
+
const patient = screen.getByText('John Smith');
|
|
102
|
+
expect(patient).toBeInTheDocument();
|
|
103
|
+
expect(patient).toHaveAttribute('href', 'someUrl');
|
|
104
|
+
expect(screen.getByText('12345')).toBeInTheDocument();
|
|
105
|
+
expect(screen.getByText('Service')).toBeInTheDocument();
|
|
97
106
|
});
|
|
98
107
|
|
|
99
|
-
it('should update search string when search input is changed', () => {
|
|
108
|
+
it('should update search string when search input is changed', async () => {
|
|
109
|
+
const user = userEvent.setup();
|
|
110
|
+
|
|
100
111
|
render(<AppointmentsTable {...props} appointments={appointments} />);
|
|
112
|
+
|
|
113
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
114
|
+
|
|
101
115
|
const searchInput = screen.getByRole('searchbox');
|
|
102
|
-
|
|
116
|
+
|
|
117
|
+
await user.type(searchInput, 'John');
|
|
103
118
|
expect(searchInput).toHaveValue('John');
|
|
104
119
|
});
|
|
105
120
|
|
|
106
|
-
it("should contain the title 'Scheduled appointments' and Total count", () => {
|
|
121
|
+
it("should contain the title 'Scheduled appointments' and Total count", async () => {
|
|
107
122
|
render(<AppointmentsTable {...props} appointments={appointments} />);
|
|
123
|
+
|
|
124
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
125
|
+
|
|
108
126
|
expect(screen.getByText(/Scheduled appointment/)).toBeInTheDocument();
|
|
109
127
|
expect(screen.getByText(/Total 1/)).toBeInTheDocument();
|
|
110
128
|
});
|
|
111
129
|
|
|
112
|
-
it('should execute the download function when download button is clicked', () => {
|
|
130
|
+
it('should execute the download function when download button is clicked', async () => {
|
|
131
|
+
const user = userEvent.setup();
|
|
132
|
+
|
|
113
133
|
render(<AppointmentsTable {...props} appointments={appointments} />);
|
|
134
|
+
|
|
135
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
136
|
+
|
|
114
137
|
const downloadButton = screen.getByRole('button', { name: /Download/ });
|
|
115
|
-
|
|
138
|
+
|
|
139
|
+
await user.click(downloadButton);
|
|
140
|
+
|
|
116
141
|
expect(downloadButton).toBeInTheDocument();
|
|
117
142
|
expect(mockDownloadAppointmentsAsExcel).toHaveBeenCalledWith(appointments, expect.anything());
|
|
118
143
|
});
|
|
119
144
|
|
|
120
|
-
it('should have pagination when there are more than 25 appointments', () => {
|
|
145
|
+
it('should have pagination when there are more than 25 appointments', async () => {
|
|
146
|
+
const user = userEvent.setup();
|
|
147
|
+
|
|
121
148
|
const mockAppointments = Array.from({ length: 100 }, (_, i) => ({
|
|
122
149
|
patientUuid: `${i}`,
|
|
123
150
|
name: `Patient ${i}`,
|
|
@@ -145,17 +172,22 @@ describe('AppointmentsBaseTable', () => {
|
|
|
145
172
|
});
|
|
146
173
|
|
|
147
174
|
render(<AppointmentsTable {...props} appointments={mockAppointments} />);
|
|
175
|
+
|
|
176
|
+
await screen.findByRole('heading', { name: /scheduled appointment/i });
|
|
177
|
+
|
|
148
178
|
expect(screen.getByText(/1–25 of 100 items/)).toBeInTheDocument();
|
|
149
179
|
const nextPageButton = screen.getByRole('button', { name: /Next page/ });
|
|
150
180
|
const previousPageButton = screen.getByRole('button', { name: /Previous page/ });
|
|
151
181
|
|
|
152
182
|
// Clicking the next page button should call the goTo function with the next page number
|
|
153
|
-
|
|
183
|
+
await user.click(nextPageButton);
|
|
184
|
+
|
|
154
185
|
expect(mockGoToPage).toHaveBeenCalledWith(2);
|
|
155
186
|
expect(screen.getByText(/26–50 of 100 items/)).toBeInTheDocument();
|
|
156
187
|
|
|
157
188
|
// Clicking the previous page button should call the goTo function with the previous page number
|
|
158
|
-
|
|
189
|
+
await user.click(previousPageButton);
|
|
190
|
+
|
|
159
191
|
expect(mockGoToPage).toHaveBeenCalledWith(1);
|
|
160
192
|
|
|
161
193
|
expect(screen.getByText(/1–25 of 100 items/)).toBeInTheDocument();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { screen, render, waitFor } from '@testing-library/react';
|
|
3
|
-
import CancelAppointment from './cancel-appointment.component';
|
|
4
|
-
import { mockMappedAppointmentsData } from '../../../../../../__mocks__/appointments.mock';
|
|
5
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { screen, render } from '@testing-library/react';
|
|
4
|
+
import { mockMappedAppointmentsData } from '../../../../../../__mocks__/appointments.mock';
|
|
6
5
|
import { showNotification, showToast } from '@openmrs/esm-framework';
|
|
7
6
|
import { cancelAppointment } from '../forms.resource';
|
|
7
|
+
import CancelAppointment from './cancel-appointment.component';
|
|
8
8
|
|
|
9
9
|
const testProps = {
|
|
10
10
|
appointment: mockMappedAppointmentsData.data[0],
|
|
@@ -39,8 +39,8 @@ describe('Cancel appointment form', () => {
|
|
|
39
39
|
|
|
40
40
|
renderCancelAppointment();
|
|
41
41
|
|
|
42
|
-
await
|
|
43
|
-
await
|
|
42
|
+
await user.click(screen.getByRole('textbox', { name: /reason for changes/i }));
|
|
43
|
+
await user.click(screen.getByRole('button', { name: /cancel appointment/i }));
|
|
44
44
|
|
|
45
45
|
expect(mockShowToast).toHaveBeenCalledTimes(1);
|
|
46
46
|
expect(mockShowToast).toHaveBeenCalledWith({
|
|
@@ -50,6 +50,7 @@ describe('Cancel appointment form', () => {
|
|
|
50
50
|
description: 'It has been cancelled successfully',
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
+
|
|
53
54
|
it('should display an error message when rest api call to cancel appointment fails', async () => {
|
|
54
55
|
const user = userEvent.setup();
|
|
55
56
|
mockCancelAppointment.mockResolvedValueOnce({
|
|
@@ -59,8 +60,8 @@ describe('Cancel appointment form', () => {
|
|
|
59
60
|
|
|
60
61
|
renderCancelAppointment();
|
|
61
62
|
|
|
62
|
-
await
|
|
63
|
-
await
|
|
63
|
+
await user.click(screen.getByRole('textbox', { name: /reason for changes/i }));
|
|
64
|
+
await user.click(screen.getByRole('button', { name: /cancel appointment/i }));
|
|
64
65
|
expect(mockShowNotification).toHaveBeenCalledTimes(1);
|
|
65
66
|
expect(mockShowNotification).toHaveBeenCalledWith({
|
|
66
67
|
critical: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { useUnscheduledAppointments } from '../../hooks/useUnscheduledAppointments';
|
|
4
5
|
import { downloadUnscheduledAppointments } from '../../helpers/excel';
|
|
5
6
|
import { usePagination } from '@openmrs/esm-framework';
|
|
@@ -78,6 +79,8 @@ describe('UnscheduledAppointments component', () => {
|
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
it('allows the user to search for appointments', async () => {
|
|
82
|
+
const user = userEvent.setup();
|
|
83
|
+
|
|
81
84
|
mockUseUnscheduledAppointments.mockReturnValue({
|
|
82
85
|
isLoading: false,
|
|
83
86
|
data: mockUnscheduledAppointments,
|
|
@@ -92,7 +95,7 @@ describe('UnscheduledAppointments component', () => {
|
|
|
92
95
|
render(<UnscheduledAppointments />);
|
|
93
96
|
|
|
94
97
|
const searchInput = await screen.findByRole('searchbox');
|
|
95
|
-
|
|
98
|
+
await user.type(searchInput, 'Another');
|
|
96
99
|
|
|
97
100
|
const patientName = screen.getByText('Another Patient');
|
|
98
101
|
expect(patientName).toBeInTheDocument();
|
|
@@ -108,6 +111,8 @@ describe('UnscheduledAppointments component', () => {
|
|
|
108
111
|
});
|
|
109
112
|
|
|
110
113
|
it('allows the user to download a list of unscheduled appointments', async () => {
|
|
114
|
+
const user = userEvent.setup();
|
|
115
|
+
|
|
111
116
|
mockUseUnscheduledAppointments.mockReturnValue({
|
|
112
117
|
isLoading: false,
|
|
113
118
|
data: mockUnscheduledAppointments,
|
|
@@ -124,7 +129,7 @@ describe('UnscheduledAppointments component', () => {
|
|
|
124
129
|
const downloadButton = await screen.findByText('Download');
|
|
125
130
|
expect(downloadButton).toBeInTheDocument();
|
|
126
131
|
|
|
127
|
-
|
|
132
|
+
await user.click(downloadButton);
|
|
128
133
|
|
|
129
134
|
expect(mockDownloadAppointmentsAsExcel).toHaveBeenCalledWith(mockUnscheduledAppointments);
|
|
130
135
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
2
|
import dayjs from 'dayjs';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import { navigate } from '@openmrs/esm-framework';
|
|
5
|
-
import DailyWorkloadView from './daily-view-workload.component';
|
|
6
6
|
import { spaBasePath } from '../../constants';
|
|
7
7
|
import { CalendarType } from '../../types';
|
|
8
|
+
import DailyWorkloadView from './daily-view-workload.component';
|
|
8
9
|
|
|
9
10
|
jest.mock('@openmrs/esm-framework', () => ({
|
|
10
11
|
...jest.requireActual('@openmrs/esm-framework'),
|
|
@@ -36,10 +37,12 @@ describe('DailyWorkloadView Component', () => {
|
|
|
36
37
|
expect(screen.getByText('Lab testing')).toBeInTheDocument();
|
|
37
38
|
});
|
|
38
39
|
|
|
39
|
-
it('navigates when a service area is clicked', () => {
|
|
40
|
+
it('navigates when a service area is clicked', async () => {
|
|
41
|
+
const user = userEvent.setup();
|
|
42
|
+
|
|
40
43
|
render(<DailyWorkloadView {...mockData} />);
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
await user.click(screen.getByText('HIV'));
|
|
43
46
|
|
|
44
47
|
expect(navigate).toHaveBeenCalledWith({
|
|
45
48
|
to: `${spaBasePath}/appointments/list/Fri, 18 Aug 2023 00:00:00 GMT/HIV`,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
2
|
import dayjs from 'dayjs';
|
|
4
|
-
import
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
import { CalendarType } from '../../types';
|
|
6
6
|
import { spaBasePath } from '../../constants';
|
|
7
7
|
import { navigate } from '@openmrs/esm-framework';
|
|
8
|
+
import WeeklyWorkloadView from './weekly-view-workload.component';
|
|
8
9
|
|
|
9
10
|
jest.mock('@openmrs/esm-framework', () => ({
|
|
10
11
|
...jest.requireActual('@openmrs/esm-framework'),
|
|
@@ -37,10 +38,12 @@ describe('WeeklyWorkloadView Component', () => {
|
|
|
37
38
|
expect(screen.getByText('Lab testing')).toBeInTheDocument();
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
it('navigates when a service area is clicked', () => {
|
|
41
|
+
it('navigates when a service area is clicked', async () => {
|
|
42
|
+
const user = userEvent.setup();
|
|
43
|
+
|
|
41
44
|
render(<WeeklyWorkloadView {...mockData} />);
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
await user.click(screen.getByText('HIV'));
|
|
44
47
|
|
|
45
48
|
expect(navigate).toHaveBeenCalledWith({
|
|
46
49
|
to: `${spaBasePath}/appointments/list/Thu, 17 Aug 2023 00:00:00 GMT/HIV`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { ActionsMenu } from './appointment-actions.component';
|
|
4
5
|
|
|
5
6
|
jest.mock('@openmrs/esm-framework', () => ({
|
|
@@ -30,7 +31,9 @@ describe('ActionsMenu', () => {
|
|
|
30
31
|
jest.clearAllMocks();
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
it('renders the actions menu with correct options and handlers', () => {
|
|
34
|
+
it('renders the actions menu with correct options and handlers', async () => {
|
|
35
|
+
const user = userEvent.setup();
|
|
36
|
+
|
|
34
37
|
const mockAppointment = {
|
|
35
38
|
id: '123',
|
|
36
39
|
recurring: false,
|
|
@@ -39,12 +42,12 @@ describe('ActionsMenu', () => {
|
|
|
39
42
|
|
|
40
43
|
renderActionsMenu({ appointment: mockAppointment, useBahmniUI: 'true' });
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
await user.click(screen.getByText(/Edit Appointment/i));
|
|
46
|
+
await user.click(screen.getByText(/Check In/i));
|
|
47
|
+
await user.click(screen.getByText(/Complete/i));
|
|
48
|
+
await user.click(screen.getByText(/Missed/i));
|
|
49
|
+
await user.click(screen.getByText(/Cancel/i));
|
|
50
|
+
await user.click(screen.getByText(/Add new appointment/i));
|
|
48
51
|
|
|
49
52
|
expect(screen.getByText(/Edit Appointment/i)).toBeInTheDocument();
|
|
50
53
|
expect(screen.getByText(/Check In/i)).toBeInTheDocument();
|
|
@@ -54,7 +57,9 @@ describe('ActionsMenu', () => {
|
|
|
54
57
|
expect(screen.getByText(/Add new appointment/i)).toBeInTheDocument();
|
|
55
58
|
});
|
|
56
59
|
|
|
57
|
-
it('renders the actions menu with correct options and handlers in non-BahmniUI mode', () => {
|
|
60
|
+
it('renders the actions menu with correct options and handlers in non-BahmniUI mode', async () => {
|
|
61
|
+
const user = userEvent.setup();
|
|
62
|
+
|
|
58
63
|
const mockAppointment = {
|
|
59
64
|
id: '456',
|
|
60
65
|
recurring: true,
|
|
@@ -63,12 +68,12 @@ describe('ActionsMenu', () => {
|
|
|
63
68
|
|
|
64
69
|
renderActionsMenu({ appointment: mockAppointment, useBahmniUI: undefined });
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
await user.click(screen.getByText(/Edit Appointment/i));
|
|
72
|
+
await user.click(screen.getByText(/Check In/i));
|
|
73
|
+
await user.click(screen.getByText(/Complete/i));
|
|
74
|
+
await user.click(screen.getByText(/Missed/i));
|
|
75
|
+
await user.click(screen.getByText(/Cancel/i));
|
|
76
|
+
await user.click(screen.getByText(/Add new appointment/i));
|
|
72
77
|
|
|
73
78
|
expect(screen.getByText('Edit Appointment')).toBeInTheDocument();
|
|
74
79
|
expect(screen.getByText('Check In')).toBeInTheDocument();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { showActionableNotification, showNotification } from '@openmrs/esm-framework';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
5
4
|
import { updateAppointmentStatus } from '../appointments-table.resource';
|
|
5
|
+
import { showActionableNotification, showNotification } from '@openmrs/esm-framework';
|
|
6
|
+
import CheckInAppointmentModal from './check-in-modal.component';
|
|
6
7
|
|
|
7
8
|
const mockUpdateAppointmentStatus = updateAppointmentStatus as jest.Mock;
|
|
8
9
|
const appointmentUuid = '7cd38a6d-377e-491b-8284-b04cf8b8c6d8';
|
|
@@ -16,40 +17,44 @@ describe('CheckInAppointmentModal', () => {
|
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
it('submits and displays success notification', async () => {
|
|
20
|
+
const user = await userEvent.setup();
|
|
21
|
+
|
|
19
22
|
mockUpdateAppointmentStatus.mockResolvedValue({ status: 200 });
|
|
20
23
|
const closeCheckInModal = jest.fn();
|
|
21
24
|
|
|
22
25
|
render(<CheckInAppointmentModal closeCheckInModal={closeCheckInModal} appointmentUuid={appointmentUuid} />);
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
await user.type(screen.getByRole('textbox'), '10:30');
|
|
28
|
+
await user.click(screen.getByText('Yes'));
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
expect(showActionableNotification).toHaveBeenCalled();
|
|
30
|
-
});
|
|
30
|
+
expect(closeCheckInModal).toHaveBeenCalled();
|
|
31
|
+
expect(showActionableNotification).toHaveBeenCalled();
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
it('displays error notification on submit failure', async () => {
|
|
35
|
+
const user = userEvent.setup();
|
|
36
|
+
|
|
34
37
|
mockUpdateAppointmentStatus.mockResolvedValue({ status: 400 });
|
|
35
38
|
const closeCheckInModal = jest.fn();
|
|
36
39
|
|
|
37
40
|
render(<CheckInAppointmentModal closeCheckInModal={closeCheckInModal} appointmentUuid={appointmentUuid} />);
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
fireEvent.click(screen.getByText('Yes'));
|
|
42
|
+
const input = screen.getByRole('textbox');
|
|
41
43
|
|
|
42
|
-
await
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
await user.type(input, '10:30');
|
|
45
|
+
await user.click(screen.getByText('Yes'));
|
|
46
|
+
|
|
47
|
+
expect(showNotification).toHaveBeenCalled();
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
it('closes modal on "No" button click', () => {
|
|
50
|
+
it('closes modal on "No" button click', async () => {
|
|
51
|
+
const user = userEvent.setup();
|
|
52
|
+
|
|
48
53
|
const closeCheckInModal = jest.fn();
|
|
49
54
|
|
|
50
55
|
render(<CheckInAppointmentModal closeCheckInModal={closeCheckInModal} appointmentUuid={appointmentUuid} />);
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
await user.click(screen.getByText('No'));
|
|
53
58
|
|
|
54
59
|
expect(closeCheckInModal).toHaveBeenCalled();
|
|
55
60
|
});
|