@openmrs/esm-patient-registration-app 5.0.0 → 5.0.1-pre.1828

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.
@@ -14,7 +14,7 @@ assets by path *.js 1.25 MiB
14
14
  + 17 assets
15
15
  assets by path *.json 14.3 KiB
16
16
  asset openmrs-esm-patient-registration-app.js.buildmanifest.json 13.3 KiB [emitted]
17
- asset routes.json 940 bytes [emitted] [from: src/routes.json] [copied]
17
+ asset routes.json 949 bytes [emitted] [from: src/routes.json] [copied]
18
18
  orphan modules 3.93 MiB [orphan] 634 modules
19
19
  runtime modules 38.7 KiB 28 modules
20
20
  built modules 4.43 MiB (javascript) 210 bytes (share-init) 210 bytes (consume-shared) [built]
@@ -35,4 +35,4 @@ This can impact web performance.
35
35
  Assets:
36
36
  130.js (497 KiB)
37
37
 
38
- webpack 5.86.0 compiled with 1 warning in 191213 ms
38
+ webpack 5.86.0 compiled with 1 warning in 146095 ms
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"cancelPatientEditModal","name":"cancel-patient-edit-modal","online":true,"offline":true},{"component":"patientPhoto","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true}],"version":"5.0.0"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"cancelPatientEditModal","name":"cancel-patient-edit-modal","online":true,"offline":true},{"component":"patientPhoto","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true}],"version":"5.0.1-pre.1828"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-patient-registration-app",
3
- "version": "5.0.0",
3
+ "version": "5.0.1-pre.1828",
4
4
  "description": "Patient registration microfrontend for the OpenMRS SPA",
5
5
  "browser": "dist/openmrs-esm-patient-registration-app.js",
6
6
  "main": "src/index.ts",
@@ -52,5 +52,5 @@
52
52
  "devDependencies": {
53
53
  "webpack": "^5.74.0"
54
54
  },
55
- "gitHead": "2234a566ef6ae492e872a5e0a063f03e349d68ff"
55
+ "gitHead": "20270ffacebd6a89447dac543ba64fecb1d2e265"
56
56
  }
@@ -0,0 +1,103 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { useConceptAnswers } from '../field.resource';
4
+ import { CodedPersonAttributeField } from './coded-person-attribute-field.component';
5
+ import { Form, Formik } from 'formik';
6
+
7
+ jest.mock('formik', () => ({
8
+ ...jest.requireActual('formik'),
9
+ }));
10
+
11
+ jest.mock('../field.resource'); // Mock the useConceptAnswers hook
12
+
13
+ const mockedUseConceptAnswers = useConceptAnswers as jest.Mock;
14
+
15
+ describe('CodedPersonAttributeField', () => {
16
+ const conceptAnswers = [
17
+ { uuid: '1', display: 'Option 1' },
18
+ { uuid: '2', display: 'Option 2' },
19
+ ];
20
+ const personAttributeType = {
21
+ format: 'org.openmrs.Concept',
22
+ display: 'Referred by',
23
+ uuid: '4dd56a75-14ab-4148-8700-1f4f704dc5b0',
24
+ };
25
+ const answerConceptSetUuid = '6682d17f-0777-45e4-a39b-93f77eb3531c';
26
+
27
+ beforeEach(() => {
28
+ jest.clearAllMocks();
29
+ mockedUseConceptAnswers.mockReturnValue({
30
+ data: conceptAnswers,
31
+ isLoading: false,
32
+ });
33
+ });
34
+
35
+ it('renders the Select component when conceptAnswers are available', () => {
36
+ render(
37
+ <Formik initialValues={{}} onSubmit={() => {}}>
38
+ <Form>
39
+ <CodedPersonAttributeField
40
+ id="attributeId"
41
+ personAttributeType={personAttributeType}
42
+ answerConceptSetUuid={answerConceptSetUuid}
43
+ label={personAttributeType.display}
44
+ />
45
+ </Form>
46
+ </Formik>,
47
+ );
48
+
49
+ expect(screen.getByLabelText(/Referred by/i)).toBeInTheDocument();
50
+ expect(screen.getByText(/Option 1/i)).toBeInTheDocument();
51
+ expect(screen.getByText(/Option 2/i)).toBeInTheDocument();
52
+ });
53
+
54
+ it('renders the Input component when conceptAnswers are not available', () => {
55
+ mockedUseConceptAnswers.mockReturnValueOnce({
56
+ data: null,
57
+ isLoading: false,
58
+ });
59
+
60
+ render(
61
+ <Formik initialValues={{}} onSubmit={() => {}}>
62
+ <Form>
63
+ <CodedPersonAttributeField
64
+ id="attributeId"
65
+ personAttributeType={personAttributeType}
66
+ answerConceptSetUuid={answerConceptSetUuid}
67
+ label={personAttributeType.display}
68
+ />
69
+ </Form>
70
+ </Formik>,
71
+ );
72
+
73
+ expect(screen.getByLabelText(/Referred by/i)).toBeInTheDocument();
74
+ expect(screen.queryByText(/Option 1/i)).not.toBeInTheDocument();
75
+ expect(screen.queryByText(/Option 2/i)).not.toBeInTheDocument();
76
+ expect(screen.getByRole('textbox')).toBeInTheDocument();
77
+ });
78
+
79
+ it('renders the Input component when conceptAnswers are still loading', () => {
80
+ mockedUseConceptAnswers.mockReturnValueOnce({
81
+ data: null,
82
+ isLoading: true,
83
+ });
84
+
85
+ render(
86
+ <Formik initialValues={{}} onSubmit={() => {}}>
87
+ <Form>
88
+ <CodedPersonAttributeField
89
+ id="attributeId"
90
+ personAttributeType={personAttributeType}
91
+ answerConceptSetUuid={answerConceptSetUuid}
92
+ label={personAttributeType.display}
93
+ />
94
+ </Form>
95
+ </Formik>,
96
+ );
97
+
98
+ expect(screen.getByLabelText(/Referred by/i)).toBeInTheDocument();
99
+ expect(screen.queryByText(/Option 1/i)).not.toBeInTheDocument();
100
+ expect(screen.queryByText(/Option 2/i)).not.toBeInTheDocument();
101
+ expect(screen.getByRole('textbox')).toBeInTheDocument();
102
+ });
103
+ });