@openmrs/esm-form-builder-app 3.4.2-pre.3477 → 3.4.2-pre.3479
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/dist/4701.js +2 -2
- package/dist/4701.js.map +1 -1
- package/dist/5491.js +2 -2
- package/dist/5491.js.map +1 -1
- package/dist/openmrs-esm-form-builder-app.js.buildmanifest.json +6 -6
- package/dist/routes.json +1 -1
- package/package.json +12 -13
- package/src/components/dashboard/dashboard.test.tsx +7 -6
- package/src/components/interactive-builder/drag-and-drop-helpers.test.ts +1 -0
- package/src/components/interactive-builder/interactive-builder.test.tsx +3 -2
- package/src/components/interactive-builder/modals/add-form-reference/add-form-reference.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/common/concept-search/concept-search.test.tsx +15 -14
- package/src/components/interactive-builder/modals/question/question-form/question/question.test.tsx +3 -2
- package/src/components/interactive-builder/modals/question/question-form/question-types/inputs/obs/obs-type-question.test.tsx +14 -13
- package/src/components/interactive-builder/modals/question/question-form/question-types/inputs/patient-identifier/patient-identifier-type.test.tsx +8 -7
- package/src/components/interactive-builder/modals/question/question-form/question-types/inputs/person-attribute/person-attribute-type-question.test.tsx +7 -6
- package/src/components/interactive-builder/modals/question/question-form/question-types/inputs/program-state/program-state.test.tsx +14 -13
- package/src/components/interactive-builder/modals/question/question-form/question-types/inputs/test-order/test-order-type-question.test.tsx +15 -14
- package/src/components/interactive-builder/modals/question/question-form/question-types/question-type.test.tsx +5 -4
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/date/date.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/number/number.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/select/select-answers.test.tsx +9 -8
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/text/text.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/text-area/textarea.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/toggle/toggle.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/inputs/ui-select-extended/ui-select-extended.test.tsx +4 -3
- package/src/components/interactive-builder/modals/question/question-form/rendering-types/rendering-type.test.tsx +5 -4
|
@@ -575,9 +575,9 @@
|
|
|
575
575
|
"initial": false,
|
|
576
576
|
"entry": false,
|
|
577
577
|
"reason": "split chunk (cache group: defaultVendors)",
|
|
578
|
-
"size":
|
|
578
|
+
"size": 3225562,
|
|
579
579
|
"sizes": {
|
|
580
|
-
"javascript":
|
|
580
|
+
"javascript": 3225562
|
|
581
581
|
},
|
|
582
582
|
"names": [],
|
|
583
583
|
"idHints": [
|
|
@@ -593,7 +593,7 @@
|
|
|
593
593
|
"auxiliaryFiles": [
|
|
594
594
|
"4701.js.map"
|
|
595
595
|
],
|
|
596
|
-
"hash": "
|
|
596
|
+
"hash": "fbcad02bff1f2cf9",
|
|
597
597
|
"childrenByOrder": {}
|
|
598
598
|
},
|
|
599
599
|
{
|
|
@@ -819,9 +819,9 @@
|
|
|
819
819
|
"initial": false,
|
|
820
820
|
"entry": false,
|
|
821
821
|
"reason": "split chunk (cache group: defaultVendors)",
|
|
822
|
-
"size":
|
|
822
|
+
"size": 3557838,
|
|
823
823
|
"sizes": {
|
|
824
|
-
"javascript":
|
|
824
|
+
"javascript": 3557838
|
|
825
825
|
},
|
|
826
826
|
"names": [],
|
|
827
827
|
"idHints": [
|
|
@@ -1307,7 +1307,7 @@
|
|
|
1307
1307
|
"fec23c6964d6cf25681d1f3e24b076a4.js",
|
|
1308
1308
|
"ffd3b83e8b5878f4785591ff54b1dfff.js"
|
|
1309
1309
|
],
|
|
1310
|
-
"hash": "
|
|
1310
|
+
"hash": "df675858fc8b1fcf",
|
|
1311
1311
|
"childrenByOrder": {}
|
|
1312
1312
|
},
|
|
1313
1313
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"form-builder","online":true,"offline":true,"order":1}],"extensions":[{"name":"system-administration-form-builder-card-link","slot":"system-admin-page-card-link-slot","component":"systemAdministrationFormBuilderCardLink","online":true,"offline":true}],"modals":[{"name":"new-form-modal","component":"newFormModal"},{"name":"new-page-modal","component":"newPageModal"},{"name":"delete-page-modal","component":"deletePageModal"},{"name":"new-section-modal","component":"newSectionModal"},{"name":"delete-section-modal","component":"deleteSectionModal"},{"name":"add-form-reference-modal","component":"addFormReferenceModal"},{"name":"question-modal","component":"questionModal"},{"name":"delete-question-modal","component":"deleteQuestionModal"},{"name":"edit-question-modal","component":"editQuestionModal"},{"name":"restore-draft-schema-modal","component":"restoreDraftSchemaModal"},{"name":"unpublish-form-modal","component":"unpublishFormModal"},{"name":"delete-form-modal","component":"deleteFormModal"},{"name":"edit-translation-modal","component":"editTranslationModal"}],"version":"3.4.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"form-builder","online":true,"offline":true,"order":1}],"extensions":[{"name":"system-administration-form-builder-card-link","slot":"system-admin-page-card-link-slot","component":"systemAdministrationFormBuilderCardLink","online":true,"offline":true}],"modals":[{"name":"new-form-modal","component":"newFormModal"},{"name":"new-page-modal","component":"newPageModal"},{"name":"delete-page-modal","component":"deletePageModal"},{"name":"new-section-modal","component":"newSectionModal"},{"name":"delete-section-modal","component":"deleteSectionModal"},{"name":"add-form-reference-modal","component":"addFormReferenceModal"},{"name":"question-modal","component":"questionModal"},{"name":"delete-question-modal","component":"deleteQuestionModal"},{"name":"edit-question-modal","component":"editQuestionModal"},{"name":"restore-draft-schema-modal","component":"restoreDraftSchemaModal"},{"name":"unpublish-form-modal","component":"unpublishFormModal"},{"name":"delete-form-modal","component":"deleteFormModal"},{"name":"edit-translation-modal","component":"editTranslationModal"}],"version":"3.4.2-pre.3479"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-form-builder-app",
|
|
3
|
-
"version": "3.4.2-pre.
|
|
3
|
+
"version": "3.4.2-pre.3479",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Form Builder for O3",
|
|
6
6
|
"browser": "dist/openmrs-esm-form-builder-app.js",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"analyze": "rspack --mode=production --env.analyze=true",
|
|
14
14
|
"lint": "eslint src --ext js,jsx,ts,tsx --max-warnings=0",
|
|
15
15
|
"typescript": "tsc",
|
|
16
|
-
"test": "
|
|
17
|
-
"test:watch": "
|
|
16
|
+
"test": "cross-env TZ=UTC vitest run --passWithNoTests",
|
|
17
|
+
"test:watch": "cross-env TZ=UTC vitest watch",
|
|
18
18
|
"test-e2e": "playwright test",
|
|
19
19
|
"verify": "turbo run lint typescript coverage --color",
|
|
20
|
-
"coverage": "
|
|
20
|
+
"coverage": "cross-env TZ=UTC vitest run --coverage --passWithNoTests",
|
|
21
21
|
"postinstall": "husky install",
|
|
22
22
|
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' --config ./tools/i18next-parser.config.js",
|
|
23
23
|
"ci:bump-form-engine-lib": "yarn up @openmrs/esm-form-engine-lib@latest"
|
|
@@ -75,16 +75,16 @@
|
|
|
75
75
|
"@playwright/test": "^1.50.1",
|
|
76
76
|
"@swc/cli": "^0.1.65",
|
|
77
77
|
"@swc/core": "^1.5.7",
|
|
78
|
-
"@
|
|
79
|
-
"@testing-library/dom": "^
|
|
80
|
-
"@testing-library/
|
|
81
|
-
"@testing-library/react": "^14.3.1",
|
|
78
|
+
"@testing-library/dom": "^10.4.1",
|
|
79
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
80
|
+
"@testing-library/react": "^16.3.0",
|
|
82
81
|
"@testing-library/user-event": "^14.5.2",
|
|
83
|
-
"@types/jest": "^29.5.12",
|
|
84
82
|
"@types/react": "^18.3.2",
|
|
85
83
|
"@types/react-dom": "^18.3.0",
|
|
86
84
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
87
85
|
"@typescript-eslint/parser": "^8.0.0",
|
|
86
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
87
|
+
"cross-env": "^10.1.0",
|
|
88
88
|
"eslint": "^8.57.0",
|
|
89
89
|
"eslint-plugin-import": "^2.31.0",
|
|
90
90
|
"eslint-plugin-jest-dom": "^5.4.0",
|
|
@@ -95,9 +95,7 @@
|
|
|
95
95
|
"i18next": "^25.0.0",
|
|
96
96
|
"i18next-parser": "^9.3.0",
|
|
97
97
|
"identity-obj-proxy": "^3.0.0",
|
|
98
|
-
"
|
|
99
|
-
"jest-cli": "^29.7.0",
|
|
100
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
98
|
+
"jsdom": "^28.0.0",
|
|
101
99
|
"lint-staged": "^14.0.1",
|
|
102
100
|
"openmrs": "next",
|
|
103
101
|
"prettier": "^3.3.3",
|
|
@@ -107,7 +105,8 @@
|
|
|
107
105
|
"react-i18next": "^16.0.0",
|
|
108
106
|
"rxjs": "^6.6.7",
|
|
109
107
|
"turbo": "^2.5.2",
|
|
110
|
-
"typescript": "^5.0.0"
|
|
108
|
+
"typescript": "^5.0.0",
|
|
109
|
+
"vitest": "^4.1.2"
|
|
111
110
|
},
|
|
112
111
|
"lint-staged": {
|
|
113
112
|
"*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
|
|
@@ -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, navigate, openmrsFetch, showModal } from '@openmrs/esm-framework';
|
|
@@ -12,9 +13,9 @@ type OpenmrsFetchResponse = Promise<
|
|
|
12
13
|
}>
|
|
13
14
|
>;
|
|
14
15
|
|
|
15
|
-
const mockedOpenmrsFetch =
|
|
16
|
-
const mockedDeleteForm =
|
|
17
|
-
const mockedShowModal =
|
|
16
|
+
const mockedOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
17
|
+
const mockedDeleteForm = vi.mocked(deleteForm);
|
|
18
|
+
const mockedShowModal = vi.mocked(showModal);
|
|
18
19
|
|
|
19
20
|
const formsResponse = [
|
|
20
21
|
{
|
|
@@ -38,11 +39,11 @@ const formsResponse = [
|
|
|
38
39
|
},
|
|
39
40
|
];
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
deleteForm:
|
|
42
|
+
vi.mock('@resources/forms.resource', () => ({
|
|
43
|
+
deleteForm: vi.fn(),
|
|
43
44
|
}));
|
|
44
45
|
|
|
45
|
-
global.window.URL.createObjectURL =
|
|
46
|
+
global.window.URL.createObjectURL = vi.fn();
|
|
46
47
|
|
|
47
48
|
describe('Dashboard', () => {
|
|
48
49
|
it('renders an empty state view if no forms are available', async () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import { showModal } from '@openmrs/esm-framework';
|
|
@@ -6,7 +7,7 @@ import { type FormSchema } from '@openmrs/esm-form-engine-lib';
|
|
|
6
7
|
import { type Schema } from '../../types';
|
|
7
8
|
import InteractiveBuilder from './interactive-builder.component';
|
|
8
9
|
|
|
9
|
-
const mockShowModal =
|
|
10
|
+
const mockShowModal = vi.mocked(showModal);
|
|
10
11
|
|
|
11
12
|
describe('InteractiveBuilder', () => {
|
|
12
13
|
it('renders the interactive builder', async () => {
|
|
@@ -104,7 +105,7 @@ describe('InteractiveBuilder', () => {
|
|
|
104
105
|
function renderInteractiveBuilder(props = {}) {
|
|
105
106
|
const defaultProps = {
|
|
106
107
|
isLoading: false,
|
|
107
|
-
onSchemaChange:
|
|
108
|
+
onSchemaChange: vi.fn(),
|
|
108
109
|
schema: {} as Schema,
|
|
109
110
|
validationResponse: [],
|
|
110
111
|
};
|
package/src/components/interactive-builder/modals/add-form-reference/add-form-reference.test.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
3
|
import { screen, waitFor } from '@testing-library/react';
|
|
3
4
|
import AddFormReferenceModal from './add-form-reference.modal';
|
|
4
5
|
import { Form, type Schema } from '@types';
|
|
@@ -12,9 +13,9 @@ type OpenmrsFetchResponse = Promise<
|
|
|
12
13
|
}>
|
|
13
14
|
>;
|
|
14
15
|
|
|
15
|
-
const mockedOpenmrsFetch =
|
|
16
|
-
const mockedCloseModal =
|
|
17
|
-
const mockedOnSchemaChange =
|
|
16
|
+
const mockedOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
17
|
+
const mockedCloseModal = vi.fn();
|
|
18
|
+
const mockedOnSchemaChange = vi.fn();
|
|
18
19
|
|
|
19
20
|
const formsResponse = [
|
|
20
21
|
{
|
|
@@ -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 { useConceptId } from '@hooks/useConceptId';
|
|
@@ -32,22 +33,22 @@ const concepts: Array<Concept> = [
|
|
|
32
33
|
mappings: [{ display: 'CIEL:1656', conceptMapType: { display: 'SAME-AS' } }],
|
|
33
34
|
},
|
|
34
35
|
];
|
|
35
|
-
const mockUseConceptLookup =
|
|
36
|
-
|
|
37
|
-
...
|
|
38
|
-
useConceptLookup:
|
|
36
|
+
const mockUseConceptLookup = vi.mocked(useConceptLookup);
|
|
37
|
+
vi.mock('@hooks/useConceptLookup', async () => ({
|
|
38
|
+
...((await vi.importActual('@hooks/useConceptLookup')) as object),
|
|
39
|
+
useConceptLookup: vi.fn(),
|
|
39
40
|
}));
|
|
40
|
-
const mockUseConceptId =
|
|
41
|
-
|
|
42
|
-
...
|
|
43
|
-
useConceptId:
|
|
41
|
+
const mockUseConceptId = vi.mocked(useConceptId);
|
|
42
|
+
vi.mock('@hooks/useConceptId', async () => ({
|
|
43
|
+
...((await vi.importActual('@hooks/useConceptId')) as object),
|
|
44
|
+
useConceptId: vi.fn(),
|
|
44
45
|
}));
|
|
45
|
-
const onSelectConcept =
|
|
46
|
-
const mockSetFormField =
|
|
47
|
-
const setConcept =
|
|
48
|
-
const setIsConceptValid =
|
|
49
|
-
|
|
50
|
-
...
|
|
46
|
+
const onSelectConcept = vi.fn();
|
|
47
|
+
const mockSetFormField = vi.fn();
|
|
48
|
+
const setConcept = vi.fn();
|
|
49
|
+
const setIsConceptValid = vi.fn();
|
|
50
|
+
vi.mock('../../../form-field-context', async () => ({
|
|
51
|
+
...((await vi.importActual('../../../form-field-context')) as object),
|
|
51
52
|
useFormField: () => ({ formField, setFormField: mockSetFormField, setConcept, setIsConceptValid }),
|
|
52
53
|
}));
|
|
53
54
|
|
package/src/components/interactive-builder/modals/question/question-form/question/question.test.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { render, screen, within } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import Question from './question.component';
|
|
@@ -15,7 +16,7 @@ const initialFormField: FormField = {
|
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const checkIfQuestionIdExists =
|
|
19
|
+
const checkIfQuestionIdExists = vi.fn(() => false);
|
|
19
20
|
|
|
20
21
|
const renderWithFormFieldProvider = (
|
|
21
22
|
component: React.ReactElement,
|
|
@@ -57,7 +58,7 @@ describe('Question Component', () => {
|
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
it('should validate duplicate question ids', () => {
|
|
60
|
-
const duplicateCheckFn =
|
|
61
|
+
const duplicateCheckFn = vi.fn().mockReturnValue(true);
|
|
61
62
|
|
|
62
63
|
renderWithFormFieldProvider(<Question checkIfQuestionIdExists={duplicateCheckFn} />);
|
|
63
64
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import ObsTypeQuestion from './obs-type-question.component';
|
|
@@ -8,9 +9,9 @@ import { useConceptLookup } from '@hooks/useConceptLookup';
|
|
|
8
9
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
9
10
|
import type { Concept } from '@types';
|
|
10
11
|
|
|
11
|
-
const mockSetFormField =
|
|
12
|
-
const setConcept =
|
|
13
|
-
const setIsConceptValid =
|
|
12
|
+
const mockSetFormField = vi.fn();
|
|
13
|
+
const setConcept = vi.fn();
|
|
14
|
+
const setIsConceptValid = vi.fn();
|
|
14
15
|
const formField: FormField = {
|
|
15
16
|
id: '1',
|
|
16
17
|
type: 'obs',
|
|
@@ -19,8 +20,8 @@ const formField: FormField = {
|
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
...
|
|
23
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
24
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
24
25
|
useFormField: () => ({ formField, setFormField: mockSetFormField, setConcept, setIsConceptValid }),
|
|
25
26
|
}));
|
|
26
27
|
|
|
@@ -43,16 +44,16 @@ const concepts: Array<Concept> = [
|
|
|
43
44
|
},
|
|
44
45
|
];
|
|
45
46
|
|
|
46
|
-
const mockUseConceptLookup =
|
|
47
|
-
|
|
48
|
-
...
|
|
49
|
-
useConceptLookup:
|
|
47
|
+
const mockUseConceptLookup = vi.mocked(useConceptLookup);
|
|
48
|
+
vi.mock('@hooks/useConceptLookup', async () => ({
|
|
49
|
+
...((await vi.importActual('@hooks/useConceptLookup')) as object),
|
|
50
|
+
useConceptLookup: vi.fn(),
|
|
50
51
|
}));
|
|
51
52
|
|
|
52
|
-
const mockUseConceptId =
|
|
53
|
-
|
|
54
|
-
...
|
|
55
|
-
useConceptId:
|
|
53
|
+
const mockUseConceptId = vi.mocked(useConceptId);
|
|
54
|
+
vi.mock('@hooks/useConceptId', async () => ({
|
|
55
|
+
...((await vi.importActual('@hooks/useConceptId')) as object),
|
|
56
|
+
useConceptId: vi.fn(),
|
|
56
57
|
}));
|
|
57
58
|
|
|
58
59
|
describe('ObsTypeQuestion', () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
@@ -7,7 +8,7 @@ import { FormFieldProvider } from '../../../../form-field-context';
|
|
|
7
8
|
import { usePatientIdentifierTypes } from '@hooks/usePatientIdentifierTypes';
|
|
8
9
|
import PatientIdentifierTypeQuestion from './patient-identifier-type-question.component';
|
|
9
10
|
|
|
10
|
-
const mockSetFormField =
|
|
11
|
+
const mockSetFormField = vi.fn();
|
|
11
12
|
const formField: FormField = {
|
|
12
13
|
id: '1',
|
|
13
14
|
type: 'patientIdentifier',
|
|
@@ -16,15 +17,15 @@ const formField: FormField = {
|
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
...
|
|
20
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
21
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
21
22
|
useFormField: () => ({ formField, setFormField: mockSetFormField }),
|
|
22
23
|
}));
|
|
23
24
|
|
|
24
|
-
const mockUsePatientIdentifierTypes =
|
|
25
|
-
|
|
26
|
-
...
|
|
27
|
-
usePatientIdentifierTypes:
|
|
25
|
+
const mockUsePatientIdentifierTypes = vi.mocked(usePatientIdentifierTypes);
|
|
26
|
+
vi.mock('@hooks/usePatientIdentifierTypes', async () => ({
|
|
27
|
+
...((await vi.importActual('@hooks/usePatientIdentifierTypes')) as object),
|
|
28
|
+
usePatientIdentifierTypes: vi.fn((value: string) => value),
|
|
28
29
|
}));
|
|
29
30
|
|
|
30
31
|
const patientIdentifierTypes: Array<PatientIdentifierType> = [
|
|
@@ -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 type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
@@ -7,7 +8,7 @@ import { useFormField } from '../../../../form-field-context';
|
|
|
7
8
|
import { usePersonAttributeTypes } from '@hooks/usePersonAttributeTypes';
|
|
8
9
|
import PersonAttributeTypeQuestion from './person-attribute-type-question.component';
|
|
9
10
|
|
|
10
|
-
const mockSetFormField =
|
|
11
|
+
const mockSetFormField = vi.fn();
|
|
11
12
|
const formField: FormField = {
|
|
12
13
|
id: '1',
|
|
13
14
|
type: 'personAttribute',
|
|
@@ -16,11 +17,11 @@ const formField: FormField = {
|
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
const mockUseFormField =
|
|
20
|
+
vi.mock('../../../../form-field-context');
|
|
21
|
+
const mockUseFormField = vi.mocked(useFormField);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
const mockUsePersonAttributeTypes =
|
|
23
|
+
vi.mock('@hooks/usePersonAttributeTypes');
|
|
24
|
+
const mockUsePersonAttributeTypes = vi.mocked(usePersonAttributeTypes);
|
|
24
25
|
|
|
25
26
|
const personAttributeTypes: Array<PersonAttributeType> = [
|
|
26
27
|
{ uuid: '1', display: 'Email', format: 'java.lang.String', concept: null },
|
|
@@ -33,7 +34,7 @@ describe('PersonAttributeTypeQuestion', () => {
|
|
|
33
34
|
formField,
|
|
34
35
|
setFormField: mockSetFormField,
|
|
35
36
|
concept: null,
|
|
36
|
-
setConcept:
|
|
37
|
+
setConcept: vi.fn(),
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import ProgramStateTypeQuestion from './program-state-type-question.component';
|
|
@@ -7,7 +8,7 @@ import { usePrograms, useProgramWorkStates } from '@hooks/useProgramStates';
|
|
|
7
8
|
import type { FormField, ProgramState } from '@openmrs/esm-form-engine-lib';
|
|
8
9
|
import type { Program } from '@types';
|
|
9
10
|
|
|
10
|
-
const mockSetFormField =
|
|
11
|
+
const mockSetFormField = vi.fn();
|
|
11
12
|
const formField: FormField = {
|
|
12
13
|
id: '1',
|
|
13
14
|
type: 'programState',
|
|
@@ -16,17 +17,17 @@ const formField: FormField = {
|
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
...
|
|
20
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
21
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
21
22
|
useFormField: () => ({ formField, setFormField: mockSetFormField }),
|
|
22
23
|
}));
|
|
23
24
|
|
|
24
|
-
const mockUsePrograms =
|
|
25
|
-
const mockUseProgramWorkflowStates =
|
|
26
|
-
|
|
27
|
-
...
|
|
28
|
-
usePrograms:
|
|
29
|
-
useProgramWorkStates:
|
|
25
|
+
const mockUsePrograms = vi.mocked(usePrograms);
|
|
26
|
+
const mockUseProgramWorkflowStates = vi.mocked(useProgramWorkStates);
|
|
27
|
+
vi.mock('@hooks/useProgramStates', async () => ({
|
|
28
|
+
...((await vi.importActual('@hooks/useProgramStates')) as object),
|
|
29
|
+
usePrograms: vi.fn(),
|
|
30
|
+
useProgramWorkStates: vi.fn(),
|
|
30
31
|
}));
|
|
31
32
|
|
|
32
33
|
const programOneWorkflowOneStates: Array<ProgramState> = [
|
|
@@ -79,7 +80,7 @@ describe('ProgramStateTypeQuestion', () => {
|
|
|
79
80
|
programStates: [],
|
|
80
81
|
programStatesLookupError: null,
|
|
81
82
|
isLoadingProgramStates: null,
|
|
82
|
-
mutateProgramStates:
|
|
83
|
+
mutateProgramStates: vi.fn(),
|
|
83
84
|
});
|
|
84
85
|
renderComponent();
|
|
85
86
|
|
|
@@ -92,7 +93,7 @@ describe('ProgramStateTypeQuestion', () => {
|
|
|
92
93
|
programStates: [],
|
|
93
94
|
programStatesLookupError: null,
|
|
94
95
|
isLoadingProgramStates: null,
|
|
95
|
-
mutateProgramStates:
|
|
96
|
+
mutateProgramStates: vi.fn(),
|
|
96
97
|
});
|
|
97
98
|
renderComponent();
|
|
98
99
|
|
|
@@ -106,7 +107,7 @@ describe('ProgramStateTypeQuestion', () => {
|
|
|
106
107
|
programStates: programOneWorkflowOneStates,
|
|
107
108
|
programStatesLookupError: null,
|
|
108
109
|
isLoadingProgramStates: null,
|
|
109
|
-
mutateProgramStates:
|
|
110
|
+
mutateProgramStates: vi.fn(),
|
|
110
111
|
});
|
|
111
112
|
const user = userEvent.setup();
|
|
112
113
|
renderComponent();
|
|
@@ -168,7 +169,7 @@ describe('ProgramStateTypeQuestion', () => {
|
|
|
168
169
|
programStates: programOneWorkflowOneStates,
|
|
169
170
|
programStatesLookupError: null,
|
|
170
171
|
isLoadingProgramStates: null,
|
|
171
|
-
mutateProgramStates:
|
|
172
|
+
mutateProgramStates: vi.fn(),
|
|
172
173
|
});
|
|
173
174
|
formField.questionOptions = {
|
|
174
175
|
rendering: 'select',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import TestOrderTypeQuestion from './test-order-type-question.component';
|
|
@@ -7,21 +8,21 @@ import { useConceptId } from '@hooks/useConceptId';
|
|
|
7
8
|
import { useConceptLookup } from '@hooks/useConceptLookup';
|
|
8
9
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
9
10
|
|
|
10
|
-
const mockUseConceptLookup =
|
|
11
|
-
|
|
12
|
-
...
|
|
13
|
-
useConceptLookup:
|
|
11
|
+
const mockUseConceptLookup = vi.mocked(useConceptLookup);
|
|
12
|
+
vi.mock('@hooks/useConceptLookup', async () => ({
|
|
13
|
+
...((await vi.importActual('@hooks/useConceptLookup')) as object),
|
|
14
|
+
useConceptLookup: vi.fn(),
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
|
-
const mockUseConceptId =
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
useConceptId:
|
|
17
|
+
const mockUseConceptId = vi.mocked(useConceptId);
|
|
18
|
+
vi.mock('@hooks/useConceptId', async () => ({
|
|
19
|
+
...((await vi.importActual('@hooks/useConceptId')) as object),
|
|
20
|
+
useConceptId: vi.fn(),
|
|
20
21
|
}));
|
|
21
22
|
|
|
22
|
-
const mockSetFormField =
|
|
23
|
-
const mockSetConcept =
|
|
24
|
-
const mockSetIsConceptValid =
|
|
23
|
+
const mockSetFormField = vi.fn();
|
|
24
|
+
const mockSetConcept = vi.fn();
|
|
25
|
+
const mockSetIsConceptValid = vi.fn();
|
|
25
26
|
const formField: FormField = {
|
|
26
27
|
id: 'test-order-1',
|
|
27
28
|
type: 'testOrder',
|
|
@@ -32,8 +33,8 @@ const formField: FormField = {
|
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
...
|
|
36
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
37
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
37
38
|
useFormField: () => ({
|
|
38
39
|
formField,
|
|
39
40
|
setFormField: mockSetFormField,
|
|
@@ -44,7 +45,7 @@ jest.mock('../../../../form-field-context', () => ({
|
|
|
44
45
|
|
|
45
46
|
describe('TestOrderTypeQuestion', () => {
|
|
46
47
|
beforeEach(() => {
|
|
47
|
-
|
|
48
|
+
vi.clearAllMocks();
|
|
48
49
|
mockUseConceptLookup.mockReturnValue({ concepts: [], conceptLookupError: null, isLoadingConcepts: false });
|
|
49
50
|
mockUseConceptId.mockReturnValue({
|
|
50
51
|
concept: null,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { FormFieldProvider } from '../../form-field-context';
|
|
4
5
|
import QuestionTypeComponent from './question-type.component';
|
|
5
6
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
6
7
|
|
|
7
|
-
const mockSetFormField =
|
|
8
|
+
const mockSetFormField = vi.fn();
|
|
8
9
|
const formField: FormField = {
|
|
9
10
|
type: 'obs',
|
|
10
11
|
questionOptions: { rendering: 'text' },
|
|
11
12
|
id: '1',
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
...
|
|
15
|
+
vi.mock('../../form-field-context', async () => ({
|
|
16
|
+
...((await vi.importActual('../../form-field-context')) as object),
|
|
16
17
|
useFormField: () => ({ formField, setFormField: mockSetFormField }),
|
|
17
18
|
}));
|
|
18
19
|
|
|
@@ -53,7 +54,7 @@ describe('RenderingType Component', () => {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
it('prints error to console if component cannot be found for type', () => {
|
|
56
|
-
const consoleErrorSpy =
|
|
57
|
+
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
57
58
|
formField.type = 'control';
|
|
58
59
|
renderQuestionTypeComponent();
|
|
59
60
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import Date from './date.component';
|
|
5
6
|
import { FormFieldProvider } from '../../../../form-field-context';
|
|
6
7
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
7
8
|
|
|
8
|
-
const mockSetFormField =
|
|
9
|
+
const mockSetFormField = vi.fn();
|
|
9
10
|
const formField: FormField = {
|
|
10
11
|
datePickerFormat: 'both',
|
|
11
12
|
type: 'obs',
|
|
12
13
|
questionOptions: { rendering: 'date' },
|
|
13
14
|
id: '1',
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
...
|
|
16
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
17
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
17
18
|
useFormField: () => ({ formField, setFormField: mockSetFormField }),
|
|
18
19
|
}));
|
|
19
20
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect } from 'vitest';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import Number from './number.component';
|
|
5
6
|
import { FormFieldProvider } from '../../../../form-field-context';
|
|
6
7
|
import type { FormField } from '@openmrs/esm-form-engine-lib';
|
|
7
8
|
|
|
8
|
-
const mockSetFormField =
|
|
9
|
+
const mockSetFormField = vi.fn();
|
|
9
10
|
const formField: FormField = {
|
|
10
11
|
type: 'obs',
|
|
11
12
|
questionOptions: { rendering: 'number', min: '1', max: '10' },
|
|
12
13
|
id: '1',
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
...
|
|
16
|
+
vi.mock('../../../../form-field-context', async () => ({
|
|
17
|
+
...((await vi.importActual('../../../../form-field-context')) as object),
|
|
17
18
|
useFormField: () => ({ formField, setFormField: mockSetFormField }),
|
|
18
19
|
}));
|
|
19
20
|
|