@openmrs/esm-ward-app 10.0.3-pre.8636 → 10.0.3-pre.8642

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.
@@ -3,4 +3,4 @@
3
3
  │ 4064.js (1.700 MiB)
4
4
  
5
5
 
6
- Rspack compiled with 1 warning in 36.91 s
6
+ Rspack compiled with 1 warning in 28.56 s
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">3.3.0 <4.0.0","emrapi":">=2.0.0 <4.0.0"},"optionalBackendDependencies":{"bedmanagement":{"version":">=6.0.0 <8.0.0","feature":{"flagName":"bedmanagement-module","label":"Ward App Patient Service","description":"This module, if installed, provides services for managing patients admitted to the ward."}}},"extensions":[{"name":"ward-dashboard-link","component":"wardDashboardLink","slot":"homepage-dashboard-slot","meta":{"name":"ward","slot":"ward-dashboard-slot","title":"Wards"}},{"component":"root","name":"ward-dashboard","slot":"ward-dashboard-slot"},{"component":"wardView","name":"ward-view","slot":"ward-view-slot"},{"component":"wardPatientActionButtonExtension","name":"ward-patient-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"coloredObsTagCardRowExtension","name":"colored-obs-tags-card-row","slot":"ward-patient-card-slot"},{"component":"defaultWardView","name":"default-ward","slot":"default-ward"},{"component":"maternalWardView","name":"maternal-ward","slot":"maternal-ward"},{"component":"wardPatientWorkspaceBanner","name":"ward-patient-workspace-banner","slot":"ward-workspace-patient-banner-slot"}],"modals":[{"name":"delete-note-modal","component":"deleteNoteModal"},{"name":"note-history-modal","component":"noteHistoryModal"}],"workspaces2":[{"name":"admission-requests-workspace","component":"admissionRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"transfer-elsewhere-workspace","component":"patientTransferRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"cancel-admission-request-workspace","component":"cancelAdmissionRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"admit-patient-form-workspace","component":"admitPatientFormWorkspace","window":"ward-manage-admissions-window"},{"name":"ward-app-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"ward-manage-admissions-window"},{"name":"ward-app-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"ward-manage-admissions-window"},{"name":"create-admission-encounter-workspace","component":"createAdmissionEncounterWorkspace","window":"ward-manage-admissions-window"},{"name":"ward-patient-workspace","component":"wardPatientWorkspace","window":"ward-patient"},{"name":"ward-patient-vitals-workspace","component":"@openmrs/esm-patient-vitals-app#exportedVitalsBiometricsFormWorkspace","window":"ward-patient"},{"name":"ward-patient-notes-workspace","component":"wardPatientNotesWorkspace","window":"ward-patient-notes"},{"name":"ward-patient-transfer-swap-workspace","component":"patientTransferAndSwapWorkspace","window":"ward-patient-transfer-swap"},{"name":"patient-discharge-workspace","component":"patientDischargeWorkspace","window":"ward-patient-discharge"},{"name":"ward-patient-clinical-forms-workspace","component":"@openmrs/esm-patient-forms-app#exportedClinicalFormsWorkspace","window":"ward-patient-clinical-forms"},{"name":"ward-patient-form-entry-workspace","component":"@openmrs/esm-patient-forms-app#exportedPatientFormEntryWorkspace","window":"ward-patient-clinical-forms"},{"name":"ward-patient-cancel-admission-request-workspace","component":"wardPatientCancelAdmissionRequestWorkspace","window":"ward-patient-cancel-admission-request"},{"name":"ward-patient-order-basket-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-drug-order-workspace","component":"@openmrs/esm-patient-medications-app#exportedAddDrugOrderWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-lab-order-workspace","component":"@openmrs/esm-patient-tests-app#exportedAddLabOrderWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-general-order-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"ward-patient-order-basket"}],"workspaceWindows2":[{"name":"ward-manage-admissions-window","width":"wider","group":"ward-manage-admissions"},{"name":"ward-patient","group":"ward-patient","icon":"wardPatientActionButton","width":"wider"},{"name":"ward-patient-notes","group":"ward-patient","icon":"wardPatientNotesActionButton"},{"name":"ward-patient-transfer-swap","group":"ward-patient","icon":"patientTransferAndSwapWorkspaceSiderailIcon"},{"name":"ward-patient-discharge","group":"ward-patient","icon":"patientDischargeWorkspaceSideRailIcon"},{"name":"ward-patient-clinical-forms","group":"ward-patient","icon":"clinicalFormWorkspaceSideRailIcon"},{"name":"ward-patient-order-basket","group":"ward-patient","icon":"orderBasketWorkspaceSideRailIcon"},{"name":"ward-patient-cancel-admission-request","group":"ward-patient"}],"workspaceGroups2":[{"name":"ward-manage-admissions","scopePattern":"/home/ward","overlay":true},{"name":"ward-patient","scopePattern":"/home/ward","overlay":true,"persistence":"closable"}],"version":"10.0.3-pre.8636"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">3.3.0 <4.0.0","emrapi":">=2.0.0 <4.0.0"},"optionalBackendDependencies":{"bedmanagement":{"version":">=6.0.0 <8.0.0","feature":{"flagName":"bedmanagement-module","label":"Ward App Patient Service","description":"This module, if installed, provides services for managing patients admitted to the ward."}}},"extensions":[{"name":"ward-dashboard-link","component":"wardDashboardLink","slot":"homepage-dashboard-slot","meta":{"name":"ward","slot":"ward-dashboard-slot","title":"Wards"}},{"component":"root","name":"ward-dashboard","slot":"ward-dashboard-slot"},{"component":"wardView","name":"ward-view","slot":"ward-view-slot"},{"component":"wardPatientActionButtonExtension","name":"ward-patient-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"coloredObsTagCardRowExtension","name":"colored-obs-tags-card-row","slot":"ward-patient-card-slot"},{"component":"defaultWardView","name":"default-ward","slot":"default-ward"},{"component":"maternalWardView","name":"maternal-ward","slot":"maternal-ward"},{"component":"wardPatientWorkspaceBanner","name":"ward-patient-workspace-banner","slot":"ward-workspace-patient-banner-slot"}],"modals":[{"name":"delete-note-modal","component":"deleteNoteModal"},{"name":"note-history-modal","component":"noteHistoryModal"}],"workspaces2":[{"name":"admission-requests-workspace","component":"admissionRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"transfer-elsewhere-workspace","component":"patientTransferRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"cancel-admission-request-workspace","component":"cancelAdmissionRequestWorkspace","window":"ward-manage-admissions-window"},{"name":"admit-patient-form-workspace","component":"admitPatientFormWorkspace","window":"ward-manage-admissions-window"},{"name":"ward-app-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"ward-manage-admissions-window"},{"name":"ward-app-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"ward-manage-admissions-window"},{"name":"create-admission-encounter-workspace","component":"createAdmissionEncounterWorkspace","window":"ward-manage-admissions-window"},{"name":"ward-patient-workspace","component":"wardPatientWorkspace","window":"ward-patient"},{"name":"ward-patient-vitals-workspace","component":"@openmrs/esm-patient-vitals-app#exportedVitalsBiometricsFormWorkspace","window":"ward-patient"},{"name":"ward-patient-notes-workspace","component":"wardPatientNotesWorkspace","window":"ward-patient-notes"},{"name":"ward-patient-transfer-swap-workspace","component":"patientTransferAndSwapWorkspace","window":"ward-patient-transfer-swap"},{"name":"patient-discharge-workspace","component":"patientDischargeWorkspace","window":"ward-patient-discharge"},{"name":"ward-patient-clinical-forms-workspace","component":"@openmrs/esm-patient-forms-app#exportedClinicalFormsWorkspace","window":"ward-patient-clinical-forms"},{"name":"ward-patient-form-entry-workspace","component":"@openmrs/esm-patient-forms-app#exportedPatientFormEntryWorkspace","window":"ward-patient-clinical-forms"},{"name":"ward-patient-cancel-admission-request-workspace","component":"wardPatientCancelAdmissionRequestWorkspace","window":"ward-patient-cancel-admission-request"},{"name":"ward-patient-order-basket-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-drug-order-workspace","component":"@openmrs/esm-patient-medications-app#exportedAddDrugOrderWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-lab-order-workspace","component":"@openmrs/esm-patient-tests-app#exportedAddLabOrderWorkspace","window":"ward-patient-order-basket"},{"name":"ward-patient-order-basket-add-general-order-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"ward-patient-order-basket"}],"workspaceWindows2":[{"name":"ward-manage-admissions-window","width":"wider","group":"ward-manage-admissions"},{"name":"ward-patient","group":"ward-patient","icon":"wardPatientActionButton","width":"wider"},{"name":"ward-patient-notes","group":"ward-patient","icon":"wardPatientNotesActionButton"},{"name":"ward-patient-transfer-swap","group":"ward-patient","icon":"patientTransferAndSwapWorkspaceSiderailIcon"},{"name":"ward-patient-discharge","group":"ward-patient","icon":"patientDischargeWorkspaceSideRailIcon"},{"name":"ward-patient-clinical-forms","group":"ward-patient","icon":"clinicalFormWorkspaceSideRailIcon"},{"name":"ward-patient-order-basket","group":"ward-patient","icon":"orderBasketWorkspaceSideRailIcon"},{"name":"ward-patient-cancel-admission-request","group":"ward-patient"}],"workspaceGroups2":[{"name":"ward-manage-admissions","scopePattern":"/home/ward","overlay":true},{"name":"ward-patient","scopePattern":"/home/ward","overlay":true,"persistence":"closable"}],"version":"10.0.3-pre.8642"}
package/mock.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import { vi } from 'vitest';
1
2
  import {
2
3
  mockAdmissionLocation,
3
4
  mockInpatientAdmissions,
@@ -12,50 +13,50 @@ import { useWardPatientGrouping } from './src/hooks/useWardPatientGrouping';
12
13
  import { type WardViewContext } from './src/types';
13
14
  import DefaultWardPatientCardHeader from './src/ward-view/default-ward/default-ward-patient-card-header.component';
14
15
 
15
- jest.mock('./src/hooks/useAdmissionLocation', () => ({
16
- useAdmissionLocation: jest.fn(),
16
+ vi.mock('./src/hooks/useAdmissionLocation', () => ({
17
+ useAdmissionLocation: vi.fn(),
17
18
  }));
18
- jest.mock('./src/hooks/useInpatientAdmission', () => ({
19
- useInpatientAdmission: jest.fn(),
19
+ vi.mock('./src/hooks/useInpatientAdmission', () => ({
20
+ useInpatientAdmission: vi.fn(),
20
21
  }));
21
- jest.mock('./src/hooks/useInpatientRequest', () => ({
22
- useInpatientRequest: jest.fn(),
22
+ vi.mock('./src/hooks/useInpatientRequest', () => ({
23
+ useInpatientRequest: vi.fn(),
23
24
  }));
24
- jest.mock('./src/hooks/useWardPatientGrouping', () => ({
25
- useWardPatientGrouping: jest.fn(),
25
+ vi.mock('./src/hooks/useWardPatientGrouping', () => ({
26
+ useWardPatientGrouping: vi.fn(),
26
27
  }));
27
- const mockAdmissionLocationResponse = jest.mocked(useAdmissionLocation).mockReturnValue({
28
+ const mockAdmissionLocationResponse = vi.mocked(useAdmissionLocation).mockReturnValue({
28
29
  error: undefined,
29
- mutate: jest.fn(),
30
+ mutate: vi.fn(),
30
31
  isValidating: false,
31
32
  isLoading: false,
32
33
  admissionLocation: mockAdmissionLocation,
33
34
  });
34
- const mockInpatientAdmissionResponse = jest.mocked(useInpatientAdmission).mockReturnValue({
35
+ const mockInpatientAdmissionResponse = vi.mocked(useInpatientAdmission).mockReturnValue({
35
36
  data: mockInpatientAdmissions,
36
37
  hasMore: false,
37
- loadMore: jest.fn(),
38
+ loadMore: vi.fn(),
38
39
  isValidating: false,
39
40
  isLoading: false,
40
41
  error: undefined,
41
- mutate: jest.fn(),
42
+ mutate: vi.fn(),
42
43
  totalCount: mockInpatientAdmissions.length,
43
44
  nextUri: null,
44
45
  });
45
46
 
46
- const mockInpatientRequestResponse = jest.mocked(useInpatientRequest).mockReturnValue({
47
+ const mockInpatientRequestResponse = vi.mocked(useInpatientRequest).mockReturnValue({
47
48
  inpatientRequests: mockInpatientRequests,
48
49
  hasMore: false,
49
- loadMore: jest.fn(),
50
+ loadMore: vi.fn(),
50
51
  isValidating: false,
51
52
  isLoading: false,
52
53
  error: undefined,
53
- mutate: jest.fn(),
54
+ mutate: vi.fn(),
54
55
  totalCount: mockInpatientRequests.length,
55
56
  nextUri: null,
56
57
  });
57
58
 
58
- export const mockWardPatientGroupDetails = jest.mocked(useWardPatientGrouping).mockReturnValue({
59
+ export const mockWardPatientGroupDetails = vi.mocked(useWardPatientGrouping).mockReturnValue({
59
60
  admissionLocationResponse: mockAdmissionLocationResponse(),
60
61
  inpatientAdmissionResponse: mockInpatientAdmissionResponse(),
61
62
  inpatientRequestResponse: mockInpatientRequestResponse(),
@@ -67,7 +68,7 @@ export const mockWardPatientGroupDetails = jest.mocked(useWardPatientGrouping).m
67
68
  mockLocationInpatientWard,
68
69
  ),
69
70
  isLoading: false,
70
- mutate: jest.fn(),
71
+ mutate: vi.fn(),
71
72
  });
72
73
 
73
74
  export const mockWardViewContext: WardViewContext = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-ward-app",
3
- "version": "10.0.3-pre.8636",
3
+ "version": "10.0.3-pre.8642",
4
4
  "description": "Ward and bed management module for O3",
5
5
  "browser": "dist/openmrs-esm-ward-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": "cross-env eslint src --ext ts,tsx",
17
- "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
18
- "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
19
- "coverage": "yarn test --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/**/*.resource.ts' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
22
22
  },
@@ -51,7 +51,8 @@
51
51
  "swr": "2.x"
52
52
  },
53
53
  "devDependencies": {
54
- "openmrs": "next"
54
+ "openmrs": "next",
55
+ "vitest": "^4.1.2"
55
56
  },
56
57
  "stableVersion": "10.0.2"
57
58
  }
@@ -1,4 +1,5 @@
1
1
  import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
2
+ import { vi, describe, it, expect, type Mock } from 'vitest';
2
3
  import { render, screen } from '@testing-library/react';
3
4
  import React from 'react';
4
5
  import {
@@ -17,23 +18,24 @@ import WardBed from './ward-bed.component';
17
18
 
18
19
  const defaultConfig: WardConfigObject = getDefaultsFromConfigSchema(configSchema);
19
20
 
20
- jest.mocked(useConfig).mockReturnValue(defaultConfig);
21
- jest.mock('../hooks/useObs', () => ({
22
- useObs: jest.fn(),
21
+ vi.mocked(useConfig).mockReturnValue(defaultConfig);
22
+ vi.mock('../hooks/useObs', () => ({
23
+ useObs: vi.fn(),
23
24
  }));
24
- jest.mock('../ward-patient-card/row-elements/ward-patient-obs.resource', () => ({
25
- useConceptToTagColorMap: jest.fn(),
25
+ vi.mock('../ward-patient-card/row-elements/ward-patient-obs.resource', async (importOriginal) => ({
26
+ ...((await importOriginal()) as object),
27
+ useConceptToTagColorMap: vi.fn(),
26
28
  }));
27
29
 
28
30
  const mockBedLayouts = filterBeds(mockAdmissionLocation);
29
31
 
30
- jest.mock('../hooks/useWardLocation', () => jest.fn());
32
+ vi.mock('../hooks/useWardLocation', () => ({ default: vi.fn() }));
31
33
  //@ts-ignore
32
- jest.mocked(useObs).mockReturnValue({
34
+ vi.mocked(useObs).mockReturnValue({
33
35
  data: [],
34
36
  });
35
37
 
36
- const mockedUseWardLocation = useWardLocation as jest.Mock;
38
+ const mockedUseWardLocation = useWardLocation as Mock;
37
39
  mockedUseWardLocation.mockReturnValue({
38
40
  location: mockLocationInpatientWard,
39
41
  isLoadingLocation: false,
@@ -1,18 +1,19 @@
1
1
  import useSWRImmutable from 'swr/immutable';
2
+ import { vi, describe, it, expect, type Mock } from 'vitest';
2
3
  import { renderHook } from '@testing-library/react';
3
4
  import { restBaseUrl } from '@openmrs/esm-framework';
4
5
  import useLocation from './useLocation';
5
6
 
6
- jest.mock('swr/immutable', () =>
7
- jest.fn().mockReturnValue({
7
+ vi.mock('swr/immutable', () => ({
8
+ default: vi.fn().mockReturnValue({
8
9
  data: {},
9
10
  error: null,
10
11
  isValidating: false,
11
- mutate: jest.fn(),
12
+ mutate: vi.fn(),
12
13
  }),
13
- );
14
+ }));
14
15
 
15
- const useSWRImmutableMock = useSWRImmutable as jest.Mock;
16
+ const useSWRImmutableMock = useSWRImmutable as Mock;
16
17
 
17
18
  describe('useLocation hook', () => {
18
19
  it('should call useLocation', () => {
@@ -1,21 +1,23 @@
1
1
  import { renderHook } from '@testing-library/react';
2
+ import { vi, describe, it, expect, test, beforeEach, type Mock } from 'vitest';
2
3
  import { type FetchResponse, useSession } from '@openmrs/esm-framework';
3
4
  import { mockSession } from '__mocks__';
4
5
  import { useParams } from 'react-router-dom';
5
6
  import useWardLocation from './useWardLocation';
6
7
  import useLocation from './useLocation';
7
8
 
8
- jest.mock('@openmrs/esm-framework', () => ({
9
- useSession: jest.fn(),
9
+ vi.mock('@openmrs/esm-framework', async (importOriginal) => ({
10
+ ...((await importOriginal()) as object),
11
+ useSession: vi.fn(),
10
12
  }));
11
- jest.mock('react-router-dom', () => ({
12
- useParams: jest.fn(),
13
+ vi.mock('react-router-dom', () => ({
14
+ useParams: vi.fn(),
13
15
  }));
14
- jest.mock('./useLocation', () => jest.fn());
16
+ vi.mock('./useLocation', () => ({ default: vi.fn() }));
15
17
 
16
- const mockUseParams = jest.mocked(useParams);
17
- const mockUseSession = jest.mocked(useSession);
18
- const mockUseLocation = useLocation as jest.Mock;
18
+ const mockUseParams = vi.mocked(useParams);
19
+ const mockUseSession = vi.mocked(useSession);
20
+ const mockUseLocation = useLocation as Mock;
19
21
 
20
22
  describe('useWardLocation', () => {
21
23
  beforeEach(() => {
@@ -29,7 +31,7 @@ describe('useWardLocation', () => {
29
31
  error: null,
30
32
  isLoading: null,
31
33
  isValidating: null,
32
- mutate: jest.fn(),
34
+ mutate: vi.fn(),
33
35
  });
34
36
 
35
37
  const { result } = renderHook(() => useWardLocation());
@@ -49,7 +51,7 @@ describe('useWardLocation', () => {
49
51
  error: null,
50
52
  isLoading: false,
51
53
  isValidating: null,
52
- mutate: jest.fn(),
54
+ mutate: vi.fn(),
53
55
  });
54
56
 
55
57
  const { result } = renderHook(() => useWardLocation());
@@ -69,7 +71,7 @@ describe('useWardLocation', () => {
69
71
  error: null,
70
72
  isLoading: true,
71
73
  isValidating: false,
72
- mutate: jest.fn(),
74
+ mutate: vi.fn(),
73
75
  });
74
76
 
75
77
  const { result } = renderHook(() => useWardLocation());
@@ -84,7 +86,7 @@ describe('useWardLocation', () => {
84
86
  error,
85
87
  isLoading: false,
86
88
  isValidating: false,
87
- mutate: jest.fn(),
89
+ mutate: vi.fn(),
88
90
  });
89
91
 
90
92
  const { result } = renderHook(() => useWardLocation());
@@ -99,7 +101,7 @@ describe('useWardLocation', () => {
99
101
  error,
100
102
  isLoading: false,
101
103
  isValidating: false,
102
- mutate: jest.fn(),
104
+ mutate: vi.fn(),
103
105
  });
104
106
 
105
107
  const { result } = renderHook(() => useWardLocation());
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi, describe, it, expect, beforeEach } from 'vitest';
2
3
  import { getDefaultsFromConfigSchema, useAppContext, useConfig } from '@openmrs/esm-framework';
3
4
  import { screen } from '@testing-library/react';
4
5
  import { configSchema, type WardConfigObject } from '../../config-schema';
@@ -11,20 +12,21 @@ import { useObs } from '../../hooks/useObs';
11
12
  import { type WardPatient, type WardViewContext } from '../../types';
12
13
  import MaternalWardPatientCard from './maternal-ward-patient-card.component';
13
14
 
14
- const mockUseConfig = jest.mocked(useConfig<WardConfigObject>);
15
+ const mockUseConfig = vi.mocked(useConfig<WardConfigObject>);
15
16
 
16
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
17
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
17
18
 
18
- jest.mock('../../hooks/useObs', () => ({
19
- useObs: jest.fn(),
19
+ vi.mock('../../hooks/useObs', () => ({
20
+ useObs: vi.fn(),
20
21
  }));
21
22
 
22
- jest.mock('../../ward-patient-card/row-elements/ward-patient-obs.resource', () => ({
23
- useConceptToTagColorMap: jest.fn(),
23
+ vi.mock('../../ward-patient-card/row-elements/ward-patient-obs.resource', async (importOriginal) => ({
24
+ ...((await importOriginal()) as object),
25
+ useConceptToTagColorMap: vi.fn(),
24
26
  }));
25
27
 
26
28
  //@ts-ignore
27
- jest.mocked(useObs).mockReturnValue({
29
+ vi.mocked(useObs).mockReturnValue({
28
30
  data: [],
29
31
  });
30
32
 
@@ -1,4 +1,5 @@
1
1
  import { createAndGetWardPatientGrouping, getWardMetrics } from './ward-view.resource';
2
+ import { vi, describe, it, expect } from 'vitest';
2
3
  import { type AdmissionLocationFetchResponse, type InpatientAdmission, type WardPatientGroupDetails } from '../types';
3
4
  import type { Location } from '@openmrs/esm-framework';
4
5
 
@@ -1,51 +1,54 @@
1
1
  import React from 'react';
2
+ import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
2
3
  import { useParams } from 'react-router-dom';
3
4
  import { screen } from '@testing-library/react';
4
5
  import { getDefaultsFromConfigSchema, useAppContext, useConfig, useFeatureFlag } from '@openmrs/esm-framework';
5
6
  import { configSchema, type WardConfigObject } from '../config-schema';
6
7
  import { mockWardPatientGroupDetails, mockWardViewContext } from '../../mock';
7
- import { renderWithSwr } from 'tools';
8
+ import { renderWithSwr, replaceProperty } from 'tools';
8
9
  import { type WardViewContext } from '../types';
9
10
  import { useObs } from '../hooks/useObs';
10
11
  import useWardLocation from '../hooks/useWardLocation';
11
12
  import DefaultWardView from './default-ward/default-ward-view.component';
12
13
  import WardView from './ward-view.component';
13
14
 
14
- const mockUseConfig = jest.mocked(useConfig<WardConfigObject>);
15
- const mockUseFeatureFlag = jest.mocked(useFeatureFlag);
16
- const mockUseWardLocation = jest.mocked(useWardLocation);
17
- const mockUseParams = jest.mocked(useParams);
15
+ const mockUseConfig = vi.mocked(useConfig<WardConfigObject>);
16
+ const mockUseFeatureFlag = vi.mocked(useFeatureFlag);
17
+ const mockUseWardLocation = vi.mocked(useWardLocation);
18
+ const mockUseParams = vi.mocked(useParams);
18
19
 
19
- jest.mock('react-router-dom', () => ({
20
- ...jest.requireActual('react-router-dom'),
21
- useParams: jest.fn().mockReturnValue({}),
20
+ vi.mock('react-router-dom', async () => ({
21
+ ...((await vi.importActual('react-router-dom')) as object),
22
+ useParams: vi.fn().mockReturnValue({}),
22
23
  }));
23
24
 
24
- jest.mock('../hooks/useWardLocation', () =>
25
- jest.fn().mockReturnValue({
25
+ vi.mock('../hooks/useWardLocation', () => ({
26
+ default: vi.fn().mockReturnValue({
26
27
  location: { uuid: 'abcd', display: 'mock location' },
27
28
  isLoadingLocation: false,
28
29
  errorFetchingLocation: null,
29
30
  invalidLocation: false,
30
31
  }),
31
- );
32
+ }));
32
33
 
33
- jest.mock('../hooks/useObs', () => ({
34
- useObs: jest.fn(),
34
+ vi.mock('../hooks/useObs', () => ({
35
+ useObs: vi.fn(),
35
36
  }));
36
37
 
37
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
38
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
38
39
 
39
40
  //@ts-ignore
40
- jest.mocked(useObs).mockReturnValue({
41
+ vi.mocked(useObs).mockReturnValue({
41
42
  data: [],
42
43
  });
43
44
 
44
- const intersectionObserverMock = () => ({
45
- observe: () => null,
46
- });
45
+ class IntersectionObserverMock {
46
+ observe() {}
47
+ unobserve() {}
48
+ disconnect() {}
49
+ }
47
50
 
48
- window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
51
+ window.IntersectionObserver = IntersectionObserverMock as unknown as typeof IntersectionObserver;
49
52
 
50
53
  beforeEach(() => {
51
54
  const config = getDefaultsFromConfigSchema<WardConfigObject>(configSchema);
@@ -53,7 +56,7 @@ beforeEach(() => {
53
56
  });
54
57
 
55
58
  describe('WardView', () => {
56
- let replacedProperty: ReturnType<typeof jest.replaceProperty> | null = null;
59
+ let replacedProperty: ReturnType<typeof replaceProperty> | null = null;
57
60
 
58
61
  it('renders the session location when no location provided in URL', () => {
59
62
  renderWithSwr(<DefaultWardView />);
@@ -104,7 +107,7 @@ describe('WardView', () => {
104
107
 
105
108
  it('should render warning if backend module installed and no beds configured', () => {
106
109
  // override the default response so that no beds are returned
107
- replacedProperty = jest.replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
110
+ replacedProperty = replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
108
111
 
109
112
  mockUseFeatureFlag.mockReturnValue(true);
110
113
 
@@ -115,7 +118,7 @@ describe('WardView', () => {
115
118
 
116
119
  it('should not render warning if backend module installed and no beds configured', () => {
117
120
  // override the default response so that no beds are returned
118
- replacedProperty = jest.replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
121
+ replacedProperty = replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
119
122
  mockUseFeatureFlag.mockReturnValue(false);
120
123
 
121
124
  renderWithSwr(<WardView />);
@@ -1,4 +1,5 @@
1
1
  import { launchWorkspace2, useAppContext } from '@openmrs/esm-framework';
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 React from 'react';
@@ -7,8 +8,8 @@ import { mockWardViewContext } from '../../mock';
7
8
  import { type WardViewContext } from '../types';
8
9
  import AdmissionRequestsBar from './admission-requests-bar.component';
9
10
 
10
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
11
- const mockLaunchWorkspace = jest.mocked(launchWorkspace2);
11
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
12
+ const mockLaunchWorkspace = vi.mocked(launchWorkspace2);
12
13
  describe('Admission Requests Button', () => {
13
14
  it('should launch workspace when clicked on manage button', async () => {
14
15
  const user = userEvent.setup();
@@ -1,4 +1,5 @@
1
1
  import { useAppContext } from '@openmrs/esm-framework';
2
+ import { vi, describe, it, expect } from 'vitest';
2
3
  import { screen } from '@testing-library/react';
3
4
  import React from 'react';
4
5
  import { renderWithSwr } from 'tools';
@@ -6,7 +7,7 @@ import { mockWardViewContext } from '../../mock';
6
7
  import { WardMetricType, type WardViewContext } from '../types';
7
8
  import WardMetrics from './ward-metrics.component';
8
9
 
9
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
10
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
10
11
 
11
12
  describe('Ward Metrics', () => {
12
13
  it('Should display standard metrics by default', () => {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi, describe, it, expect, beforeEach } from 'vitest';
2
3
  import { screen } from '@testing-library/react';
3
4
  import { useAppContext, useWorkspace2Context, type Workspace2DefinitionProps } from '@openmrs/esm-framework';
4
5
  import { renderWithSwr } from 'tools';
@@ -8,15 +9,15 @@ import useEmrConfiguration from '../../hooks/useEmrConfiguration';
8
9
  import DefaultWardPendingPatients from '../../ward-view/default-ward/default-ward-pending-patients.component';
9
10
  import AdmissionRequestsWorkspace, { type AdmissionRequestsWorkspaceProps } from './admission-requests.workspace';
10
11
 
11
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
12
- const mockUseWorkspace2Context = jest.mocked(useWorkspace2Context);
12
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
13
+ const mockUseWorkspace2Context = vi.mocked(useWorkspace2Context);
13
14
 
14
- jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
15
- const mockedUseEmrConfiguration = jest.mocked(useEmrConfiguration);
15
+ vi.mock('../../hooks/useEmrConfiguration', () => ({ default: vi.fn() }));
16
+ const mockedUseEmrConfiguration = vi.mocked(useEmrConfiguration);
16
17
 
17
18
  const workspaceProps: Workspace2DefinitionProps<AdmissionRequestsWorkspaceProps> = {
18
- closeWorkspace: jest.fn(),
19
- launchChildWorkspace: jest.fn(),
19
+ closeWorkspace: vi.fn(),
20
+ launchChildWorkspace: vi.fn(),
20
21
  workspaceProps: {
21
22
  wardPendingPatients: <DefaultWardPendingPatients />,
22
23
  },
@@ -46,11 +47,11 @@ describe('Admission Requests Workspace', () => {
46
47
  uuid: 'clinician-encounter-role-uuid',
47
48
  },
48
49
  },
49
- mutateEmrConfiguration: jest.fn(),
50
+ mutateEmrConfiguration: vi.fn(),
50
51
  });
51
52
  mockUseWorkspace2Context.mockReturnValue({
52
- closeWorkspace: jest.fn(),
53
- launchChildWorkspace: jest.fn(),
53
+ closeWorkspace: vi.fn(),
54
+ launchChildWorkspace: vi.fn(),
54
55
  workspaceProps: undefined,
55
56
  windowProps: undefined,
56
57
  groupProps: undefined,
@@ -71,7 +72,7 @@ describe('Admission Requests Workspace', () => {
71
72
  isLoadingEmrConfiguration: false,
72
73
  errorFetchingEmrConfiguration: true,
73
74
  emrConfiguration: null,
74
- mutateEmrConfiguration: jest.fn(),
75
+ mutateEmrConfiguration: vi.fn(),
75
76
  });
76
77
 
77
78
  renderWithSwr(<AdmissionRequestsWorkspace {...workspaceProps} />);
@@ -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 { screen } from '@testing-library/react';
4
5
  import {
@@ -9,7 +10,7 @@ import {
9
10
  type Workspace2DefinitionProps,
10
11
  } from '@openmrs/esm-framework';
11
12
  import { mockInpatientRequestAlice, mockLocationInpatientWard, mockPatientAlice } from '__mocks__';
12
- import { renderWithSwr } from 'tools';
13
+ import { renderWithSwr, replaceProperty } from 'tools';
13
14
  import { mockWardPatientGroupDetails, mockWardViewContext } from '../../../mock';
14
15
  import { useAssignedBedByPatient } from '../../hooks/useAssignedBedByPatient';
15
16
  import type { WardPatient, WardPatientWorkspaceProps, WardViewContext } from '../../types';
@@ -22,54 +23,54 @@ import {
22
23
  import AdmitPatientFormWorkspace from './admit-patient-form.workspace';
23
24
  import useWardLocation from '../../hooks/useWardLocation';
24
25
 
25
- jest.mock('../../hooks/useAdmissionLocation', () => ({
26
- useAdmissionLocation: jest.fn(),
26
+ vi.mock('../../hooks/useAdmissionLocation', () => ({
27
+ useAdmissionLocation: vi.fn(),
27
28
  }));
28
29
 
29
- jest.mock('../../hooks/useWardLocation', () => jest.fn());
30
+ vi.mock('../../hooks/useWardLocation', () => ({ default: vi.fn() }));
30
31
 
31
- jest.mock('../../hooks/useInpatientRequest', () => ({
32
- useInpatientRequest: jest.fn(),
32
+ vi.mock('../../hooks/useInpatientRequest', () => ({
33
+ useInpatientRequest: vi.fn(),
33
34
  }));
34
35
 
35
- jest.mock('../../hooks/useWardPatientGrouping', () => ({
36
- useWardPatientGrouping: jest.fn(),
36
+ vi.mock('../../hooks/useWardPatientGrouping', () => ({
37
+ useWardPatientGrouping: vi.fn(),
37
38
  }));
38
39
 
39
- jest.mock('../../hooks/useInpatientAdmission', () => ({
40
- useInpatientAdmission: jest.fn(),
40
+ vi.mock('../../hooks/useInpatientAdmission', () => ({
41
+ useInpatientAdmission: vi.fn(),
41
42
  }));
42
43
 
43
- jest.mock('../../hooks/useAssignedBedByPatient', () => ({
44
- useAssignedBedByPatient: jest.fn(),
44
+ vi.mock('../../hooks/useAssignedBedByPatient', () => ({
45
+ useAssignedBedByPatient: vi.fn(),
45
46
  }));
46
47
 
47
- jest.mock('../../ward.resource', () => ({
48
- useAdmitPatient: jest.fn(),
49
- assignPatientToBed: jest.fn(),
50
- removePatientFromBed: jest.fn(),
51
- getAssignedBedByPatient: jest.fn(),
48
+ vi.mock('../../ward.resource', () => ({
49
+ useAdmitPatient: vi.fn(),
50
+ assignPatientToBed: vi.fn(),
51
+ removePatientFromBed: vi.fn(),
52
+ getAssignedBedByPatient: vi.fn(),
52
53
  }));
53
54
 
54
- const mockedUseWardLocation = jest.mocked(useWardLocation);
55
- const mockedUseFeatureFlag = jest.mocked(useFeatureFlag);
56
- const mockedShowSnackbar = jest.mocked(showSnackbar);
57
- const mockedUseSession = jest.mocked(useSession);
58
- const mockedUseAssignedBedByPatient = jest.mocked(useAssignedBedByPatient);
59
- const mockedAssignPatientToBed = jest.mocked(assignPatientToBed);
60
- const mockedRemovePatientFromBed = jest.mocked(removePatientFromBed);
61
- const mockedUseAdmitPatient = jest.mocked(useAdmitPatient);
62
- const mockedGetAssignedBedByPatient = jest.mocked(getAssignedBedByPatient);
55
+ const mockedUseWardLocation = vi.mocked(useWardLocation);
56
+ const mockedUseFeatureFlag = vi.mocked(useFeatureFlag);
57
+ const mockedShowSnackbar = vi.mocked(showSnackbar);
58
+ const mockedUseSession = vi.mocked(useSession);
59
+ const mockedUseAssignedBedByPatient = vi.mocked(useAssignedBedByPatient);
60
+ const mockedAssignPatientToBed = vi.mocked(assignPatientToBed);
61
+ const mockedRemovePatientFromBed = vi.mocked(removePatientFromBed);
62
+ const mockedUseAdmitPatient = vi.mocked(useAdmitPatient);
63
+ const mockedGetAssignedBedByPatient = vi.mocked(getAssignedBedByPatient);
63
64
 
64
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
65
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
65
66
 
66
- const mockedAdmitPatient = jest.fn();
67
+ const mockedAdmitPatient = vi.fn();
67
68
  const mockUseAdmitPatientObj: ReturnType<typeof useAdmitPatient> = {
68
69
  admitPatient: mockedAdmitPatient,
69
70
  isLoadingEmrConfiguration: false,
70
71
  errorFetchingEmrConfiguration: false,
71
72
  };
72
- jest.mocked(useAdmitPatient).mockReturnValue(mockUseAdmitPatientObj);
73
+ vi.mocked(useAdmitPatient).mockReturnValue(mockUseAdmitPatientObj);
73
74
 
74
75
  const mockWardPatientAliceProps: WardPatient = {
75
76
  visit: mockInpatientRequestAlice.visit,
@@ -80,8 +81,8 @@ const mockWardPatientAliceProps: WardPatient = {
80
81
  };
81
82
 
82
83
  const mockWorkspaceProps: Workspace2DefinitionProps<WardPatientWorkspaceProps, {}, {}> = {
83
- closeWorkspace: jest.fn(),
84
- launchChildWorkspace: jest.fn(),
84
+ closeWorkspace: vi.fn(),
85
+ launchChildWorkspace: vi.fn(),
85
86
  workspaceProps: {
86
87
  wardPatient: mockWardPatientAliceProps,
87
88
  },
@@ -193,7 +194,7 @@ describe('Testing AdmitPatientForm', () => {
193
194
 
194
195
  it('should render admit patient form if bed management module is present, but no beds are configured', () => {
195
196
  mockedUseFeatureFlag.mockReturnValue(true);
196
- const replacedProperty = jest.replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
197
+ const replacedProperty = replaceProperty(mockWardPatientGroupDetails(), 'bedLayouts', []);
197
198
  renderAdmissionForm();
198
199
  expect(screen.getByText('Select a bed')).toBeInTheDocument();
199
200
  expect(screen.getByText(/No beds configured/i)).toBeInTheDocument();
@@ -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 { useAppContext, type DefaultWorkspaceProps } from '@openmrs/esm-framework';
@@ -10,32 +11,32 @@ import { useCreateEncounter } from '../../ward.resource';
10
11
  import CancelAdmissionRequestWorkspace from './cancel-admission-request.workspace';
11
12
  import { mockWardViewContext } from '../../../mock';
12
13
 
13
- jest.mock('../../hooks/useWardLocation', () => jest.fn());
14
+ vi.mock('../../hooks/useWardLocation', () => ({ default: vi.fn() }));
14
15
 
15
- jest.mock('../../hooks/useInpatientRequest', () => ({
16
- useInpatientRequest: jest.fn(),
16
+ vi.mock('../../hooks/useInpatientRequest', () => ({
17
+ useInpatientRequest: vi.fn(),
17
18
  }));
18
19
 
19
- jest.mock('../../hooks/useWardPatientGrouping', () => ({
20
- useWardPatientGrouping: jest.fn(),
20
+ vi.mock('../../hooks/useWardPatientGrouping', () => ({
21
+ useWardPatientGrouping: vi.fn(),
21
22
  }));
22
23
 
23
- jest.mock('../../hooks/useInpatientAdmission', () => ({
24
- useInpatientAdmission: jest.fn(),
24
+ vi.mock('../../hooks/useInpatientAdmission', () => ({
25
+ useInpatientAdmission: vi.fn(),
25
26
  }));
26
27
 
27
- jest.mock('../../ward.resource', () => ({
28
- useCreateEncounter: jest.fn(),
28
+ vi.mock('../../ward.resource', () => ({
29
+ useCreateEncounter: vi.fn(),
29
30
  }));
30
31
 
31
- const mockedUseWardLocation = jest.mocked(useWardLocation);
32
- const mockedCreateEncounter = jest.fn().mockResolvedValue({
32
+ const mockedUseWardLocation = vi.mocked(useWardLocation);
33
+ const mockedCreateEncounter = vi.fn().mockResolvedValue({
33
34
  ok: true,
34
35
  data: {
35
36
  uuid: 'encounter-uuid',
36
37
  },
37
38
  });
38
- const mockedUseCreateEncounter = jest.mocked(useCreateEncounter);
39
+ const mockedUseCreateEncounter = vi.mocked(useCreateEncounter);
39
40
  mockedUseCreateEncounter.mockReturnValue({
40
41
  createEncounter: mockedCreateEncounter,
41
42
  isLoadingEmrConfiguration: false,
@@ -58,13 +59,13 @@ const mockWardPatientAlice: WardPatient = {
58
59
  inpatientRequest: mockInpatientRequestAlice,
59
60
  };
60
61
 
61
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
62
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
62
63
 
63
64
  function renderCancelAdmissionRequestWorkspace() {
64
65
  renderWithSwr(
65
66
  <CancelAdmissionRequestWorkspace
66
- launchChildWorkspace={jest.fn()}
67
- closeWorkspace={jest.fn()}
67
+ launchChildWorkspace={vi.fn()}
68
+ closeWorkspace={vi.fn()}
68
69
  workspaceProps={{
69
70
  wardPatient: mockWardPatientAlice,
70
71
  }}
@@ -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 { useAppContext, useVisit, useWorkspace2Context } from '@openmrs/esm-framework';
@@ -21,11 +22,11 @@ import { type WardViewContext } from '../../types';
21
22
  import { useAdmitPatient } from '../../ward.resource';
22
23
  import CreateAdmissionEncounterWorkspace from './create-admission-encounter.workspace';
23
24
 
24
- jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
25
- const mockUseWorkspace2Context = jest.mocked(useWorkspace2Context);
25
+ vi.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
26
+ const mockUseWorkspace2Context = vi.mocked(useWorkspace2Context);
26
27
  mockUseWorkspace2Context.mockReturnValue({
27
- closeWorkspace: jest.fn(),
28
- launchChildWorkspace: jest.fn(),
28
+ closeWorkspace: vi.fn(),
29
+ launchChildWorkspace: vi.fn(),
29
30
  showActionMenu: false,
30
31
  workspaceProps: undefined,
31
32
  windowProps: undefined,
@@ -35,7 +36,7 @@ mockUseWorkspace2Context.mockReturnValue({
35
36
  isRootWorkspace: false,
36
37
  });
37
38
 
38
- const mockUseVisit = jest.mocked(useVisit).mockReturnValue({
39
+ const mockUseVisit = vi.mocked(useVisit).mockReturnValue({
39
40
  activeVisit: {
40
41
  encounters: [],
41
42
  startDatetime: new Date().toISOString(),
@@ -45,14 +46,14 @@ const mockUseVisit = jest.mocked(useVisit).mockReturnValue({
45
46
  },
46
47
  currentVisit: null,
47
48
  currentVisitIsRetrospective: null,
48
- mutate: jest.fn(),
49
+ mutate: vi.fn(),
49
50
  error: undefined,
50
51
  isLoading: false,
51
52
  isValidating: false,
52
53
  });
53
54
 
54
- jest.mock('../../hooks/useWardLocation', () => jest.fn());
55
- const mockedUseWardLocation = jest.mocked(useWardLocation);
55
+ vi.mock('../../hooks/useWardLocation', () => ({ default: vi.fn() }));
56
+ const mockedUseWardLocation = vi.mocked(useWardLocation);
56
57
  mockedUseWardLocation.mockReturnValue({
57
58
  location: mockLocationInpatientWard,
58
59
  isLoadingLocation: false,
@@ -60,21 +61,21 @@ mockedUseWardLocation.mockReturnValue({
60
61
  invalidLocation: false,
61
62
  });
62
63
 
63
- jest.mock('../../hooks/useRestPatient', () => jest.fn());
64
- const mockUseRestPatient = jest.mocked(useRestPatient).mockReturnValue({
64
+ vi.mock('../../hooks/useRestPatient', () => ({ default: vi.fn() }));
65
+ const mockUseRestPatient = vi.mocked(useRestPatient).mockReturnValue({
65
66
  patient: mockPatientAlice,
66
67
  isLoading: false,
67
68
  error: null,
68
69
  isValidating: false,
69
- mutate: jest.fn(),
70
+ mutate: vi.fn(),
70
71
  });
71
72
 
72
- jest.mock('../../hooks/useAssignedBedByPatient', () => ({
73
- useAssignedBedByPatient: jest.fn(),
73
+ vi.mock('../../hooks/useAssignedBedByPatient', () => ({
74
+ useAssignedBedByPatient: vi.fn(),
74
75
  }));
75
76
 
76
77
  // @ts-ignore - we don't need to mock the entire object
77
- jest.mocked(useAssignedBedByPatient).mockReturnValue({
78
+ vi.mocked(useAssignedBedByPatient).mockReturnValue({
78
79
  data: {
79
80
  data: {
80
81
  results: [
@@ -91,38 +92,38 @@ jest.mocked(useAssignedBedByPatient).mockReturnValue({
91
92
  isLoading: false,
92
93
  });
93
94
 
94
- jest.mock('../../hooks/useInpatientAdmissionByPatients', () => ({
95
- useInpatientAdmissionByPatients: jest.fn(),
95
+ vi.mock('../../hooks/useInpatientAdmissionByPatients', () => ({
96
+ useInpatientAdmissionByPatients: vi.fn(),
96
97
  }));
97
- const mockedUseInpatientAdmissionByPatients = jest.mocked(useInpatientAdmissionByPatients).mockReturnValue({
98
+ const mockedUseInpatientAdmissionByPatients = vi.mocked(useInpatientAdmissionByPatients).mockReturnValue({
98
99
  data: [],
99
100
  hasMore: false,
100
- loadMore: jest.fn(),
101
+ loadMore: vi.fn(),
101
102
  isValidating: false,
102
103
  isLoading: false,
103
104
  error: undefined,
104
- mutate: jest.fn(),
105
+ mutate: vi.fn(),
105
106
  totalCount: mockInpatientAdmissions.length,
106
107
  nextUri: null,
107
108
  });
108
109
 
109
- jest.mock('../../hooks/useInpatientRequestByPatients', () => ({
110
- useInpatientRequestByPatients: jest.fn(),
110
+ vi.mock('../../hooks/useInpatientRequestByPatients', () => ({
111
+ useInpatientRequestByPatients: vi.fn(),
111
112
  }));
112
- const mockedUseInpatientRequestByPatients = jest.mocked(useInpatientRequestByPatients).mockReturnValue({
113
+ const mockedUseInpatientRequestByPatients = vi.mocked(useInpatientRequestByPatients).mockReturnValue({
113
114
  inpatientRequests: [],
114
115
  hasMore: false,
115
- loadMore: jest.fn(),
116
+ loadMore: vi.fn(),
116
117
  isValidating: false,
117
118
  isLoading: false,
118
119
  error: undefined,
119
- mutate: jest.fn(),
120
+ mutate: vi.fn(),
120
121
  totalCount: mockInpatientAdmissions.length,
121
122
  nextUri: null,
122
123
  });
123
124
 
124
- jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
125
- jest.mocked(useEmrConfiguration).mockReturnValue({
125
+ vi.mock('../../hooks/useEmrConfiguration', () => ({ default: vi.fn() }));
126
+ vi.mocked(useEmrConfiguration).mockReturnValue({
126
127
  isLoadingEmrConfiguration: false,
127
128
  errorFetchingEmrConfiguration: null,
128
129
  // @ts-ignore - we only need these keys for now
@@ -139,20 +140,20 @@ jest.mocked(useEmrConfiguration).mockReturnValue({
139
140
  uuid: 'clinician-encounter-role-uuid',
140
141
  },
141
142
  },
142
- mutateEmrConfiguration: jest.fn(),
143
+ mutateEmrConfiguration: vi.fn(),
143
144
  });
144
145
 
145
- jest.mock('../../ward.resource', () => ({
146
- useAdmitPatient: jest.fn(),
147
- assignPatientToBed: jest.fn(),
148
- removePatientFromBed: jest.fn(),
146
+ vi.mock('../../ward.resource', () => ({
147
+ useAdmitPatient: vi.fn(),
148
+ assignPatientToBed: vi.fn(),
149
+ removePatientFromBed: vi.fn(),
149
150
  }));
150
151
  const mockedUseAdmitPatient: ReturnType<typeof useAdmitPatient> = {
151
- admitPatient: jest.fn(),
152
+ admitPatient: vi.fn(),
152
153
  isLoadingEmrConfiguration: false,
153
154
  errorFetchingEmrConfiguration: false,
154
155
  };
155
- jest.mocked(useAdmitPatient).mockReturnValue(mockedUseAdmitPatient);
156
+ vi.mocked(useAdmitPatient).mockReturnValue(mockedUseAdmitPatient);
156
157
  const mockedAdmitPatient = mockedUseAdmitPatient.admitPatient;
157
158
  // @ts-ignore - we only need these two keys for now
158
159
  mockedAdmitPatient.mockResolvedValue({
@@ -177,11 +178,11 @@ describe('CreateAdmissionEncounterWorkspace', () => {
177
178
  mockedUseInpatientRequestByPatients.mockReturnValueOnce({
178
179
  inpatientRequests: mockInpatientRequests,
179
180
  hasMore: false,
180
- loadMore: jest.fn(),
181
+ loadMore: vi.fn(),
181
182
  isValidating: false,
182
183
  isLoading: false,
183
184
  error: undefined,
184
- mutate: jest.fn(),
185
+ mutate: vi.fn(),
185
186
  totalCount: mockInpatientAdmissions.length,
186
187
  nextUri: null,
187
188
  });
@@ -204,11 +205,11 @@ describe('CreateAdmissionEncounterWorkspace', () => {
204
205
  mockedUseInpatientAdmissionByPatients.mockReturnValueOnce({
205
206
  data: [{ ...mockInpatientAdmissions[0], currentInpatientLocation: mockLocationMosoriot }],
206
207
  hasMore: false,
207
- loadMore: jest.fn(),
208
+ loadMore: vi.fn(),
208
209
  isValidating: false,
209
210
  isLoading: false,
210
211
  error: undefined,
211
- mutate: jest.fn(),
212
+ mutate: vi.fn(),
212
213
  totalCount: mockInpatientAdmissions.length,
213
214
  nextUri: null,
214
215
  });
@@ -227,11 +228,11 @@ describe('CreateAdmissionEncounterWorkspace', () => {
227
228
  mockedUseInpatientAdmissionByPatients.mockReturnValueOnce({
228
229
  data: mockInpatientAdmissions,
229
230
  hasMore: false,
230
- loadMore: jest.fn(),
231
+ loadMore: vi.fn(),
231
232
  isValidating: false,
232
233
  isLoading: false,
233
234
  error: undefined,
234
- mutate: jest.fn(),
235
+ mutate: vi.fn(),
235
236
  totalCount: mockInpatientAdmissions.length,
236
237
  nextUri: null,
237
238
  });
@@ -248,8 +249,8 @@ function renderCreateAdmissionEncounterWorkspace(patentUuid: string) {
248
249
  windowName={''}
249
250
  isRootWorkspace={false}
250
251
  showActionMenu={false}
251
- closeWorkspace={jest.fn()}
252
- launchChildWorkspace={jest.fn()}
252
+ closeWorkspace={vi.fn()}
253
+ launchChildWorkspace={vi.fn()}
253
254
  workspaceProps={{
254
255
  selectedPatientUuid: patentUuid,
255
256
  }}
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
+ import { vi, describe, expect, test, beforeEach } from 'vitest';
2
3
  import { render, screen } from '@testing-library/react';
3
4
  import { emrConfigurationMock } from '__mocks__';
4
5
  import { useEmrConfiguration } from '@openmrs/esm-framework';
5
6
  import { type PatientNote } from '../types';
6
7
  import PatientNotesHistory from './notes-container.component';
7
8
 
8
- const mockedUseEmrConfiguration = jest.mocked(useEmrConfiguration);
9
+ const mockedUseEmrConfiguration = vi.mocked(useEmrConfiguration);
9
10
 
10
11
  const mockPatientNotes: PatientNote[] = [
11
12
  {
@@ -58,18 +59,18 @@ const mockEditedPatientNote: PatientNote = {
58
59
 
59
60
  const defaultProps = {
60
61
  patientNotes: [],
61
- mutatePatientNotes: jest.fn(),
62
+ mutatePatientNotes: vi.fn(),
62
63
  isLoading: false,
63
64
  errorFetchingPatientNotes: null,
64
- promptBeforeClosing: jest.fn(),
65
+ promptBeforeClosing: vi.fn(),
65
66
  };
66
67
 
67
68
  describe('PatientNotesHistory', () => {
68
69
  beforeEach(() => {
69
- jest.resetAllMocks();
70
+ vi.resetAllMocks();
70
71
  mockedUseEmrConfiguration.mockReturnValue({
71
72
  emrConfiguration: emrConfigurationMock,
72
- mutateEmrConfiguration: jest.fn(),
73
+ mutateEmrConfiguration: vi.fn(),
73
74
  isLoadingEmrConfiguration: false,
74
75
  errorFetchingEmrConfiguration: null,
75
76
  });
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi, describe, expect, test, type Mock } from 'vitest';
2
3
  import userEvent from '@testing-library/user-event';
3
4
  import { render, screen } from '@testing-library/react';
4
5
  import { getDefaultsFromConfigSchema, showSnackbar, useConfig } from '@openmrs/esm-framework';
@@ -21,8 +22,8 @@ const testProps: WardPatientWorkspaceDefinition = {
21
22
  groupProps: {
22
23
  wardPatient: mockWardPatientAlice,
23
24
  },
24
- closeWorkspace: jest.fn(),
25
- launchChildWorkspace: jest.fn(),
25
+ closeWorkspace: vi.fn(),
26
+ launchChildWorkspace: vi.fn(),
26
27
  workspaceProps: undefined,
27
28
  windowProps: undefined,
28
29
  workspaceName: '',
@@ -31,23 +32,23 @@ const testProps: WardPatientWorkspaceDefinition = {
31
32
  showActionMenu: false,
32
33
  };
33
34
 
34
- const mockCreatePatientNote = createPatientNote as jest.Mock;
35
- const mockedShowSnackbar = jest.mocked(showSnackbar);
35
+ const mockCreatePatientNote = createPatientNote as Mock;
36
+ const mockedShowSnackbar = vi.mocked(showSnackbar);
36
37
 
37
- jest.mock('./notes.resource', () => ({
38
- createPatientNote: jest.fn(),
39
- usePatientNotes: jest.fn(),
38
+ vi.mock('./notes.resource', () => ({
39
+ createPatientNote: vi.fn(),
40
+ usePatientNotes: vi.fn(),
40
41
  }));
41
42
 
42
- jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
43
+ vi.mock('../../hooks/useEmrConfiguration', () => ({ default: vi.fn() }));
43
44
 
44
- const mockedUseEmrConfiguration = jest.mocked(useEmrConfiguration);
45
- const mockedUsePatientNotes = jest.mocked(usePatientNotes);
46
- const mockUseConfig = jest.mocked(useConfig<WardConfigObject>);
45
+ const mockedUseEmrConfiguration = vi.mocked(useEmrConfiguration);
46
+ const mockedUsePatientNotes = vi.mocked(usePatientNotes);
47
+ const mockUseConfig = vi.mocked(useConfig<WardConfigObject>);
47
48
 
48
49
  mockedUseEmrConfiguration.mockReturnValue({
49
50
  emrConfiguration: emrConfigurationMock,
50
- mutateEmrConfiguration: jest.fn(),
51
+ mutateEmrConfiguration: vi.fn(),
51
52
  isLoadingEmrConfiguration: false,
52
53
  errorFetchingEmrConfiguration: null,
53
54
  });
@@ -58,7 +59,7 @@ describe('<WardPatientNotesWorkspace>', () => {
58
59
  patientNotes: [],
59
60
  errorFetchingPatientNotes: undefined,
60
61
  isLoadingPatientNotes: false,
61
- mutatePatientNotes: jest.fn(),
62
+ mutatePatientNotes: vi.fn(),
62
63
  });
63
64
 
64
65
  test('renders the visit notes form with all the relevant fields and values', () => {
@@ -0,0 +1,4 @@
1
+ import { mergeConfig } from 'vitest/config';
2
+ import sharedConfig from '../../tools/vitest.shared';
3
+
4
+ export default mergeConfig(sharedConfig, {});
package/jest.config.js DELETED
@@ -1,3 +0,0 @@
1
- const rootConfig = require('../../jest.config.js');
2
-
3
- module.exports = rootConfig;