@openmrs/esm-appointments-app 10.0.3-pre.8636 → 10.0.3-pre.8644
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/routes.json +1 -1
- package/package.json +6 -5
- package/src/appointments/appointment-tabs.test.tsx +3 -2
- package/src/appointments/common-components/appointments-actions.test.tsx +5 -4
- package/src/appointments/common-components/appointments-table.test.tsx +6 -5
- package/src/appointments/common-components/batch-change-appointment-statuses.test.tsx +14 -13
- package/src/appointments/common-components/end-appointment.test.tsx +9 -8
- package/src/appointments/details/appointment-details.test.tsx +3 -2
- package/src/appointments/unscheduled/unscheduled-appointments.test.tsx +10 -9
- package/src/appointments.test.tsx +2 -1
- package/src/calendar/appointments-calendar-view.test.tsx +4 -3
- package/src/form/appointments-form.test.tsx +26 -25
- package/src/helpers/__tests__/time.test.ts +1 -0
- package/src/helpers/functions.test.ts +1 -0
- package/src/hooks/usePatientAppointmentHistory.test.tsx +5 -4
- package/src/patient-appointments/patient-appointments-detailed-summary.test.tsx +3 -2
- package/src/patient-appointments/patient-appointments.resource.test.tsx +2 -1
- package/vitest.config.ts +4 -0
- package/jest.config.js +0 -3
package/.turbo/turbo-build.log
CHANGED
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0","appointments":">=2.0.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"},"order":2},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-dashboard","slot":"appointments-dashboard-slot","component":"appointmentsDashboard"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"hideDashboardTitle":true,"path":"appointments","slot":"patient-chart-appointments-dashboard-slot","title":"Appointments"}},{"name":"appointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"},{"name":"metrics-card-scheduled-appointments","component":"metricsCardScheduledAppointments","slot":"appointments-metrics-slot","order":1},{"name":"metrics-card-highest-volume-service","component":"metricsCardHighestVolumeService","slot":"appointments-metrics-slot","order":2},{"name":"metrics-card-providers-booked","component":"metricsCardProvidersBooked","slot":"appointments-metrics-slot","order":3}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"cancel-appointment-modal","component":"cancelAppointmentModal"},{"name":"batch-change-appointments-statuses-modal","component":"batchChangeAppointmentStatusesModal"}],"workspaceGroups2":[{"name":"appointments-group","scopePattern":"/home/appointments"}],"workspaceWindows2":[{"name":"appointments-window","group":"appointments-group"}],"workspaces2":[{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","window":"appointments-window"},{"name":"appointments-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"appointments-window"},{"name":"appointments-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"appointments-window"}],"version":"10.0.3-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0","appointments":">=2.0.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"},"order":2},{"component":"root","name":"clinical-appointments-dashboard","slot":"clinical-appointments-dashboard-slot"},{"name":"appointments-dashboard","slot":"appointments-dashboard-slot","component":"appointmentsDashboard"},{"name":"appointments-calendar-dashboard-link","slot":"calendar-dashboard-slot","component":"appointmentsCalendarDashboardLink"},{"name":"todays-appointments-dashboard","slot":"todays-appointment-slot","component":"homeAppointments"},{"name":"early-appointments-panel","component":"earlyAppointments"},{"name":"patient-appointments-summary-dashboard","component":"patientAppointmentsSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"hideDashboardTitle":true,"path":"appointments","slot":"patient-chart-appointments-dashboard-slot","title":"Appointments"}},{"name":"appointments-details-widget","component":"patientAppointmentsDetailedSummary","slot":"patient-chart-appointments-dashboard-slot","meta":{"columnSpan":1}},{"name":"patient-upcoming-appointment-widget","component":"patientUpcomingAppointmentsWidget","slot":"visit-form-top-slot"},{"name":"home-appointments-tile","slot":"home-metrics-tiles-slot","component":"homeAppointmentsTile"},{"name":"metrics-card-scheduled-appointments","component":"metricsCardScheduledAppointments","slot":"appointments-metrics-slot","order":1},{"name":"metrics-card-highest-volume-service","component":"metricsCardHighestVolumeService","slot":"appointments-metrics-slot","order":2},{"name":"metrics-card-providers-booked","component":"metricsCardProvidersBooked","slot":"appointments-metrics-slot","order":3}],"modals":[{"name":"end-appointment-modal","component":"endAppointmentModal"},{"name":"cancel-appointment-modal","component":"cancelAppointmentModal"},{"name":"batch-change-appointments-statuses-modal","component":"batchChangeAppointmentStatusesModal"}],"workspaceGroups2":[{"name":"appointments-group","scopePattern":"/home/appointments"}],"workspaceWindows2":[{"name":"appointments-window","group":"appointments-group"}],"workspaces2":[{"name":"appointments-form-workspace","component":"appointmentsFormWorkspace","window":"appointments-window"},{"name":"appointments-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"appointments-window"},{"name":"appointments-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"appointments-window"}],"version":"10.0.3-pre.8644"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-appointments-app",
|
|
3
|
-
"version": "10.0.3-pre.
|
|
3
|
+
"version": "10.0.3-pre.8644",
|
|
4
4
|
"description": "Appointments front-end module for O3",
|
|
5
5
|
"browser": "dist/openmrs-esm-appointments-app.js",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"build": "rspack --mode production",
|
|
15
15
|
"analyze": "rspack --mode=production --env analyze=true",
|
|
16
16
|
"lint": "eslint src --ext tsx",
|
|
17
|
-
"test": "
|
|
18
|
-
"test
|
|
19
|
-
"coverage": "
|
|
17
|
+
"test": "vitest run --passWithNoTests",
|
|
18
|
+
"test:watch": "vitest watch",
|
|
19
|
+
"coverage": "vitest run --coverage --passWithNoTests",
|
|
20
20
|
"typescript": "tsc",
|
|
21
21
|
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.extension.tsx' 'src/**/*modal.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' 'src/constants.ts' --config ../../tools/i18next-parser.config.js"
|
|
22
22
|
},
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"swr": "2.x"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"openmrs": "next"
|
|
59
|
+
"openmrs": "next",
|
|
60
|
+
"vitest": "^4.1.2"
|
|
60
61
|
},
|
|
61
62
|
"stableVersion": "10.0.2"
|
|
62
63
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { screen } from '@testing-library/react';
|
|
3
4
|
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
|
|
4
5
|
import { renderWithSwr, waitForLoadingToFinish } from 'tools';
|
|
5
6
|
import { mockAppointmentsData } from '__mocks__';
|
|
6
7
|
import AppointmentTabs from './appointment-tabs.component';
|
|
7
8
|
|
|
8
|
-
const mockOpenmrsFetch =
|
|
9
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
9
10
|
|
|
10
11
|
describe('AppointmentTabs', () => {
|
|
11
|
-
|
|
12
|
+
it.skip(`renders tabs showing different appointment lists`, async () => {
|
|
12
13
|
mockOpenmrsFetch.mockResolvedValue({ ...mockAppointmentsData } as unknown as FetchResponse);
|
|
13
14
|
|
|
14
15
|
renderWithSwr(<AppointmentTabs appointmentServiceTypes={['service-type-uuid']} />);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, afterAll, type Mock } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
|
|
4
5
|
import { type ConfigObject, configSchema } from '../../config-schema';
|
|
@@ -7,8 +8,8 @@ import AppointmentActions from './appointments-actions.component';
|
|
|
7
8
|
import { changeAppointmentStatus } from '../../patient-appointments/patient-appointments.resource';
|
|
8
9
|
import userEvent from '@testing-library/user-event';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
const mockChangeAppointmentStatus = changeAppointmentStatus as
|
|
11
|
+
vi.mock('../../patient-appointments/patient-appointments.resource');
|
|
12
|
+
const mockChangeAppointmentStatus = changeAppointmentStatus as Mock;
|
|
12
13
|
|
|
13
14
|
const appointment: Appointment = {
|
|
14
15
|
uuid: '7cd38a6d-377e-491b-8284-b04cf8b8c6d8',
|
|
@@ -59,11 +60,11 @@ const defaultProps = {
|
|
|
59
60
|
hasActiveVisit: false,
|
|
60
61
|
};
|
|
61
62
|
|
|
62
|
-
const mockUseConfig =
|
|
63
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
63
64
|
|
|
64
65
|
describe('AppointmentActions', () => {
|
|
65
66
|
afterAll(() => {
|
|
66
|
-
|
|
67
|
+
vi.useRealTimers();
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
it('renders the check in button when appointment is scheduled and check in button is enabled', () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
|
|
@@ -61,13 +62,13 @@ const mockAppointments = [
|
|
|
61
62
|
},
|
|
62
63
|
] as unknown as Array<Appointment>;
|
|
63
64
|
|
|
64
|
-
const mockUseConfig =
|
|
65
|
-
const mockExportAppointmentsToSpreadsheet =
|
|
65
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
66
|
+
const mockExportAppointmentsToSpreadsheet = vi.mocked(exportAppointmentsToSpreadsheet);
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
vi.mock('../../helpers/excel', async () => {
|
|
68
69
|
return {
|
|
69
|
-
...
|
|
70
|
-
exportAppointmentsToSpreadsheet:
|
|
70
|
+
...((await vi.importActual('../../helpers/excel')) as object),
|
|
71
|
+
exportAppointmentsToSpreadsheet: vi.fn(),
|
|
71
72
|
};
|
|
72
73
|
});
|
|
73
74
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import { getDefaultsFromConfigSchema, showSnackbar, useConfig } from '@openmrs/esm-framework';
|
|
@@ -8,23 +9,23 @@ import { type Appointment, AppointmentKind, AppointmentStatus } from '../../type
|
|
|
8
9
|
import { type ConfigObject, configSchema } from '../../config-schema';
|
|
9
10
|
import BatchChangeAppointmentStatusesModal from './batch-change-appointment-statuses.modal';
|
|
10
11
|
|
|
11
|
-
const mockCloseModal =
|
|
12
|
-
const mockMutateAppointments =
|
|
13
|
-
const mockChangeAppointmentStatus =
|
|
14
|
-
const mockShowSnackbar =
|
|
15
|
-
const mockUseConfig =
|
|
16
|
-
const mockUseMutateAppointments =
|
|
12
|
+
const mockCloseModal = vi.fn();
|
|
13
|
+
const mockMutateAppointments = vi.fn();
|
|
14
|
+
const mockChangeAppointmentStatus = vi.mocked(changeAppointmentStatus);
|
|
15
|
+
const mockShowSnackbar = vi.mocked(showSnackbar);
|
|
16
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
17
|
+
const mockUseMutateAppointments = vi.mocked(useMutateAppointments);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
changeAppointmentStatus:
|
|
19
|
+
vi.mock('../../patient-appointments/patient-appointments.resource', () => ({
|
|
20
|
+
changeAppointmentStatus: vi.fn(),
|
|
20
21
|
}));
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
getActiveVisitsForPatient:
|
|
23
|
+
vi.mock('./batch-change-appointment-statuses.resources', () => ({
|
|
24
|
+
getActiveVisitsForPatient: vi.fn(),
|
|
24
25
|
}));
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
useMutateAppointments:
|
|
27
|
+
vi.mock('../../hooks/useMutateAppointments', () => ({
|
|
28
|
+
useMutateAppointments: vi.fn(),
|
|
28
29
|
}));
|
|
29
30
|
|
|
30
31
|
const mockAppointment1: Appointment = {
|
|
@@ -85,7 +86,7 @@ const mockAppointment2: Appointment = {
|
|
|
85
86
|
|
|
86
87
|
describe('BatchChangeAppointmentStatusesModal', () => {
|
|
87
88
|
beforeEach(() => {
|
|
88
|
-
|
|
89
|
+
vi.clearAllMocks();
|
|
89
90
|
mockUseConfig.mockReturnValue({
|
|
90
91
|
...getDefaultsFromConfigSchema(configSchema),
|
|
91
92
|
checkOutButton: { enabled: true, customUrl: '' },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import {
|
|
@@ -12,16 +13,16 @@ import {
|
|
|
12
13
|
import { changeAppointmentStatus } from '../../patient-appointments/patient-appointments.resource';
|
|
13
14
|
import EndAppointmentModal from './end-appointment.modal';
|
|
14
15
|
|
|
15
|
-
const closeModal =
|
|
16
|
-
const mockUseVisit =
|
|
17
|
-
const mockUpdateVisit =
|
|
16
|
+
const closeModal = vi.fn();
|
|
17
|
+
const mockUseVisit = vi.mocked(useVisit);
|
|
18
|
+
const mockUpdateVisit = vi.mocked(updateVisit);
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
changeAppointmentStatus:
|
|
20
|
+
vi.mock('../../patient-appointments/patient-appointments.resource', () => ({
|
|
21
|
+
changeAppointmentStatus: vi.fn().mockResolvedValue({}),
|
|
21
22
|
}));
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
useMutateAppointments:
|
|
24
|
+
vi.mock('../../hooks/useMutateAppointments', () => ({
|
|
25
|
+
useMutateAppointments: vi.fn().mockReturnValue({ mutateAppointments: vi.fn() }),
|
|
25
26
|
}));
|
|
26
27
|
|
|
27
28
|
describe('EndAppointmentModal', () => {
|
|
@@ -65,7 +66,7 @@ describe('EndAppointmentModal', () => {
|
|
|
65
66
|
|
|
66
67
|
mockUseVisit.mockReturnValue({
|
|
67
68
|
activeVisit: { location: { uuid: 'def' }, visitType: { uuid: 'ghi' }, startDatetime: new Date() },
|
|
68
|
-
mutate:
|
|
69
|
+
mutate: vi.fn(),
|
|
69
70
|
} as unknown as VisitReturnType);
|
|
70
71
|
|
|
71
72
|
render(<EndAppointmentModal appointmentUuid={'abc'} patientUuid={'123'} closeModal={closeModal} />);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, expect, test } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { usePatient } from '@openmrs/esm-framework';
|
|
4
5
|
import { mockPatient } from 'tools';
|
|
@@ -50,9 +51,9 @@ const appointment: Appointment = {
|
|
|
50
51
|
extensions: [],
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
const mockUsePatient =
|
|
54
|
+
const mockUsePatient = vi.mocked(usePatient);
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
vi.mock('../../hooks/usePatientAppointmentHistory', () => ({
|
|
56
57
|
usePatientAppointmentHistory: () => ({
|
|
57
58
|
appointmentsCount: {
|
|
58
59
|
completedAppointments: 1,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
|
|
@@ -8,21 +9,21 @@ import { getByTextWithMarkup } from 'tools';
|
|
|
8
9
|
import { useUnscheduledAppointments } from '../../hooks/useUnscheduledAppointments';
|
|
9
10
|
import UnscheduledAppointments from './unscheduled-appointments.component';
|
|
10
11
|
|
|
11
|
-
const mockExportUnscheduledAppointmentsToSpreadsheet =
|
|
12
|
-
const mockUseUnscheduledAppointments =
|
|
13
|
-
const mockUseConfig =
|
|
12
|
+
const mockExportUnscheduledAppointmentsToSpreadsheet = vi.mocked(exportUnscheduledAppointmentsToSpreadsheet);
|
|
13
|
+
const mockUseUnscheduledAppointments = vi.mocked(useUnscheduledAppointments);
|
|
14
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
vi.mock('../../helpers/excel', async () => {
|
|
16
17
|
return {
|
|
17
|
-
...
|
|
18
|
-
exportUnscheduledAppointmentsToSpreadsheet:
|
|
18
|
+
...((await vi.importActual('../../helpers/excel')) as object),
|
|
19
|
+
exportUnscheduledAppointmentsToSpreadsheet: vi.fn(),
|
|
19
20
|
};
|
|
20
21
|
});
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
vi.mock('../../hooks/useUnscheduledAppointments', async () => {
|
|
23
24
|
return {
|
|
24
|
-
...
|
|
25
|
-
useUnscheduledAppointments:
|
|
25
|
+
...((await vi.importActual('../../hooks/useUnscheduledAppointments')) as object),
|
|
26
|
+
useUnscheduledAppointments: vi.fn(),
|
|
26
27
|
};
|
|
27
28
|
});
|
|
28
29
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { useConfig, getDefaultsFromConfigSchema } from '@openmrs/esm-framework';
|
|
4
5
|
import Appointments from './appointments.component';
|
|
5
6
|
import { type ConfigObject, configSchema } from './config-schema';
|
|
6
7
|
import { BrowserRouter } from 'react-router-dom';
|
|
7
8
|
|
|
8
|
-
const mockUseConfig =
|
|
9
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
9
10
|
|
|
10
11
|
describe('Appointments', () => {
|
|
11
12
|
beforeEach(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import dayjs from 'dayjs';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import { render, screen } from '@testing-library/react';
|
|
@@ -6,11 +7,11 @@ import { BrowserRouter } from 'react-router-dom';
|
|
|
6
7
|
import AppointmentsCalendarView from './appointments-calendar-view.component';
|
|
7
8
|
import { useAppointmentsCalendar } from '../hooks/useAppointmentsCalendar';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
useAppointmentsCalendar:
|
|
10
|
+
vi.mock('../hooks/useAppointmentsCalendar', () => ({
|
|
11
|
+
useAppointmentsCalendar: vi.fn().mockReturnValue({ calendarEvents: [], isLoading: false, error: null }),
|
|
11
12
|
}));
|
|
12
13
|
|
|
13
|
-
const mockUseAppointmentsCalendar =
|
|
14
|
+
const mockUseAppointmentsCalendar = vi.mocked(useAppointmentsCalendar);
|
|
14
15
|
|
|
15
16
|
function renderCalendar() {
|
|
16
17
|
return render(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, test, beforeEach } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { fireEvent, screen } from '@testing-library/react';
|
|
4
5
|
import {
|
|
@@ -49,7 +50,7 @@ const existingAppointment = {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const defaultProps = {
|
|
52
|
-
closeWorkspace:
|
|
53
|
+
closeWorkspace: vi.fn(),
|
|
53
54
|
workspaceProps: {
|
|
54
55
|
patientUuid: mockPatient.id,
|
|
55
56
|
},
|
|
@@ -58,36 +59,36 @@ const defaultProps = {
|
|
|
58
59
|
workspaceName: 'appointments-form',
|
|
59
60
|
windowName: 'test-window',
|
|
60
61
|
isRootWorkspace: true,
|
|
61
|
-
launchChildWorkspace:
|
|
62
|
+
launchChildWorkspace: vi.fn(),
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const mockOpenmrsFetch =
|
|
65
|
-
const mockSaveAppointment =
|
|
66
|
-
const mockCheckAppointmentConflict =
|
|
67
|
-
const mockShowSnackbar =
|
|
68
|
-
const mockUseConfig =
|
|
69
|
-
const mockUseLocations =
|
|
70
|
-
const mockUseProviders =
|
|
71
|
-
const mockUseSession =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...
|
|
75
|
-
saveAppointment:
|
|
76
|
-
checkAppointmentConflict:
|
|
65
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
66
|
+
const mockSaveAppointment = vi.mocked(saveAppointment);
|
|
67
|
+
const mockCheckAppointmentConflict = vi.mocked(checkAppointmentConflict);
|
|
68
|
+
const mockShowSnackbar = vi.mocked(showSnackbar);
|
|
69
|
+
const mockUseConfig = vi.mocked(useConfig<ConfigObject>);
|
|
70
|
+
const mockUseLocations = vi.mocked(useLocations);
|
|
71
|
+
const mockUseProviders = vi.mocked(useProviders);
|
|
72
|
+
const mockUseSession = vi.mocked(useSession);
|
|
73
|
+
|
|
74
|
+
vi.mock('./appointments-form.resource', async () => ({
|
|
75
|
+
...((await vi.importActual('./appointments-form.resource')) as object),
|
|
76
|
+
saveAppointment: vi.fn(),
|
|
77
|
+
checkAppointmentConflict: vi.fn(),
|
|
77
78
|
}));
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
...
|
|
81
|
-
useProviders:
|
|
80
|
+
vi.mock('../hooks/useProviders', async () => ({
|
|
81
|
+
...((await vi.importActual('../hooks/useProviders')) as object),
|
|
82
|
+
useProviders: vi.fn(),
|
|
82
83
|
}));
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
...
|
|
86
|
-
getMonthlyCalendarDistribution:
|
|
87
|
-
useAppointmentSummary:
|
|
88
|
-
useCalendarDistribution:
|
|
89
|
-
useMonthlyCalendarDistribution:
|
|
90
|
-
useMonthlyAppointmentSummary:
|
|
85
|
+
vi.mock('../workload/workload.resource', async () => ({
|
|
86
|
+
...((await vi.importActual('../workload/workload.resource')) as object),
|
|
87
|
+
getMonthlyCalendarDistribution: vi.fn(),
|
|
88
|
+
useAppointmentSummary: vi.fn(),
|
|
89
|
+
useCalendarDistribution: vi.fn(),
|
|
90
|
+
useMonthlyCalendarDistribution: vi.fn().mockReturnValue([]),
|
|
91
|
+
useMonthlyAppointmentSummary: vi.fn().mockReturnValue([]),
|
|
91
92
|
}));
|
|
92
93
|
|
|
93
94
|
describe('AppointmentForm', () => {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { renderHook, waitFor } from '@testing-library/react';
|
|
3
4
|
import { SWRConfig } from 'swr';
|
|
4
5
|
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
5
6
|
import { usePatientAppointmentHistory } from './usePatientAppointmentHistory';
|
|
6
7
|
|
|
7
|
-
const mockOpenmrsFetch =
|
|
8
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
useSelectedDate:
|
|
10
|
+
vi.mock('./useSelectedDate', () => ({
|
|
11
|
+
useSelectedDate: vi.fn(),
|
|
11
12
|
}));
|
|
12
13
|
|
|
13
14
|
import { useSelectedDate } from './useSelectedDate';
|
|
14
15
|
|
|
15
|
-
const mockUseSelectedDate =
|
|
16
|
+
const mockUseSelectedDate = vi.mocked(useSelectedDate);
|
|
16
17
|
|
|
17
18
|
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
18
19
|
<SWRConfig
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
|
|
@@ -17,10 +18,10 @@ import AppointmentsDetailedSummary from './patient-appointments-detailed-summary
|
|
|
17
18
|
const testProps = {
|
|
18
19
|
basePath: patientChartBasePath,
|
|
19
20
|
patientUuid: mockPatient.id,
|
|
20
|
-
launchAppointmentForm:
|
|
21
|
+
launchAppointmentForm: vi.fn(),
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
const mockOpenmrsFetch =
|
|
24
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
24
25
|
|
|
25
26
|
describe('AppointmentsDetailedSummary', () => {
|
|
26
27
|
it('renders an empty state if appointments data is unavailable', async () => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { renderHook, waitFor } from '@testing-library/react';
|
|
3
4
|
import { SWRConfig } from 'swr';
|
|
4
5
|
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
5
6
|
import { usePatientAppointments } from './patient-appointments.resource';
|
|
6
7
|
|
|
7
|
-
const mockOpenmrsFetch =
|
|
8
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
8
9
|
|
|
9
10
|
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
10
11
|
<SWRConfig
|
package/vitest.config.ts
ADDED
package/jest.config.js
DELETED