@ukhomeoffice/cop-react-form-renderer 6.0.6-peter → 6.7.0-alpha
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 +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +2 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +75 -59
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +15 -14
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.test.js +98 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +144 -135
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +167 -197
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +54 -56
- package/dist/components/CollectionSummary/RenderListView.scss +10 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +89 -78
- package/dist/components/CollectionSummary/SummaryCard.js +135 -145
- package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +943 -932
- package/dist/components/CollectionSummary/SummaryCardDetails.js +120 -62
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +261 -120
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +38 -33
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -73
- package/dist/components/FormComponent/Collection.js +81 -108
- package/dist/components/FormComponent/Collection.test.js +909 -943
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +80 -71
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.scss +1 -1
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +150 -183
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +50 -48
- package/dist/components/FormRenderer/onPageAction.test.js +241 -217
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.scss +2 -2
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.scss +1 -1
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +65 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -61
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +27 -40
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +29 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -4
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +7 -27
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +29 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +66 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +55 -0
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +153 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +3 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -17
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +38 -20
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +28 -19
- package/dist/utils/Condition/meetsCondition.test.js +476 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +29 -25
- package/dist/utils/Data/getOptions.test.js +93 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +42 -0
- package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +77 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -52
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -27
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +16 -19
- package/dist/utils/Validate/validateContainer.test.js +84 -45
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +24 -18
- package/dist/utils/Validate/validatePage.test.js +263 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +5 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -175
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -113
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -20
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -6,120 +6,107 @@ var _handlers = _interopRequireDefault(require("./handlers"));
|
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onPageAction = _interopRequireDefault(require("./onPageAction"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
submissionErrorCalls: 0,
|
|
22
|
-
submissionErrorArgs: [],
|
|
23
|
-
submissionError: function submissionError(errors, addErrors) {
|
|
24
|
-
this.submissionErrorCalls += 1;
|
|
25
|
-
this.submissionErrorArgs.push(errors);
|
|
26
|
-
if (typeof addErrors === 'function') {
|
|
27
|
-
addErrors(errors);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
reset: function reset() {
|
|
31
|
-
this.navigateCalls = 0;
|
|
32
|
-
this.submissionErrorCalls = 0;
|
|
33
|
-
this.submissionErrorArgs = [];
|
|
9
|
+
jest.mock('./handlers', () => ({
|
|
10
|
+
navigateCalls: 0,
|
|
11
|
+
navigate() {
|
|
12
|
+
this.navigateCalls += 1;
|
|
13
|
+
},
|
|
14
|
+
submissionErrorCalls: 0,
|
|
15
|
+
submissionErrorArgs: [],
|
|
16
|
+
submissionError(errors, addErrors) {
|
|
17
|
+
this.submissionErrorCalls += 1;
|
|
18
|
+
this.submissionErrorArgs.push(errors);
|
|
19
|
+
if (typeof addErrors === 'function') {
|
|
20
|
+
addErrors(errors);
|
|
34
21
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cleanHiddenNestedData: function cleanHiddenNestedData(patch) {
|
|
50
|
-
this.cleanHiddenNestedDataCalls += 1;
|
|
51
|
-
return patch;
|
|
52
|
-
},
|
|
53
|
-
clearOutUncompletedRoutesCalls: 0,
|
|
54
|
-
clearOutUncompletedRoutes: function clearOutUncompletedRoutes(pages, allComponents, formData) {
|
|
55
|
-
this.clearOutUncompletedRoutesCalls += 1;
|
|
56
|
-
return formData;
|
|
57
|
-
},
|
|
58
|
-
getNextPageIdCalls: 0,
|
|
59
|
-
getNextPageId: function getNextPageId() {
|
|
60
|
-
this.getNextPageIdCalls += 1;
|
|
61
|
-
return 'page2';
|
|
62
|
-
},
|
|
63
|
-
getSubmissionStatusCalls: 0,
|
|
64
|
-
getSubmissionStatus: function getSubmissionStatus() {
|
|
65
|
-
this.getSubmissionStatusCalls += 1;
|
|
66
|
-
return 'Good to go!';
|
|
67
|
-
},
|
|
68
|
-
reset: function reset() {
|
|
69
|
-
this.canActionProceedCalls = 0;
|
|
70
|
-
this.canActionProceedResult = true;
|
|
71
|
-
this.canCYASubmitResult = true;
|
|
72
|
-
this.cleanHiddenNestedDataCalls = 0;
|
|
73
|
-
this.getFormStateCalls = 0;
|
|
74
|
-
this.getSubmissionStatusCalls = 0;
|
|
22
|
+
},
|
|
23
|
+
reset() {
|
|
24
|
+
this.navigateCalls = 0;
|
|
25
|
+
this.submissionErrorCalls = 0;
|
|
26
|
+
this.submissionErrorArgs = [];
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('./helpers', () => ({
|
|
30
|
+
canActionProceedCalls: 0,
|
|
31
|
+
canActionProceedResult: true,
|
|
32
|
+
canActionProceed(action, page, validator) {
|
|
33
|
+
this.canActionProceedCalls += 1;
|
|
34
|
+
if (typeof validator === 'function') {
|
|
35
|
+
validator();
|
|
75
36
|
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
37
|
+
return this.canActionProceedResult;
|
|
38
|
+
},
|
|
39
|
+
cleanHiddenNestedDataCalls: 0,
|
|
40
|
+
cleanHiddenNestedData(patch) {
|
|
41
|
+
this.cleanHiddenNestedDataCalls += 1;
|
|
42
|
+
return patch;
|
|
43
|
+
},
|
|
44
|
+
getNextPageIdCalls: 0,
|
|
45
|
+
getNextPageId() {
|
|
46
|
+
this.getNextPageIdCalls += 1;
|
|
47
|
+
return 'page2';
|
|
48
|
+
},
|
|
49
|
+
getSubmissionStatusCalls: 0,
|
|
50
|
+
getSubmissionStatus() {
|
|
51
|
+
this.getSubmissionStatusCalls += 1;
|
|
52
|
+
return 'Good to go!';
|
|
53
|
+
},
|
|
54
|
+
reset() {
|
|
55
|
+
this.canActionProceedCalls = 0;
|
|
56
|
+
this.canActionProceedResult = true;
|
|
57
|
+
this.canCYASubmitResult = true;
|
|
58
|
+
this.cleanHiddenNestedDataCalls = 0;
|
|
59
|
+
this.getFormStateCalls = 0;
|
|
60
|
+
this.getSubmissionStatusCalls = 0;
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
jest.mock('../../utils', () => {
|
|
64
|
+
const originalModule = jest.requireActual('../../utils');
|
|
65
|
+
return {
|
|
66
|
+
...originalModule.default,
|
|
81
67
|
Format: {
|
|
82
68
|
formCalls: 0,
|
|
83
|
-
form
|
|
69
|
+
form(form, data) {
|
|
84
70
|
this.formCalls += 1;
|
|
85
71
|
return data;
|
|
86
72
|
}
|
|
87
73
|
},
|
|
88
|
-
CollectionPage:
|
|
74
|
+
CollectionPage: {
|
|
75
|
+
...originalModule.default.CollectionPage,
|
|
89
76
|
duplicateActiveEntryCalls: 0,
|
|
90
77
|
duplicateActiveEntryResult: true,
|
|
91
|
-
duplicateActiveEntry
|
|
78
|
+
duplicateActiveEntry() {
|
|
92
79
|
this.duplicateActiveEntryCalls += 1;
|
|
93
80
|
return this.duplicateActiveEntryResult;
|
|
94
81
|
},
|
|
95
82
|
addEntryCalls: 0,
|
|
96
83
|
addEntryResult: true,
|
|
97
|
-
addEntry
|
|
84
|
+
addEntry(collectionName, formData) {
|
|
98
85
|
originalModule.default.CollectionPage.addEntry(collectionName, formData);
|
|
99
86
|
this.addEntryCalls += 1;
|
|
100
87
|
return this.addEntryResult;
|
|
101
88
|
}
|
|
102
|
-
}
|
|
103
|
-
reset
|
|
89
|
+
},
|
|
90
|
+
reset() {
|
|
104
91
|
this.Format.formCalls = 0;
|
|
105
92
|
this.CollectionPage.duplicateActiveEntryCalls = 0;
|
|
106
93
|
this.duplicateActiveEntryResult = true;
|
|
107
94
|
this.CollectionPage.addEntryCalls = 0;
|
|
108
95
|
this.addEntryResult = true;
|
|
109
96
|
}
|
|
110
|
-
}
|
|
97
|
+
};
|
|
111
98
|
});
|
|
112
|
-
describe('components.FormRenderer.onPageAction',
|
|
113
|
-
|
|
99
|
+
describe('components.FormRenderer.onPageAction', () => {
|
|
100
|
+
const MOCK_HOOKS = {
|
|
114
101
|
onSubmitCalls: 0,
|
|
115
102
|
onSubmitArgs: [],
|
|
116
|
-
onSubmit
|
|
103
|
+
onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
|
|
117
104
|
this.onSubmitCalls += 1;
|
|
118
105
|
this.onSubmitArgs.push({
|
|
119
|
-
type
|
|
120
|
-
payload
|
|
121
|
-
changedFieldName
|
|
122
|
-
changedFieldValue
|
|
106
|
+
type,
|
|
107
|
+
payload,
|
|
108
|
+
changedFieldName,
|
|
109
|
+
changedFieldValue
|
|
123
110
|
});
|
|
124
111
|
if (typeof onSuccess === 'function') {
|
|
125
112
|
onSuccess();
|
|
@@ -132,14 +119,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
132
119
|
}
|
|
133
120
|
},
|
|
134
121
|
onFormCompleteCalls: 0,
|
|
135
|
-
onFormComplete
|
|
122
|
+
onFormComplete() {
|
|
136
123
|
this.onFormCompleteCalls += 1;
|
|
137
124
|
},
|
|
138
125
|
onCancelArgs: [],
|
|
139
|
-
onCancel
|
|
126
|
+
onCancel(data) {
|
|
140
127
|
this.onCancelArgs.push(data);
|
|
141
128
|
},
|
|
142
|
-
reset
|
|
129
|
+
reset() {
|
|
143
130
|
this.onSubmitCalls = 0;
|
|
144
131
|
this.onSubmitArgs = [];
|
|
145
132
|
this.onFormCompleteCalls = 0;
|
|
@@ -147,54 +134,54 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
147
134
|
this.onActionCalls = 0;
|
|
148
135
|
},
|
|
149
136
|
onActionCalls: 0,
|
|
150
|
-
onAction
|
|
137
|
+
onAction(formData, patch) {
|
|
151
138
|
this.onActionCalls += 1;
|
|
152
139
|
return {
|
|
153
|
-
formData
|
|
154
|
-
patch
|
|
140
|
+
formData,
|
|
141
|
+
patch
|
|
155
142
|
};
|
|
156
143
|
}
|
|
157
144
|
};
|
|
158
|
-
|
|
145
|
+
const MOCK_VALIDATE = {
|
|
159
146
|
pageCalls: 0,
|
|
160
|
-
page
|
|
147
|
+
page() {
|
|
161
148
|
MOCK_VALIDATE.pageCalls += 1;
|
|
162
149
|
},
|
|
163
|
-
reset
|
|
150
|
+
reset() {
|
|
164
151
|
this.pageCalls = 0;
|
|
165
152
|
}
|
|
166
153
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
154
|
+
let setPagePointCalls = 0;
|
|
155
|
+
let setPagePointArgs = [];
|
|
156
|
+
const mockSetPagePoint = point => {
|
|
170
157
|
setPagePointCalls += 1;
|
|
171
158
|
setPagePointArgs.push(point);
|
|
172
159
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
let setDataCalls = 0;
|
|
161
|
+
let setDataArgs = [];
|
|
162
|
+
const mockSetData = data => {
|
|
176
163
|
setDataCalls += 1;
|
|
177
164
|
setDataArgs.push(data);
|
|
178
165
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
166
|
+
let onPageChangeCalls = 0;
|
|
167
|
+
let onPageChangeArgs = [];
|
|
168
|
+
const mockOnPageChange = pageId => {
|
|
182
169
|
onPageChangeCalls += 1;
|
|
183
170
|
onPageChangeArgs.push(pageId);
|
|
184
171
|
};
|
|
185
|
-
|
|
186
|
-
|
|
172
|
+
let addErrorsArgs = [];
|
|
173
|
+
const mockAddErrors = errors => {
|
|
187
174
|
addErrorsArgs.push(errors);
|
|
188
175
|
};
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
let setSubmittedArgs = [];
|
|
177
|
+
const mockSetSubmitted = newSubmitted => {
|
|
191
178
|
setSubmittedArgs.push(newSubmitted);
|
|
192
179
|
};
|
|
193
|
-
|
|
194
|
-
|
|
180
|
+
let mockSubmitting = false;
|
|
181
|
+
const mockSetSubmitting = submitting => {
|
|
195
182
|
mockSubmitting = submitting;
|
|
196
183
|
};
|
|
197
|
-
|
|
184
|
+
const COMPONENTS = [{
|
|
198
185
|
id: 'alpha',
|
|
199
186
|
fieldId: 'alpha'
|
|
200
187
|
}, {
|
|
@@ -207,18 +194,26 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
207
194
|
id: 'delta',
|
|
208
195
|
fieldId: 'delta'
|
|
209
196
|
}];
|
|
210
|
-
|
|
197
|
+
const PAGES = [{
|
|
211
198
|
id: 'page1',
|
|
212
|
-
components: [
|
|
199
|
+
components: [{
|
|
200
|
+
...COMPONENTS[0]
|
|
201
|
+
}, {
|
|
202
|
+
...COMPONENTS[1]
|
|
203
|
+
}]
|
|
213
204
|
}, {
|
|
214
205
|
id: 'page2',
|
|
215
|
-
components: [
|
|
206
|
+
components: [{
|
|
207
|
+
...COMPONENTS[2]
|
|
208
|
+
}, {
|
|
209
|
+
...COMPONENTS[3]
|
|
210
|
+
}]
|
|
216
211
|
}];
|
|
217
|
-
|
|
212
|
+
const CURRENT_TASK = {
|
|
218
213
|
name: 'testTask',
|
|
219
214
|
fullPages: PAGES
|
|
220
215
|
};
|
|
221
|
-
|
|
216
|
+
const ARGS = {
|
|
222
217
|
action: {
|
|
223
218
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
224
219
|
},
|
|
@@ -246,7 +241,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
246
241
|
submitting: mockSubmitting,
|
|
247
242
|
setSubmitting: mockSetSubmitting
|
|
248
243
|
};
|
|
249
|
-
beforeEach(
|
|
244
|
+
beforeEach(() => {
|
|
250
245
|
_handlers.default.reset();
|
|
251
246
|
_helpers.default.reset();
|
|
252
247
|
_utils.default.reset();
|
|
@@ -262,12 +257,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
262
257
|
setSubmittedArgs = [];
|
|
263
258
|
mockSetSubmitting(false);
|
|
264
259
|
});
|
|
265
|
-
|
|
260
|
+
const preActionChecks = () => {
|
|
266
261
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
267
262
|
expect(MOCK_VALIDATE.pageCalls).toEqual(1);
|
|
268
263
|
expect(_helpers.default.cleanHiddenNestedDataCalls).toEqual(1);
|
|
269
264
|
};
|
|
270
|
-
|
|
265
|
+
const postActionChecks = argsUsed => {
|
|
271
266
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
272
267
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
273
268
|
// setData is always called once in the error callback
|
|
@@ -275,8 +270,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
275
270
|
// to this if patch is valid.
|
|
276
271
|
if (argsUsed.patch) {
|
|
277
272
|
expect(setDataCalls).toEqual(2);
|
|
278
|
-
|
|
279
|
-
|
|
273
|
+
const dataUsed = {
|
|
274
|
+
...argsUsed.data,
|
|
275
|
+
...argsUsed.patch,
|
|
276
|
+
...argsUsed.formState.page.formData
|
|
277
|
+
};
|
|
278
|
+
const submissionData = _utils.default.Format.form(null, dataUsed, null);
|
|
280
279
|
submissionData.formStatus = _helpers.default.getSubmissionStatus();
|
|
281
280
|
expect(setDataArgs[0]).toEqual(submissionData);
|
|
282
281
|
} else {
|
|
@@ -284,7 +283,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
284
283
|
}
|
|
285
284
|
expect(MOCK_HOOKS.onSubmitCalls).toEqual(1);
|
|
286
285
|
if (argsUsed.type === _models.FormTypes.HUB && Object.keys(argsUsed.patchLabel).length > 0) {
|
|
287
|
-
|
|
286
|
+
const firstKey = Object.keys(argsUsed.patchLabel)[0];
|
|
288
287
|
expect(MOCK_HOOKS.onSubmitArgs[0]).toMatchObject({
|
|
289
288
|
changedFieldName: firstKey,
|
|
290
289
|
changedFieldValue: argsUsed.patchLabel[firstKey]
|
|
@@ -302,14 +301,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
302
301
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
303
302
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
304
303
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
var ACTION = {
|
|
304
|
+
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), () => {
|
|
305
|
+
const ACTION = {
|
|
308
306
|
type: _models.PageAction.TYPES.CANCEL
|
|
309
307
|
};
|
|
310
|
-
|
|
308
|
+
const CUSTOM_ARGS = {
|
|
309
|
+
...ARGS,
|
|
311
310
|
action: ACTION
|
|
312
|
-
}
|
|
311
|
+
};
|
|
313
312
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
314
313
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
315
314
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -318,13 +317,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
318
317
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
319
318
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
320
319
|
});
|
|
321
|
-
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"),
|
|
322
|
-
|
|
320
|
+
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), () => {
|
|
321
|
+
const ACTION = {
|
|
323
322
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
324
323
|
};
|
|
325
|
-
|
|
324
|
+
const CUSTOM_ARGS = {
|
|
325
|
+
...ARGS,
|
|
326
326
|
action: ACTION
|
|
327
|
-
}
|
|
327
|
+
};
|
|
328
328
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
329
329
|
preActionChecks();
|
|
330
330
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -333,27 +333,28 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
333
333
|
// as a navigate action should stop at calling
|
|
334
334
|
// hooks.navigate.
|
|
335
335
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
var ACTION = {
|
|
336
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), () => {
|
|
337
|
+
const ACTION = {
|
|
339
338
|
type: _models.PageAction.TYPES.SUBMIT
|
|
340
339
|
};
|
|
341
|
-
|
|
340
|
+
const CUSTOM_ARGS = {
|
|
341
|
+
...ARGS,
|
|
342
342
|
action: ACTION
|
|
343
|
-
}
|
|
343
|
+
};
|
|
344
344
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
345
345
|
preActionChecks();
|
|
346
346
|
expect(setPagePointCalls).toEqual(1);
|
|
347
347
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
348
348
|
postActionChecks(CUSTOM_ARGS);
|
|
349
349
|
});
|
|
350
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"),
|
|
351
|
-
|
|
350
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), () => {
|
|
351
|
+
const ACTION = {
|
|
352
352
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
353
353
|
};
|
|
354
|
-
|
|
354
|
+
const CUSTOM_ARGS = {
|
|
355
|
+
...ARGS,
|
|
355
356
|
action: ACTION
|
|
356
|
-
}
|
|
357
|
+
};
|
|
357
358
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
358
359
|
preActionChecks();
|
|
359
360
|
// All the actions does in this case is set a function
|
|
@@ -361,22 +362,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
361
362
|
postActionChecks(CUSTOM_ARGS);
|
|
362
363
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
363
364
|
});
|
|
364
|
-
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"),
|
|
365
|
-
|
|
365
|
+
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), () => {
|
|
366
|
+
const FORM_STATE = {
|
|
366
367
|
page: {
|
|
367
368
|
formData: {
|
|
368
369
|
'testCollection': []
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
372
|
};
|
|
372
|
-
|
|
373
|
+
const ACTION = {
|
|
373
374
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
374
375
|
collection: 'testCollection'
|
|
375
376
|
};
|
|
376
|
-
|
|
377
|
+
const CUSTOM_ARGS = {
|
|
378
|
+
...ARGS,
|
|
377
379
|
action: ACTION,
|
|
378
380
|
formState: FORM_STATE
|
|
379
|
-
}
|
|
381
|
+
};
|
|
380
382
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
381
383
|
preActionChecks();
|
|
382
384
|
expect(FORM_STATE.page.formData["".concat(ACTION.collection, "ActiveId")]).toBeDefined();
|
|
@@ -386,23 +388,24 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
386
388
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
387
389
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
388
390
|
});
|
|
389
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"),
|
|
390
|
-
it("calling handlers.navigate if the duplication was successful",
|
|
391
|
-
|
|
391
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), () => {
|
|
392
|
+
it("calling handlers.navigate if the duplication was successful", () => {
|
|
393
|
+
const FORM_STATE = {
|
|
392
394
|
page: {
|
|
393
395
|
formData: {
|
|
394
396
|
'testCollection': []
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
399
|
};
|
|
398
|
-
|
|
400
|
+
const ACTION = {
|
|
399
401
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
400
402
|
collection: 'testCollection'
|
|
401
403
|
};
|
|
402
|
-
|
|
404
|
+
const CUSTOM_ARGS = {
|
|
405
|
+
...ARGS,
|
|
403
406
|
action: ACTION,
|
|
404
407
|
formState: FORM_STATE
|
|
405
|
-
}
|
|
408
|
+
};
|
|
406
409
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
407
410
|
preActionChecks();
|
|
408
411
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -412,22 +415,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
412
415
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
413
416
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
414
417
|
});
|
|
415
|
-
it("calling onPageChange if the duplication was unsuccessful",
|
|
416
|
-
|
|
418
|
+
it("calling onPageChange if the duplication was unsuccessful", () => {
|
|
419
|
+
const FORM_STATE = {
|
|
417
420
|
page: {
|
|
418
421
|
formData: {
|
|
419
422
|
'testCollection': []
|
|
420
423
|
}
|
|
421
424
|
}
|
|
422
425
|
};
|
|
423
|
-
|
|
426
|
+
const ACTION = {
|
|
424
427
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
425
428
|
collection: 'testCollection'
|
|
426
429
|
};
|
|
427
|
-
|
|
430
|
+
const CUSTOM_ARGS = {
|
|
431
|
+
...ARGS,
|
|
428
432
|
action: ACTION,
|
|
429
433
|
formState: FORM_STATE
|
|
430
|
-
}
|
|
434
|
+
};
|
|
431
435
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
432
436
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
433
437
|
preActionChecks();
|
|
@@ -441,9 +445,9 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
441
445
|
expect(onPageChangeCalls).toEqual(1);
|
|
442
446
|
});
|
|
443
447
|
});
|
|
444
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"),
|
|
445
|
-
it("should store a reference to the removed item if action.recordRemoval is true",
|
|
446
|
-
|
|
448
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), () => {
|
|
449
|
+
it("should store a reference to the removed item if action.recordRemoval is true", () => {
|
|
450
|
+
const FORM_STATE = {
|
|
447
451
|
page: {
|
|
448
452
|
formData: {
|
|
449
453
|
testCollectionActiveId: 'removeMe',
|
|
@@ -455,15 +459,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
461
|
};
|
|
458
|
-
|
|
462
|
+
const ACTION = {
|
|
459
463
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
460
464
|
collection: 'testCollection',
|
|
461
465
|
recordRemoval: true
|
|
462
466
|
};
|
|
463
|
-
|
|
467
|
+
const CUSTOM_ARGS = {
|
|
468
|
+
...ARGS,
|
|
464
469
|
action: ACTION,
|
|
465
470
|
formState: FORM_STATE
|
|
466
|
-
}
|
|
471
|
+
};
|
|
467
472
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
468
473
|
preActionChecks();
|
|
469
474
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -477,8 +482,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
477
482
|
// This action type uses the default onPageChange.
|
|
478
483
|
expect(onPageChangeCalls).toEqual(1);
|
|
479
484
|
});
|
|
480
|
-
it("should not store a reference to the removed item if action.recordRemoval is false",
|
|
481
|
-
|
|
485
|
+
it("should not store a reference to the removed item if action.recordRemoval is false", () => {
|
|
486
|
+
const FORM_STATE = {
|
|
482
487
|
page: {
|
|
483
488
|
formData: {
|
|
484
489
|
testCollectionActiveId: 'removeMe',
|
|
@@ -490,15 +495,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
490
495
|
}
|
|
491
496
|
}
|
|
492
497
|
};
|
|
493
|
-
|
|
498
|
+
const ACTION = {
|
|
494
499
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
495
500
|
collection: 'testCollection',
|
|
496
501
|
recordRemoval: false
|
|
497
502
|
};
|
|
498
|
-
|
|
503
|
+
const CUSTOM_ARGS = {
|
|
504
|
+
...ARGS,
|
|
499
505
|
action: ACTION,
|
|
500
506
|
formState: FORM_STATE
|
|
501
|
-
}
|
|
507
|
+
};
|
|
502
508
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
503
509
|
preActionChecks();
|
|
504
510
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -510,8 +516,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
510
516
|
// This action type uses the default onPageChange.
|
|
511
517
|
expect(onPageChangeCalls).toEqual(1);
|
|
512
518
|
});
|
|
513
|
-
it("should not store a reference to the removed item if action.recordRemoval is not defined",
|
|
514
|
-
|
|
519
|
+
it("should not store a reference to the removed item if action.recordRemoval is not defined", () => {
|
|
520
|
+
const FORM_STATE = {
|
|
515
521
|
page: {
|
|
516
522
|
formData: {
|
|
517
523
|
testCollectionActiveId: 'removeMe',
|
|
@@ -523,14 +529,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
523
529
|
}
|
|
524
530
|
}
|
|
525
531
|
};
|
|
526
|
-
|
|
532
|
+
const ACTION = {
|
|
527
533
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
528
534
|
collection: 'testCollection'
|
|
529
535
|
};
|
|
530
|
-
|
|
536
|
+
const CUSTOM_ARGS = {
|
|
537
|
+
...ARGS,
|
|
531
538
|
action: ACTION,
|
|
532
539
|
formState: FORM_STATE
|
|
533
|
-
}
|
|
540
|
+
};
|
|
534
541
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
535
542
|
preActionChecks();
|
|
536
543
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -543,18 +550,17 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
543
550
|
expect(onPageChangeCalls).toEqual(1);
|
|
544
551
|
});
|
|
545
552
|
});
|
|
546
|
-
describe('if validation fails',
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
it("should not continue for the ".concat(actionType, " action type"), function () {
|
|
552
|
-
var ACTION = {
|
|
553
|
+
describe('if validation fails', () => {
|
|
554
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL);
|
|
555
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
556
|
+
it("should not continue for the ".concat(actionType, " action type"), () => {
|
|
557
|
+
const ACTION = {
|
|
553
558
|
type: actionType
|
|
554
559
|
};
|
|
555
|
-
|
|
560
|
+
const CUSTOM_ARGS = {
|
|
561
|
+
...ARGS,
|
|
556
562
|
action: ACTION
|
|
557
|
-
}
|
|
563
|
+
};
|
|
558
564
|
_helpers.default.canActionProceedResult = false;
|
|
559
565
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
560
566
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -565,59 +571,72 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
565
571
|
});
|
|
566
572
|
});
|
|
567
573
|
});
|
|
568
|
-
describe('adding a field to formData if specified on the action',
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
574
|
-
var FORM_STATE = {
|
|
574
|
+
describe('adding a field to formData if specified on the action', () => {
|
|
575
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
576
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
577
|
+
it("should work for the ".concat(actionType, " action type"), () => {
|
|
578
|
+
const FORM_STATE = {
|
|
575
579
|
page: {
|
|
576
580
|
formData: {
|
|
577
581
|
testCollection: []
|
|
578
582
|
}
|
|
579
583
|
}
|
|
580
584
|
};
|
|
581
|
-
|
|
585
|
+
const ACTION = {
|
|
582
586
|
type: actionType,
|
|
583
587
|
collection: 'testCollection',
|
|
584
|
-
addToFormData: {
|
|
588
|
+
addToFormData: [{
|
|
585
589
|
field: 'alpha',
|
|
586
590
|
value: '123'
|
|
587
|
-
}
|
|
591
|
+
}, {
|
|
592
|
+
field: 'parent.child',
|
|
593
|
+
value: [{
|
|
594
|
+
id: '12345'
|
|
595
|
+
}],
|
|
596
|
+
isCollection: true
|
|
597
|
+
}]
|
|
588
598
|
};
|
|
589
|
-
|
|
599
|
+
const CUSTOM_ARGS = {
|
|
600
|
+
...ARGS,
|
|
590
601
|
formState: FORM_STATE,
|
|
591
602
|
action: ACTION
|
|
592
|
-
}
|
|
603
|
+
};
|
|
593
604
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
594
605
|
preActionChecks();
|
|
595
606
|
postActionChecks(CUSTOM_ARGS);
|
|
596
607
|
expect(FORM_STATE.page.formData).toMatchObject({
|
|
597
608
|
alpha: '123'
|
|
598
609
|
});
|
|
610
|
+
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
599
611
|
});
|
|
600
612
|
});
|
|
601
|
-
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"),
|
|
602
|
-
|
|
613
|
+
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), () => {
|
|
614
|
+
const FORM_STATE = {
|
|
603
615
|
page: {
|
|
604
616
|
formData: {
|
|
605
617
|
testCollection: []
|
|
606
618
|
}
|
|
607
619
|
}
|
|
608
620
|
};
|
|
609
|
-
|
|
621
|
+
const ACTION = {
|
|
610
622
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
611
623
|
collection: 'testCollection',
|
|
612
|
-
addToFormData: {
|
|
624
|
+
addToFormData: [{
|
|
613
625
|
field: 'alpha',
|
|
614
626
|
value: '123'
|
|
615
|
-
}
|
|
627
|
+
}, {
|
|
628
|
+
field: 'parent.child',
|
|
629
|
+
value: [{
|
|
630
|
+
id: '12345'
|
|
631
|
+
}],
|
|
632
|
+
isCollection: true
|
|
633
|
+
}]
|
|
616
634
|
};
|
|
617
|
-
|
|
635
|
+
const CUSTOM_ARGS = {
|
|
636
|
+
...ARGS,
|
|
618
637
|
formState: FORM_STATE,
|
|
619
638
|
action: ACTION
|
|
620
|
-
}
|
|
639
|
+
};
|
|
621
640
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
622
641
|
preActionChecks();
|
|
623
642
|
// Not doing the usual post-action checks here
|
|
@@ -626,16 +645,17 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
626
645
|
expect(FORM_STATE.page.formData).toMatchObject({
|
|
627
646
|
alpha: '123'
|
|
628
647
|
});
|
|
648
|
+
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
629
649
|
});
|
|
630
|
-
it('should work for an array of formData',
|
|
631
|
-
|
|
650
|
+
it('should work for an array of formData', () => {
|
|
651
|
+
const FORM_STATE = {
|
|
632
652
|
page: {
|
|
633
653
|
formData: {
|
|
634
654
|
testCollection: []
|
|
635
655
|
}
|
|
636
656
|
}
|
|
637
657
|
};
|
|
638
|
-
|
|
658
|
+
const ACTION = {
|
|
639
659
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
640
660
|
collection: 'testCollection',
|
|
641
661
|
addToFormData: [{
|
|
@@ -646,10 +666,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
646
666
|
value: '456'
|
|
647
667
|
}]
|
|
648
668
|
};
|
|
649
|
-
|
|
669
|
+
const CUSTOM_ARGS = {
|
|
670
|
+
...ARGS,
|
|
650
671
|
formState: FORM_STATE,
|
|
651
672
|
action: ACTION
|
|
652
|
-
}
|
|
673
|
+
};
|
|
653
674
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
654
675
|
preActionChecks();
|
|
655
676
|
// Not doing the usual post-action checks here
|
|
@@ -663,34 +684,37 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
663
684
|
});
|
|
664
685
|
});
|
|
665
686
|
});
|
|
666
|
-
describe('recording patchLabel fields correctly when it is defined',
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
672
|
-
var FORM_STATE = {
|
|
687
|
+
describe('recording patchLabel fields correctly when it is defined', () => {
|
|
688
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
689
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
690
|
+
it("should work for the ".concat(actionType, " action type"), () => {
|
|
691
|
+
const FORM_STATE = {
|
|
673
692
|
page: {
|
|
674
693
|
formData: {
|
|
675
694
|
testCollection: []
|
|
676
695
|
}
|
|
677
696
|
}
|
|
678
697
|
};
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
698
|
+
const KEY = 'testField';
|
|
699
|
+
const VALUE = 'testValue';
|
|
700
|
+
const PATCH_LABEL = {
|
|
701
|
+
[KEY]: VALUE
|
|
702
|
+
};
|
|
703
|
+
const PATCH = {
|
|
704
|
+
[KEY]: VALUE
|
|
705
|
+
};
|
|
706
|
+
const ACTION = {
|
|
684
707
|
type: actionType,
|
|
685
708
|
collection: 'testCollection'
|
|
686
709
|
};
|
|
687
|
-
|
|
710
|
+
const CUSTOM_ARGS = {
|
|
711
|
+
...ARGS,
|
|
688
712
|
action: ACTION,
|
|
689
713
|
formState: FORM_STATE,
|
|
690
714
|
patch: PATCH,
|
|
691
715
|
patchLabel: PATCH_LABEL,
|
|
692
716
|
type: _models.FormTypes.HUB
|
|
693
|
-
}
|
|
717
|
+
};
|
|
694
718
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
695
719
|
preActionChecks();
|
|
696
720
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|