@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.1
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/components/CheckYourAnswers/Answer.js +18 -7
- package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
- package/dist/components/CollectionPage/CollectionPage.js +15 -10
- package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
- package/dist/components/FormComponent/Collection.js +91 -48
- package/dist/components/FormComponent/Collection.scss +2 -1
- package/dist/components/FormComponent/Collection.test.js +807 -0
- package/dist/components/FormComponent/Container.js +35 -16
- package/dist/components/FormComponent/Container.test.js +370 -0
- package/dist/components/FormComponent/FormComponent.js +45 -14
- package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
- package/dist/components/FormComponent/FormComponent.test.js +226 -0
- package/dist/components/FormComponent/helpers/addLabel.js +5 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
- package/dist/components/FormComponent/helpers/index.js +8 -1
- package/dist/components/FormPage/FormPage.js +69 -30
- package/dist/components/FormPage/FormPage.stories.mdx +155 -0
- package/dist/components/FormPage/FormPage.test.js +330 -0
- package/dist/components/FormRenderer/FormRenderer.js +142 -228
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
- package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
- package/dist/components/FormRenderer/handlers/index.js +1 -2
- package/dist/components/FormRenderer/handlers/navigate.js +3 -1
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
- package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
- package/dist/components/FormRenderer/helpers/index.js +1 -2
- package/dist/components/FormRenderer/onCYAAction.js +108 -0
- package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
- package/dist/components/FormRenderer/onPageAction.js +145 -0
- package/dist/components/FormRenderer/onPageAction.test.js +678 -0
- package/dist/components/FormRenderer/onTaskAction.js +48 -0
- package/dist/components/FormRenderer/onTaskAction.test.js +251 -0
- package/dist/components/PageActions/ActionButton.js +0 -3
- package/dist/components/PageActions/ActionButton.test.js +93 -0
- package/dist/components/PageActions/PageActions.js +2 -2
- package/dist/components/PageActions/PageActions.stories.mdx +74 -0
- package/dist/components/PageActions/PageActions.test.js +132 -0
- package/dist/components/SummaryList/GroupAction.js +2 -2
- package/dist/components/SummaryList/GroupAction.test.js +80 -0
- package/dist/components/SummaryList/RowAction.js +2 -2
- package/dist/components/SummaryList/RowAction.test.js +80 -0
- package/dist/components/SummaryList/SummaryList.js +29 -12
- package/dist/components/SummaryList/SummaryList.scss +19 -0
- package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
- package/dist/components/SummaryList/SummaryList.test.js +400 -0
- package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
- package/dist/components/SummaryList/SummaryListRow.js +5 -2
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
- package/dist/components/TaskList/Task.js +3 -3
- package/dist/components/TaskList/Task.test.js +167 -0
- package/dist/components/TaskList/TaskList.js +76 -23
- package/dist/components/TaskList/TaskList.stories.mdx +164 -0
- package/dist/components/TaskList/TaskList.test.js +389 -0
- package/dist/components/TaskList/TaskState.js +2 -2
- package/dist/components/TaskList/TaskState.test.js +86 -0
- package/dist/components/index.js +14 -0
- package/dist/context/HooksContext/HooksContext.js +72 -8
- package/dist/context/HooksContext/HooksContext.test.js +44 -0
- package/dist/context/ValidationContext/ValidationContext.js +38 -28
- package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
- package/dist/hooks/useAxios.js +10 -12
- package/dist/hooks/useGetRequest.js +48 -49
- package/dist/hooks/useRefData.js +7 -4
- package/dist/index.js +34 -1
- package/dist/json/addressDetails.json +149 -0
- package/dist/json/areYouACivilServant.json +7 -0
- package/dist/json/firstForm.json +94 -0
- package/dist/json/grade.json +108 -0
- package/dist/json/group.data.json +21 -0
- package/dist/json/group.json +402 -0
- package/dist/json/groupOfRow.json +137 -0
- package/dist/json/groupOfRowData.json +15 -0
- package/dist/json/port.json +346 -0
- package/dist/json/saveAndContinue.json +98 -0
- package/dist/json/sublocation.json +859 -0
- package/dist/json/taskList.json +265 -0
- package/dist/json/team.json +17351 -0
- package/dist/json/terminal.json +81 -0
- package/dist/json/userProfile.data.json +21 -0
- package/dist/json/userProfile.json +276 -0
- package/dist/models/ComponentTypes.js +8 -0
- package/dist/models/PageAction.js +4 -1
- package/dist/models/TaskStates.js +10 -2
- package/dist/models/index.js +16 -1
- package/dist/setupTests.js +46 -0
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
- package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
- package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
- package/dist/utils/Component/addShowWhen.js +44 -0
- package/dist/utils/Component/addShowWhen.test.js +216 -0
- package/dist/utils/Component/applyToComponentTree.js +71 -0
- package/dist/utils/Component/applyToComponentTree.test.js +127 -0
- package/dist/utils/Component/cleanAttributes.js +8 -2
- package/dist/utils/Component/cleanAttributes.test.js +68 -0
- package/dist/utils/Component/elevateNestedComponents.js +4 -1
- package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
- package/dist/utils/Component/getComponent.js +80 -11
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
- package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
- package/dist/utils/Component/getDefaultValue.js +4 -1
- package/dist/utils/Component/getDefaultValue.test.js +50 -0
- package/dist/utils/Component/index.js +2 -0
- package/dist/utils/Component/isEditable.js +2 -2
- package/dist/utils/Component/isEditable.test.js +43 -0
- package/dist/utils/Component/optionIsSelected.js +22 -0
- package/dist/utils/Component/optionIsSelected.test.js +42 -0
- package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
- package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
- package/dist/utils/Component/showComponent.test.js +156 -0
- package/dist/utils/Component/wrapInFormGroup.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
- package/dist/utils/Condition/meetsCondition.js +74 -4
- package/dist/utils/Condition/meetsCondition.test.js +763 -0
- package/dist/utils/Condition/meetsOneCondition.js +1 -1
- package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
- package/dist/utils/Condition/setupConditions.js +6 -3
- package/dist/utils/Condition/setupConditions.test.js +33 -0
- package/dist/utils/Container/getEditableComponents.test.js +135 -0
- package/dist/utils/Container/setupNesting.js +21 -2
- package/dist/utils/Container/setupNesting.test.js +145 -0
- package/dist/utils/Container/showContainer.test.js +178 -0
- package/dist/utils/Data/applyFormula.js +20 -11
- package/dist/utils/Data/applyFormula.test.js +263 -0
- package/dist/utils/Data/getAutocompleteSource.js +6 -2
- package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
- package/dist/utils/Data/getDataPath.test.js +48 -0
- package/dist/utils/Data/getOptions.js +17 -3
- package/dist/utils/Data/getOptions.test.js +140 -0
- package/dist/utils/Data/getSourceData.js +2 -2
- package/dist/utils/Data/getSourceData.test.js +153 -0
- package/dist/utils/Data/refDataToOptions.js +4 -1
- package/dist/utils/Data/refDataToOptions.test.js +196 -0
- package/dist/utils/Data/setDataItem.test.js +110 -0
- package/dist/utils/Data/setupFormData.js +39 -16
- package/dist/utils/Data/setupFormData.test.js +410 -0
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
- package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
- package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
- package/dist/utils/FormPage/getFormPage.js +5 -2
- package/dist/utils/FormPage/getFormPage.test.js +206 -0
- package/dist/utils/FormPage/getFormPages.js +4 -1
- package/dist/utils/FormPage/getFormPages.test.js +97 -0
- package/dist/utils/FormPage/getPageActions.js +8 -4
- package/dist/utils/FormPage/getPageActions.test.js +114 -0
- package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
- package/dist/utils/FormPage/index.js +2 -0
- package/dist/utils/FormPage/showFormPage.js +2 -2
- package/dist/utils/FormPage/showFormPage.test.js +180 -0
- package/dist/utils/FormPage/showFormPageCYA.js +1 -0
- package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
- package/dist/utils/FormPage/useComponent.js +29 -14
- package/dist/utils/FormPage/useComponent.test.js +167 -0
- package/dist/utils/Format/formatData.test.js +45 -0
- package/dist/utils/Format/formatDataForComponent.js +2 -1
- package/dist/utils/Format/formatDataForComponent.test.js +142 -0
- package/dist/utils/Format/formatDataForForm.js +4 -1
- package/dist/utils/Format/formatDataForForm.test.js +81 -0
- package/dist/utils/Format/formatDataForPage.test.js +99 -0
- package/dist/utils/Hub/getFormHub.test.js +105 -0
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
- package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
- package/dist/utils/Operate/getFirstOf.js +31 -0
- package/dist/utils/Operate/getFirstOf.test.js +86 -0
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
- package/dist/utils/Operate/persistValueInFormData.js +2 -1
- package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
- package/dist/utils/Operate/runPageOperations.js +3 -1
- package/dist/utils/Operate/runPageOperations.test.js +105 -0
- package/dist/utils/Operate/setValueInFormData.test.js +44 -0
- package/dist/utils/Operate/shouldRun.js +16 -13
- package/dist/utils/Operate/shouldRun.test.js +66 -0
- package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
- package/dist/utils/Validate/additional/index.js +13 -4
- package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
- package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
- package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
- package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
- package/dist/utils/Validate/additional/utils.js +18 -18
- package/dist/utils/Validate/index.js +6 -0
- package/dist/utils/Validate/validateCollection.js +20 -5
- package/dist/utils/Validate/validateCollection.test.js +125 -0
- package/dist/utils/Validate/validateComponent.js +36 -20
- package/dist/utils/Validate/validateComponent.test.js +365 -0
- package/dist/utils/Validate/validateContainer.js +9 -3
- package/dist/utils/Validate/validateContainer.test.js +75 -0
- package/dist/utils/Validate/validateDate.js +4 -3
- package/dist/utils/Validate/validateDate.test.js +114 -0
- package/dist/utils/Validate/validateEmail.js +14 -1
- package/dist/utils/Validate/validateEmail.test.js +74 -0
- package/dist/utils/Validate/validateMultifile.js +32 -0
- package/dist/utils/Validate/validateMultifile.test.js +47 -0
- package/dist/utils/Validate/validatePage.js +12 -6
- package/dist/utils/Validate/validatePage.test.js +472 -0
- package/dist/utils/Validate/validateRegex.js +2 -5
- package/dist/utils/Validate/validateRegex.test.js +42 -0
- package/dist/utils/Validate/validateRequired.js +2 -4
- package/dist/utils/Validate/validateRequired.test.js +63 -0
- package/dist/utils/Validate/validateTextArea.js +37 -0
- package/dist/utils/Validate/validateTextArea.test.js +42 -0
- package/dist/utils/Validate/validateTime.js +2 -2
- package/dist/utils/Validate/validateTime.test.js +59 -0
- package/dist/utils/index.js +4 -1
- package/package.json +35 -50
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": 1,
|
|
5
|
+
"name": "Terminal 1",
|
|
6
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
7
|
+
"validto": null,
|
|
8
|
+
"updatedby": null
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": 2,
|
|
12
|
+
"name": "Terminal 2",
|
|
13
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
14
|
+
"validto": null,
|
|
15
|
+
"updatedby": null
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": 3,
|
|
19
|
+
"name": "Terminal 3",
|
|
20
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
21
|
+
"validto": null,
|
|
22
|
+
"updatedby": null
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": 4,
|
|
26
|
+
"name": "Terminal 4",
|
|
27
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
28
|
+
"validto": null,
|
|
29
|
+
"updatedby": null
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": 5,
|
|
33
|
+
"name": "Terminal 5",
|
|
34
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
35
|
+
"validto": null,
|
|
36
|
+
"updatedby": null
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": 6,
|
|
40
|
+
"name": "North Terminal",
|
|
41
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
42
|
+
"validto": null,
|
|
43
|
+
"updatedby": null
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": 7,
|
|
47
|
+
"name": "South Terminal",
|
|
48
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
49
|
+
"validto": null,
|
|
50
|
+
"updatedby": null
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": 8,
|
|
54
|
+
"name": "Eastern Docks",
|
|
55
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
56
|
+
"validto": null,
|
|
57
|
+
"updatedby": null
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": 9,
|
|
61
|
+
"name": "Western Docks",
|
|
62
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
63
|
+
"validto": null,
|
|
64
|
+
"updatedby": null
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": 10,
|
|
68
|
+
"name": "Tourist",
|
|
69
|
+
"validfrom": "2021-05-07T00:01:00.000Z",
|
|
70
|
+
"validto": null,
|
|
71
|
+
"updatedby": "Ben Milnes"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": 11,
|
|
75
|
+
"name": "Freight",
|
|
76
|
+
"validfrom": "2021-05-07T00:01:00.000Z",
|
|
77
|
+
"validto": null,
|
|
78
|
+
"updatedby": "Ben Milnes"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"urls": {
|
|
3
|
+
"refData": "/ref-data"
|
|
4
|
+
},
|
|
5
|
+
"currentUser": {
|
|
6
|
+
"givenName": "John",
|
|
7
|
+
"familyName": "Smith"
|
|
8
|
+
},
|
|
9
|
+
"areYouACivilServant": "yes",
|
|
10
|
+
"userDetails": {
|
|
11
|
+
"linemanagerEmail": "line.manager@digital.homeoffice.gov.uk",
|
|
12
|
+
"delegateEmails": "del.egate@digital.homeoffice.gov.uk"
|
|
13
|
+
},
|
|
14
|
+
"addressDetails": {
|
|
15
|
+
"firstLineOfTheAddress": "10 Downing Street",
|
|
16
|
+
"city": "London",
|
|
17
|
+
"town": "City of Westminster",
|
|
18
|
+
"postCode": "SW1A 2AA"
|
|
19
|
+
},
|
|
20
|
+
"businessKey": "123456789"
|
|
21
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "userProfile",
|
|
3
|
+
"version": "1",
|
|
4
|
+
"name": "userProfile",
|
|
5
|
+
"title": "Your profile",
|
|
6
|
+
"type": "hub-and-spoke",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"id": "firstName",
|
|
10
|
+
"fieldId": "firstName",
|
|
11
|
+
"label": "First name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"readonly": true,
|
|
14
|
+
"source": {
|
|
15
|
+
"field": "currentUser.givenName"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "surname",
|
|
20
|
+
"fieldId": "surname",
|
|
21
|
+
"label": "Last name",
|
|
22
|
+
"type": "text",
|
|
23
|
+
"readonly": true,
|
|
24
|
+
"source": {
|
|
25
|
+
"field": "currentUser.familyName"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "areYouACivilServant",
|
|
30
|
+
"fieldId": "areYouACivilServant",
|
|
31
|
+
"label": "Are you a civil servant?",
|
|
32
|
+
"type": "radios",
|
|
33
|
+
"required": true,
|
|
34
|
+
"data": {
|
|
35
|
+
"url": "${urls.refData}/areYouACivilServant"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "staffGradeId",
|
|
40
|
+
"fieldId": "staffGradeId",
|
|
41
|
+
"label": "Grade",
|
|
42
|
+
"hint": "We use this to assign you tasks",
|
|
43
|
+
"type": "radios",
|
|
44
|
+
"required": true,
|
|
45
|
+
"data": {
|
|
46
|
+
"url": "${urls.refData}/grade"
|
|
47
|
+
},
|
|
48
|
+
"source": {
|
|
49
|
+
"field": "userDetails.gradeid"
|
|
50
|
+
},
|
|
51
|
+
"show_when": {
|
|
52
|
+
"field": "areYouACivilServant",
|
|
53
|
+
"op": "eq",
|
|
54
|
+
"value": "yes"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "team",
|
|
59
|
+
"fieldId": "team",
|
|
60
|
+
"label": "Team",
|
|
61
|
+
"hint": "We use this to assign you tasks",
|
|
62
|
+
"type": "autocomplete",
|
|
63
|
+
"required": true,
|
|
64
|
+
"item": { "value": "id", "label": "name" },
|
|
65
|
+
"data": {
|
|
66
|
+
"url": "${urls.refData}/team"
|
|
67
|
+
},
|
|
68
|
+
"displayMenu": "inline",
|
|
69
|
+
"source": {
|
|
70
|
+
"field": "userDetails.defaultteam"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "linemanagerEmail",
|
|
75
|
+
"fieldId": "linemanagerEmail",
|
|
76
|
+
"label": "Line manager email",
|
|
77
|
+
"hint": "Must be a homeoffice.gov.uk or digital.homeoffice.gov.uk address",
|
|
78
|
+
"type": "email",
|
|
79
|
+
"format": {
|
|
80
|
+
"type": "lowercase",
|
|
81
|
+
"on": "submit"
|
|
82
|
+
},
|
|
83
|
+
"required": true,
|
|
84
|
+
"source": {
|
|
85
|
+
"field": "userDetails.linemanagerEmail"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "delegateEmails",
|
|
90
|
+
"fieldId": "delegateEmails",
|
|
91
|
+
"label": "Delegate email",
|
|
92
|
+
"hint": "Must be a homeoffice.gov.uk or digital.homeoffice.gov.uk address",
|
|
93
|
+
"type": "email",
|
|
94
|
+
"format": {
|
|
95
|
+
"type": "lowercase",
|
|
96
|
+
"on": "submit"
|
|
97
|
+
},
|
|
98
|
+
"required": true,
|
|
99
|
+
"source": {
|
|
100
|
+
"field": "userDetails.delegateEmails"
|
|
101
|
+
},
|
|
102
|
+
"show_when": [
|
|
103
|
+
{
|
|
104
|
+
"field": "areYouACivilServant",
|
|
105
|
+
"op": "eq",
|
|
106
|
+
"value": "yes"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"field": "staffGradeId",
|
|
110
|
+
"op": "in",
|
|
111
|
+
"values": [
|
|
112
|
+
"373979c1-2360-46be-b712-0409ac068059",
|
|
113
|
+
"36c80dfe-0aae-455b-9445-2e1c09dcafdc",
|
|
114
|
+
"1b041cda-b151-4769-b76a-d42d67b0b960",
|
|
115
|
+
"172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
|
|
116
|
+
"39e18b45-0358-4a45-83ec-5a70b74641e8"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"pages": [
|
|
123
|
+
{
|
|
124
|
+
"id": "names",
|
|
125
|
+
"name": "names",
|
|
126
|
+
"components": [
|
|
127
|
+
{ "use": "firstName" },
|
|
128
|
+
{ "use": "surname" }
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "civil-servant-status",
|
|
133
|
+
"name": "civil-servant-status",
|
|
134
|
+
"title": "Are you a civil servant?",
|
|
135
|
+
"components": [
|
|
136
|
+
{
|
|
137
|
+
"use": "areYouACivilServant",
|
|
138
|
+
"label": ""
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"actions": ["submit", "cancel"],
|
|
142
|
+
"cya_link": {
|
|
143
|
+
"page": "civil-servant-status",
|
|
144
|
+
"aria_suffix": "civil servant status"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "grade",
|
|
149
|
+
"name": "grade",
|
|
150
|
+
"title": "What's your grade?",
|
|
151
|
+
"components": [
|
|
152
|
+
{
|
|
153
|
+
"use": "staffGradeId",
|
|
154
|
+
"label": ""
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"actions": ["submit"],
|
|
158
|
+
"cya_link": {
|
|
159
|
+
"page": "grade",
|
|
160
|
+
"aria_suffix": "grade"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "team-name",
|
|
165
|
+
"name": "team-name",
|
|
166
|
+
"title": "What's your team name?",
|
|
167
|
+
"components": [
|
|
168
|
+
{
|
|
169
|
+
"use": "team",
|
|
170
|
+
"label": ""
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"actions": ["submit"],
|
|
174
|
+
"cya_link": {
|
|
175
|
+
"page": "team-name",
|
|
176
|
+
"aria_suffix": "teams"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"id": "add-or-change-line-manager",
|
|
181
|
+
"name": "add-or-change-line-manager",
|
|
182
|
+
"title": "Add or change a line manager",
|
|
183
|
+
"components": [
|
|
184
|
+
"Your line manager will need to review some of your forms. It’s important to keep their details up-to-date.",
|
|
185
|
+
"An email will be sent to your line manager to ask if they want to approve your request to add them.",
|
|
186
|
+
{
|
|
187
|
+
"type": "inset-text",
|
|
188
|
+
"content": "The changes will show in your profile when they approve your request."
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"type": "heading",
|
|
192
|
+
"size": "m",
|
|
193
|
+
"content": "Mandatory declarations"
|
|
194
|
+
},
|
|
195
|
+
"Mandatory declarations will not go to your line manager until they have approved your request."
|
|
196
|
+
],
|
|
197
|
+
"actions": [
|
|
198
|
+
{
|
|
199
|
+
"type": "navigate",
|
|
200
|
+
"page": "line-manager-email"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"show_on_cya": false
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "line-manager-email",
|
|
207
|
+
"name": "line-manager-email",
|
|
208
|
+
"title": "What’s your line manager’s email address?",
|
|
209
|
+
"components": [
|
|
210
|
+
{
|
|
211
|
+
"use": "linemanagerEmail"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"actions": ["submit"],
|
|
215
|
+
"cya_link": {
|
|
216
|
+
"page": "add-or-change-line-manager",
|
|
217
|
+
"aria_suffix": "line manager email address"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"id": "add-or-change-delegate",
|
|
222
|
+
"name": "add-or-change-delegate",
|
|
223
|
+
"title": "Add or change a delegate",
|
|
224
|
+
"components": [
|
|
225
|
+
"A delegate can review a mandatory declaration on your behalf.",
|
|
226
|
+
"An email will be sent to the delegate to ask if they want to approve your request.",
|
|
227
|
+
{
|
|
228
|
+
"type": "inset-text",
|
|
229
|
+
"content": "The changes will show in your profile when they approve your request."
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
"actions": [
|
|
233
|
+
{
|
|
234
|
+
"type": "navigate",
|
|
235
|
+
"page": "delegate-email"
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
"show_on_cya": false
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"id": "delegate-email",
|
|
242
|
+
"name": "delegate-email",
|
|
243
|
+
"title": "What’s your delegate's email address?",
|
|
244
|
+
"components": [
|
|
245
|
+
{
|
|
246
|
+
"use": "delegateEmails",
|
|
247
|
+
"label": "Delegate email address"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"actions": ["submit"],
|
|
251
|
+
"cya_link": {
|
|
252
|
+
"page": "add-or-change-delegate"
|
|
253
|
+
},
|
|
254
|
+
"show_when": [
|
|
255
|
+
{
|
|
256
|
+
"field": "areYouACivilServant",
|
|
257
|
+
"op": "eq",
|
|
258
|
+
"value": "yes"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"field": "staffGradeId",
|
|
262
|
+
"op": "in",
|
|
263
|
+
"values": [
|
|
264
|
+
"373979c1-2360-46be-b712-0409ac068059",
|
|
265
|
+
"36c80dfe-0aae-455b-9445-2e1c09dcafdc",
|
|
266
|
+
"1b041cda-b151-4769-b76a-d42d67b0b960",
|
|
267
|
+
"172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
|
|
268
|
+
"39e18b45-0358-4a45-83ec-5a70b74641e8"
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
"hub": { "format": "CYA" },
|
|
275
|
+
"cya": { "hide_page_titles": true, "hide_actions": true }
|
|
276
|
+
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var TYPE_ALERT = 'alert';
|
|
7
8
|
var TYPE_AUTOCOMPLETE = 'autocomplete';
|
|
8
9
|
var TYPE_CALCULATION = 'calculation';
|
|
9
10
|
var TYPE_CHECKBOXES = 'checkboxes';
|
|
@@ -16,6 +17,9 @@ var TYPE_FILE = 'file';
|
|
|
16
17
|
var TYPE_HEADING = 'heading';
|
|
17
18
|
var TYPE_HTML = 'html';
|
|
18
19
|
var TYPE_INSET_TEXT = 'inset-text';
|
|
20
|
+
var TYPE_LIST = 'list';
|
|
21
|
+
var TYPE_MULTI_FILE = 'multifile';
|
|
22
|
+
var TYPE_PARAGRAPH = 'paragraph';
|
|
19
23
|
var TYPE_PHONE_NUMBER = 'phone-number';
|
|
20
24
|
var TYPE_RADIOS = 'radios';
|
|
21
25
|
var TYPE_SELECT = 'select';
|
|
@@ -24,6 +28,7 @@ var TYPE_TEXT_AREA = 'textarea';
|
|
|
24
28
|
var TYPE_TIME = 'time';
|
|
25
29
|
var TYPE_WARNING = 'warning';
|
|
26
30
|
var ComponentTypes = {
|
|
31
|
+
ALERT: TYPE_ALERT,
|
|
27
32
|
AUTOCOMPLETE: TYPE_AUTOCOMPLETE,
|
|
28
33
|
CALCULATION: TYPE_CALCULATION,
|
|
29
34
|
CHECKBOXES: TYPE_CHECKBOXES,
|
|
@@ -36,6 +41,9 @@ var ComponentTypes = {
|
|
|
36
41
|
HEADING: TYPE_HEADING,
|
|
37
42
|
HTML: TYPE_HTML,
|
|
38
43
|
INSET_TEXT: TYPE_INSET_TEXT,
|
|
44
|
+
LIST: TYPE_LIST,
|
|
45
|
+
MULTI_FILE: TYPE_MULTI_FILE,
|
|
46
|
+
PARAGRAPH: TYPE_PARAGRAPH,
|
|
39
47
|
PHONE_NUMBER: TYPE_PHONE_NUMBER,
|
|
40
48
|
RADIOS: TYPE_RADIOS,
|
|
41
49
|
SELECT: TYPE_SELECT,
|
|
@@ -5,7 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.PageActionTypes = exports.DefaultPageActions = void 0;
|
|
7
7
|
var _DefaultPageActions;
|
|
8
|
-
function
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
12
|
var TYPE_CANCEL = 'cancel';
|
|
10
13
|
var TYPE_COLLECTION_ADD = 'collectionAdd';
|
|
11
14
|
var TYPE_COLLECTION_DUPLICATE = 'collectionDuplicate';
|
|
@@ -5,16 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.StateTypes = void 0;
|
|
7
7
|
var _StateDetails;
|
|
8
|
-
function
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
12
|
var TYPE_COMPLETE = 'complete';
|
|
10
13
|
var TYPE_IN_PROGRESS = 'inProgress';
|
|
11
14
|
var TYPE_NOT_STARTED = 'notStarted';
|
|
12
15
|
var TYPE_CANNOT_START_YET = 'cannotStartYet';
|
|
16
|
+
var TYPE_SKIPPED = 'skipped';
|
|
13
17
|
var StateTypes = {
|
|
14
18
|
COMPLETE: TYPE_COMPLETE,
|
|
15
19
|
IN_PROGRESS: TYPE_IN_PROGRESS,
|
|
16
20
|
NOT_STARTED: TYPE_NOT_STARTED,
|
|
17
|
-
CANNOT_START_YET: TYPE_CANNOT_START_YET
|
|
21
|
+
CANNOT_START_YET: TYPE_CANNOT_START_YET,
|
|
22
|
+
SKIPPED: TYPE_SKIPPED
|
|
18
23
|
};
|
|
19
24
|
exports.StateTypes = StateTypes;
|
|
20
25
|
var StateDetails = (_StateDetails = {}, _defineProperty(_StateDetails, TYPE_COMPLETE, {
|
|
@@ -29,6 +34,9 @@ var StateDetails = (_StateDetails = {}, _defineProperty(_StateDetails, TYPE_COMP
|
|
|
29
34
|
}), _defineProperty(_StateDetails, TYPE_CANNOT_START_YET, {
|
|
30
35
|
label: 'Cannot Start Yet',
|
|
31
36
|
colour: 'dark-grey'
|
|
37
|
+
}), _defineProperty(_StateDetails, TYPE_SKIPPED, {
|
|
38
|
+
label: 'Skipped',
|
|
39
|
+
colour: 'dark-grey'
|
|
32
40
|
}), _StateDetails);
|
|
33
41
|
var TaskStates = {
|
|
34
42
|
TYPES: StateTypes,
|
package/dist/models/index.js
CHANGED
|
@@ -51,6 +51,7 @@ Object.defineProperty(exports, "TaskStates", {
|
|
|
51
51
|
return _TaskStates.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
+
exports.default = void 0;
|
|
54
55
|
var _CollectionLabels = _interopRequireDefault(require("./CollectionLabels"));
|
|
55
56
|
var _ComponentTypes = _interopRequireDefault(require("./ComponentTypes"));
|
|
56
57
|
var _EventTypes = _interopRequireDefault(require("./EventTypes"));
|
|
@@ -59,4 +60,18 @@ var _FormTypes = _interopRequireDefault(require("./FormTypes"));
|
|
|
59
60
|
var _HubFormats = _interopRequireDefault(require("./HubFormats"));
|
|
60
61
|
var _PageAction = _interopRequireDefault(require("./PageAction"));
|
|
61
62
|
var _TaskStates = _interopRequireDefault(require("./TaskStates"));
|
|
62
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
64
|
+
// Local imports
|
|
65
|
+
|
|
66
|
+
var Models = {
|
|
67
|
+
CollectionLabels: _CollectionLabels.default,
|
|
68
|
+
ComponentTypes: _ComponentTypes.default,
|
|
69
|
+
EventTypes: _EventTypes.default,
|
|
70
|
+
FormPages: _FormPages.default,
|
|
71
|
+
FormTypes: _FormTypes.default,
|
|
72
|
+
HubFormats: _HubFormats.default,
|
|
73
|
+
PageAction: _PageAction.default,
|
|
74
|
+
TaskStates: _TaskStates.default
|
|
75
|
+
};
|
|
76
|
+
var _default = Models;
|
|
77
|
+
exports.default = _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderWithValidation = exports.renderHookWithProvider = exports.renderDomWithValidation = exports.expectObjectLike = void 0;
|
|
7
|
+
var _react = require("@testing-library/react");
|
|
8
|
+
var _reactHooks = require("@testing-library/react-hooks");
|
|
9
|
+
var _reactDom = require("react-dom");
|
|
10
|
+
var _context = require("./context");
|
|
11
|
+
var renderWithValidation = function renderWithValidation(ui, options) {
|
|
12
|
+
return (0, _react.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
13
|
+
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
14
|
+
}, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
|
|
15
|
+
key: "vcp"
|
|
16
|
+
}, ui)), options);
|
|
17
|
+
};
|
|
18
|
+
exports.renderWithValidation = renderWithValidation;
|
|
19
|
+
var renderDomWithValidation = function renderDomWithValidation(ui, container, options) {
|
|
20
|
+
return (0, _reactDom.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
21
|
+
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
22
|
+
}, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
|
|
23
|
+
key: "vcp"
|
|
24
|
+
}, ui)), container);
|
|
25
|
+
};
|
|
26
|
+
exports.renderDomWithValidation = renderDomWithValidation;
|
|
27
|
+
var renderHookWithProvider = function renderHookWithProvider(hook, options) {
|
|
28
|
+
var wrapper = function wrapper(_ref) {
|
|
29
|
+
var children = _ref.children;
|
|
30
|
+
return /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
31
|
+
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
32
|
+
}, children);
|
|
33
|
+
};
|
|
34
|
+
return (0, _reactHooks.renderHook)(function () {
|
|
35
|
+
return hook();
|
|
36
|
+
}, {
|
|
37
|
+
wrapper: wrapper
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.renderHookWithProvider = renderHookWithProvider;
|
|
41
|
+
var expectObjectLike = function expectObjectLike(received, expected) {
|
|
42
|
+
Object.keys(expected).forEach(function (key) {
|
|
43
|
+
expect(received[key]).toEqual(expected[key]);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.expectObjectLike = expectObjectLike;
|
|
@@ -29,12 +29,12 @@ var getPageFromCYALink = function getPageFromCYALink(link) {
|
|
|
29
29
|
* - `href: '/bravo'` => `page: 'bravo'`
|
|
30
30
|
*/
|
|
31
31
|
var getCYAAction = function getCYAAction(readonly, page, onAction) {
|
|
32
|
-
var
|
|
33
|
-
if (readonly !== true &&
|
|
32
|
+
var cyaLink = page === null || page === void 0 ? void 0 : page.cya_link;
|
|
33
|
+
if (readonly !== true && cyaLink) {
|
|
34
34
|
return {
|
|
35
|
-
page: getPageFromCYALink(
|
|
36
|
-
label:
|
|
37
|
-
aria_suffix:
|
|
35
|
+
page: getPageFromCYALink(cyaLink) || page.id || '#',
|
|
36
|
+
label: cyaLink.label || 'Change',
|
|
37
|
+
aria_suffix: cyaLink.aria_suffix,
|
|
38
38
|
onAction: onAction
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
// Local imports
|
|
6
|
+
|
|
7
|
+
describe('utils', function () {
|
|
8
|
+
describe('CheckYourAnswers', function () {
|
|
9
|
+
describe('getCYAAction', function () {
|
|
10
|
+
var getPage = function getPage(cyaLink, id) {
|
|
11
|
+
return {
|
|
12
|
+
cya_link: cyaLink,
|
|
13
|
+
id: id
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
it('should return null if readonly', function () {
|
|
17
|
+
expect((0, _getCYAAction.default)(true, {}, function () {})).toBeNull();
|
|
18
|
+
});
|
|
19
|
+
it('should return null if there is no cya_link', function () {
|
|
20
|
+
expect((0, _getCYAAction.default)(false, null, function () {})).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
it('should return a default action if the cya_link is empty and the page has no id', function () {
|
|
23
|
+
var cyaLink = {};
|
|
24
|
+
var onAction = function onAction() {};
|
|
25
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
26
|
+
page: '#',
|
|
27
|
+
label: 'Change',
|
|
28
|
+
onAction: onAction
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it('should return a default action if the cya_link is empty but the page has an id', function () {
|
|
32
|
+
var PAGE_ID = 'page-id';
|
|
33
|
+
var cyaLink = {};
|
|
34
|
+
var onAction = function onAction() {};
|
|
35
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink, PAGE_ID), onAction)).toEqual({
|
|
36
|
+
page: PAGE_ID,
|
|
37
|
+
label: 'Change',
|
|
38
|
+
onAction: onAction
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
it('should use page specified in cya_link', function () {
|
|
42
|
+
var PAGE = 'alpha';
|
|
43
|
+
var cyaLink = {
|
|
44
|
+
page: PAGE
|
|
45
|
+
};
|
|
46
|
+
var onAction = function onAction() {};
|
|
47
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
48
|
+
page: PAGE,
|
|
49
|
+
label: 'Change',
|
|
50
|
+
onAction: onAction
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it('should convert an href specified in cya_link', function () {
|
|
54
|
+
var HREF = '/alpha/bravo';
|
|
55
|
+
var cyaLink = {
|
|
56
|
+
href: HREF
|
|
57
|
+
};
|
|
58
|
+
var onAction = function onAction() {};
|
|
59
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
60
|
+
page: 'bravo',
|
|
61
|
+
label: 'Change',
|
|
62
|
+
onAction: onAction
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
it('should convert a url specified in cya_link', function () {
|
|
66
|
+
var URL = '/alpha/bravo';
|
|
67
|
+
var cyaLink = {
|
|
68
|
+
url: URL
|
|
69
|
+
};
|
|
70
|
+
var onAction = function onAction() {};
|
|
71
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
72
|
+
page: 'bravo',
|
|
73
|
+
label: 'Change',
|
|
74
|
+
onAction: onAction
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it('should use label specified in cya_link', function () {
|
|
78
|
+
var LABEL = 'Alpha Bravo Charlie';
|
|
79
|
+
var cyaLink = {
|
|
80
|
+
label: LABEL
|
|
81
|
+
};
|
|
82
|
+
var onAction = function onAction() {};
|
|
83
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
84
|
+
page: '#',
|
|
85
|
+
label: LABEL,
|
|
86
|
+
onAction: onAction
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
it('should use aria_suffix specified in cya_link', function () {
|
|
90
|
+
var ARIA_SUFFIX = 'This is hidden text';
|
|
91
|
+
var cyaLink = {
|
|
92
|
+
aria_suffix: ARIA_SUFFIX
|
|
93
|
+
};
|
|
94
|
+
var onAction = function onAction() {};
|
|
95
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
96
|
+
page: '#',
|
|
97
|
+
label: 'Change',
|
|
98
|
+
aria_suffix: ARIA_SUFFIX,
|
|
99
|
+
onAction: onAction
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it('should use all properties specified in cya_link', function () {
|
|
103
|
+
var PAGE = 'alpha';
|
|
104
|
+
var LABEL = 'Alpha Bravo Charlie';
|
|
105
|
+
var ARIA_SUFFIX = 'This is hidden text';
|
|
106
|
+
var cyaLink = {
|
|
107
|
+
label: LABEL,
|
|
108
|
+
page: PAGE,
|
|
109
|
+
aria_suffix: ARIA_SUFFIX
|
|
110
|
+
};
|
|
111
|
+
var onAction = function onAction() {};
|
|
112
|
+
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
113
|
+
page: PAGE,
|
|
114
|
+
label: LABEL,
|
|
115
|
+
aria_suffix: ARIA_SUFFIX,
|
|
116
|
+
onAction: onAction
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|