Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore) O3-3922: Enable form-engine component test suite #383

Merged
merged 14 commits into from
Sep 12, 2024
Merged
5 changes: 2 additions & 3 deletions __mocks__/forms/rfe-forms/conditional-required-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"concept": "dc1942b2-5e50-4adc-949d-ad6c905f054e"
},
"validators": [],
"hide": {
}
"hide": {}
},
{
"label": "If Unscheduled, actual text area scheduled date",
Expand Down Expand Up @@ -278,4 +277,4 @@
"version": "1.0",
"description": "des",
"encounterType": "181820aa-88c9-479b-9077-af92f5364329"
}
}
5 changes: 1 addition & 4 deletions __mocks__/forms/rfe-forms/labour_and_delivery_test_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@
"readonly": "true",
"questionOptions": {
"concept": "164803AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"rendering": "text",
"calculate": {
"calculateExpression": "!isEmpty('MotherPtracker_id') ? myValue = customGenerateInfantPTrackerId(node.value.id, MotherPtracker_id) : ''"
}
"rendering": "text"
},
"behaviours": [
{
Expand Down
198 changes: 198 additions & 0 deletions __mocks__/forms/rfe-forms/radio-button-form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"name": "A Radio Button Test",
"pages": [
{
"label": "Page 1",
"sections": [
{
"label": "1",
"isExpanded": "true",
"questions": [
{
"label": "Visit type",
"type": "obs",
"required": "false",
"id": "visitType",
"questionOptions": {
"rendering": "radio",
"concept": "164181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"conceptMappings": [
{
"relationship": "SAME-AS",
"type": "CIEL",
"value": "164181"
}
],
"answers": [
{
"concept": "164180AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"label": "New visit"
},
{
"concept": "160530AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"label": "Return visit type"
},
{
"concept": "5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"label": "Other"
}
]
},
"validators": [
{
"type": "form_field"
},
{
"type": "default_value"
}
],
"meta": {
"submission": null,
"concept": {
"uuid": "164181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Visit type",
"conceptClass": {
"uuid": "8d491e50-c2cc-11de-8d13-0010c6dffd0f",
"display": "Question"
},
"answers": [
{
"uuid": "164180AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "New visit"
},
{
"uuid": "160530AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Return visit type"
},
{
"uuid": "5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Other"
}
],
"conceptMappings": [
{
"conceptReferenceTerm": {
"conceptSource": {
"name": "CIEL"
},
"code": "164181"
}
}
]
}
},
"isHidden": false,
"isRequired": false,
"isDisabled": false
},
{
"label": "Visit punctuality",
"type": "obs",
"required": false,
"id": "visitPunctuality",
"questionOptions": {
"rendering": "radio",
"concept": "d81d4698-e78c-420d-aac5-cb1f606fb32e",
"answers": [
{
"concept": "5c3ce9c9-75bd-4730-8878-08c03ec02e9d",
"label": "Early"
},
{
"concept": "90af4b72-442a-4fcc-84c2-2bb1c0361737",
"label": "Late"
},
{
"concept": "66cdc0a1-aa19-4676-af51-80f66d78d9eb",
"label": "On time"
}
]
},
"validators": [
{
"type": "form_field"
},
{
"type": "default_value"
}
],
"meta": {
"submission": null,
"concept": {
"uuid": "d81d4698-e78c-420d-aac5-cb1f606fb32e",
"display": "Visit Punctuality",
"conceptClass": {
"uuid": "8d491e50-c2cc-11de-8d13-0010c6dffd0f",
"display": "Question"
},
"answers": [
{
"uuid": "66cdc0a1-aa19-4676-af51-80f66d78d9eb",
"display": "On time"
},
{
"uuid": "90af4b72-442a-4fcc-84c2-2bb1c0361737",
"display": "Late"
},
{
"uuid": "5c3ce9c9-75bd-4730-8878-08c03ec02e9d",
"display": "Early"
}
],
"conceptMappings": []
}
},
"isHidden": false,
"isRequired": false,
"isDisabled": false
}
],
"isHidden": false
}
],
"isHidden": false
}
],
"processor": "EncounterFormProcessor",
"encounterType": "0e8230ce-bd1d-43f5-a863-cf44344fa4b0",
"referencedForms": [],
"uuid": "fd067f44-99fd-4b07-b238-cea7b278c2b2",
"description": "A Radio Button Test",
"version": "1.0",
"translations": {},
"conceptReferences": {
"164181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": {
"uuid": "164181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Visit type"
},
"164180AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": {
"uuid": "164180AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "New visit"
},
"160530AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": {
"uuid": "160530AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Return visit type"
},
"5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": {
"uuid": "5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"display": "Other"
},
"d81d4698-e78c-420d-aac5-cb1f606fb32e": {
"uuid": "d81d4698-e78c-420d-aac5-cb1f606fb32e",
"display": "Visit Punctuality"
},
"5c3ce9c9-75bd-4730-8878-08c03ec02e9d": {
"uuid": "5c3ce9c9-75bd-4730-8878-08c03ec02e9d",
"display": "Early"
},
"90af4b72-442a-4fcc-84c2-2bb1c0361737": {
"uuid": "90af4b72-442a-4fcc-84c2-2bb1c0361737",
"display": "Late"
},
"66cdc0a1-aa19-4676-af51-80f66d78d9eb": {
"uuid": "66cdc0a1-aa19-4676-af51-80f66d78d9eb",
"display": "On time"
}
},
"encounter": ""
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
'^dexie$': require.resolve('dexie'),
'\\.(s?css)$': 'identity-obj-proxy',
'@openmrs/esm-framework': '@openmrs/esm-framework/mock',
'react-i18next': '<rootDir>/__mocks__/react-i18next.js',
'^react-i18next$': '<rootDir>/__mocks__/react-i18next.js',
'lodash-es': 'lodash',
'react-markdown': '<rootDir>/__mocks__/react-markdown.tsx',
'^uuid$': '<rootDir>/node_modules/uuid/dist/index.js',
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/radio/radio.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Radio: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
legendText={<FieldLabel field={field} />}
className={styles.boldedLegend}
disabled={field.isDisabled}
invalid={errors.length > 0}>
invalid={errors?.length > 0}>
<RadioButtonGroup
name={field.id}
valueSelected={value}
Expand Down
Loading
Loading