@ukhomeoffice/cop-react-form-renderer 6.13.2 → 6.14.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/README.md +8 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +81 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +47 -48
- package/dist/components/CollectionSummary/RenderListView.scss +4 -0
- package/dist/components/CollectionSummary/RenderListView.test.js +133 -98
- package/dist/components/CollectionSummary/SummaryCard.js +110 -148
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +71 -0
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +85 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +67 -102
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- 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 +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +1 -1
- package/dist/components/FormPage/FormPage.js +99 -88
- package/dist/components/FormPage/FormPage.test.js +173 -164
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +138 -174
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- 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 +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +25 -37
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- 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 +10 -10
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -14
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +146 -98
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +81 -83
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -174
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +17 -26
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +12 -15
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +19 -27
- package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +57 -30
- package/dist/utils/Data/getOptions.test.js +75 -28
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +16 -12
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +25 -22
- package/dist/utils/FormPage/useComponent.test.js +79 -44
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +5 -6
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +23 -24
- package/dist/utils/Hub/index.js +2 -2
- 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 +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +8 -9
- package/dist/utils/Validate/validateEmail.test.js +29 -26
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +5 -6
- package/package.json +5 -5
|
@@ -6,27 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _models = require("../../models");
|
|
8
8
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(
|
|
14
|
-
function _toPropertyKey(
|
|
15
|
-
function _toPrimitive(
|
|
16
|
-
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
const onTaskAction = (currentTask, pages, setCurrentTask, hubDetails, data, onPageChange) => {
|
|
17
16
|
if (currentTask) {
|
|
18
|
-
|
|
17
|
+
const task = currentTask;
|
|
19
18
|
task.fullPages = [];
|
|
20
|
-
task.pages.forEach(
|
|
19
|
+
task.pages.forEach(page => {
|
|
21
20
|
task.fullPages.push(_helpers.default.getPage(page, pages));
|
|
22
21
|
});
|
|
23
22
|
setCurrentTask(currentTask);
|
|
24
|
-
|
|
23
|
+
const state = _objectSpread({}, task);
|
|
25
24
|
if (task.state === _models.TaskStates.TYPES.COMPLETE && !task.alwaysShowFirstPage) {
|
|
26
25
|
if (hubDetails !== null && hubDetails !== void 0 && hubDetails.noTaskCYAs) {
|
|
27
26
|
// If the task is complete and there are no CYA's then show user first page
|
|
28
27
|
/* eslint-disable prefer-destructuring */
|
|
29
|
-
|
|
28
|
+
const currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
30
29
|
onPageChange(task.pages[0] || currentPage);
|
|
31
30
|
} else if (task.customCYA) {
|
|
32
31
|
onPageChange(task.customCYA);
|
|
@@ -34,9 +33,9 @@ var onTaskAction = function onTaskAction(currentTask, pages, setCurrentTask, hub
|
|
|
34
33
|
onPageChange(_models.FormPages.CYA, state);
|
|
35
34
|
}
|
|
36
35
|
} else if (task.state === _models.TaskStates.TYPES.IN_PROGRESS && !task.alwaysShowFirstPage) {
|
|
37
|
-
|
|
36
|
+
const currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
38
37
|
/* eslint-enable prefer-destructuring */
|
|
39
|
-
onPageChange(
|
|
38
|
+
onPageChange(currentPage || currentTask.pages[0], state);
|
|
40
39
|
} else if (task.firstPage) {
|
|
41
40
|
onPageChange(task.firstPage, state);
|
|
42
41
|
} else {
|
|
@@ -3,40 +3,37 @@
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
5
5
|
var _onTaskAction = _interopRequireDefault(require("./onTaskAction"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperty(
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
13
|
-
jest.mock('./helpers',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var setCurrentTaskArgs = [];
|
|
29
|
-
var mockSetCurrentTask = function mockSetCurrentTask(task) {
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
+
jest.mock('./helpers', () => ({
|
|
13
|
+
getPageArgs: [],
|
|
14
|
+
getPage(page, pages) {
|
|
15
|
+
this.getPageArgs.push({
|
|
16
|
+
page,
|
|
17
|
+
pages
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
reset() {
|
|
21
|
+
this.getPageArgs = [];
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
describe('components.FormRenderer.onTaskAction', () => {
|
|
25
|
+
let setCurrentTaskArgs = [];
|
|
26
|
+
const mockSetCurrentTask = task => {
|
|
30
27
|
setCurrentTaskArgs.push(task);
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
let onPageChangeArgs = [];
|
|
30
|
+
const mockOnPageChange = (page, state) => {
|
|
34
31
|
onPageChangeArgs.push({
|
|
35
|
-
page
|
|
36
|
-
state
|
|
32
|
+
page,
|
|
33
|
+
state
|
|
37
34
|
});
|
|
38
35
|
};
|
|
39
|
-
|
|
36
|
+
const PAGES = [{
|
|
40
37
|
id: 'page1'
|
|
41
38
|
}, {
|
|
42
39
|
id: 'page2'
|
|
@@ -45,7 +42,7 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
45
42
|
}, {
|
|
46
43
|
id: 'customCya'
|
|
47
44
|
}];
|
|
48
|
-
|
|
45
|
+
const DATA = {
|
|
49
46
|
formStatus: {
|
|
50
47
|
tasks: {
|
|
51
48
|
task1: {
|
|
@@ -58,7 +55,7 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
|
-
|
|
58
|
+
const ARGS = {
|
|
62
59
|
currentTask: null,
|
|
63
60
|
pages: PAGES,
|
|
64
61
|
setCurrentTask: mockSetCurrentTask,
|
|
@@ -66,31 +63,31 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
66
63
|
data: DATA,
|
|
67
64
|
onPageChange: mockOnPageChange
|
|
68
65
|
};
|
|
69
|
-
|
|
66
|
+
const genericChecks = currentTask => {
|
|
70
67
|
expect(_helpers.default.getPageArgs.length).toEqual(currentTask.pages.length);
|
|
71
68
|
expect(currentTask.fullPages.length).toEqual(currentTask.pages.length);
|
|
72
69
|
expect(setCurrentTaskArgs.length).toEqual(1);
|
|
73
70
|
expect(setCurrentTaskArgs[0]).toEqual(currentTask);
|
|
74
71
|
};
|
|
75
|
-
beforeEach(
|
|
72
|
+
beforeEach(() => {
|
|
76
73
|
setCurrentTaskArgs = [];
|
|
77
74
|
onPageChangeArgs = [];
|
|
78
75
|
_helpers.default.reset();
|
|
79
76
|
});
|
|
80
|
-
it('should do nothing if currentTask is null',
|
|
77
|
+
it('should do nothing if currentTask is null', () => {
|
|
81
78
|
_onTaskAction.default.apply(void 0, Object.values(ARGS));
|
|
82
79
|
expect(_helpers.default.getPageArgs.length).toEqual(0);
|
|
83
80
|
expect(setCurrentTaskArgs.length).toEqual(0);
|
|
84
81
|
expect(onPageChangeArgs.length).toEqual(0);
|
|
85
82
|
});
|
|
86
|
-
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.COMPLETE),
|
|
87
|
-
|
|
83
|
+
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.COMPLETE), () => {
|
|
84
|
+
const TASK = {
|
|
88
85
|
name: 'task1',
|
|
89
86
|
state: _models.TaskStates.TYPES.COMPLETE,
|
|
90
87
|
pages: ['page1', 'page2', 'page3']
|
|
91
88
|
};
|
|
92
|
-
it('should handle task CYAs not being shown',
|
|
93
|
-
|
|
89
|
+
it('should handle task CYAs not being shown', () => {
|
|
90
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
94
91
|
currentTask: TASK,
|
|
95
92
|
hubDetails: {
|
|
96
93
|
noTaskCYAs: true
|
|
@@ -101,8 +98,8 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
101
98
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
102
99
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
103
100
|
});
|
|
104
|
-
it('should handle task CYAs not being shown and no pages being provided on currentTask',
|
|
105
|
-
|
|
101
|
+
it('should handle task CYAs not being shown and no pages being provided on currentTask', () => {
|
|
102
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
106
103
|
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
107
104
|
pages: []
|
|
108
105
|
}),
|
|
@@ -115,8 +112,8 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
115
112
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
116
113
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.data.formStatus.tasks[CUSTOM_ARGS.currentTask.name].currentPage);
|
|
117
114
|
});
|
|
118
|
-
it('should handle a custom CYA being provided',
|
|
119
|
-
|
|
115
|
+
it('should handle a custom CYA being provided', () => {
|
|
116
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
120
117
|
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
121
118
|
customCYA: 'customCya'
|
|
122
119
|
})
|
|
@@ -126,8 +123,8 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
126
123
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
127
124
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.customCYA);
|
|
128
125
|
});
|
|
129
|
-
it('should handle navigation to a normal CYA page',
|
|
130
|
-
|
|
126
|
+
it('should handle navigation to a normal CYA page', () => {
|
|
127
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
131
128
|
currentTask: TASK
|
|
132
129
|
});
|
|
133
130
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -137,14 +134,14 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
137
134
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
138
135
|
});
|
|
139
136
|
});
|
|
140
|
-
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.IN_PROGRESS),
|
|
141
|
-
it('should handle page change when formStatus has a current page for the task',
|
|
142
|
-
|
|
137
|
+
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.IN_PROGRESS), () => {
|
|
138
|
+
it('should handle page change when formStatus has a current page for the task', () => {
|
|
139
|
+
const TASK = {
|
|
143
140
|
name: 'task1',
|
|
144
141
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
145
142
|
pages: ['page1', 'page2', 'page3']
|
|
146
143
|
};
|
|
147
|
-
|
|
144
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
148
145
|
currentTask: TASK
|
|
149
146
|
});
|
|
150
147
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -153,13 +150,13 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
153
150
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.data.formStatus.tasks[CUSTOM_ARGS.currentTask.name].currentPage);
|
|
154
151
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
155
152
|
});
|
|
156
|
-
it('should handle page change when formStatus does not have a current page for the task',
|
|
157
|
-
|
|
153
|
+
it('should handle page change when formStatus does not have a current page for the task', () => {
|
|
154
|
+
const TASK = {
|
|
158
155
|
name: 'taskNoCurrentPage',
|
|
159
156
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
160
157
|
pages: ['page1', 'page2', 'page3']
|
|
161
158
|
};
|
|
162
|
-
|
|
159
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
163
160
|
currentTask: TASK
|
|
164
161
|
});
|
|
165
162
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -168,15 +165,15 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
168
165
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
169
166
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
170
167
|
});
|
|
171
|
-
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress',
|
|
172
|
-
|
|
168
|
+
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', () => {
|
|
169
|
+
const TASK = {
|
|
173
170
|
name: 'taskalwaysShowFirstPageInProgress',
|
|
174
171
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
175
172
|
firstPage: 'page2',
|
|
176
173
|
alwaysShowFirstPage: true,
|
|
177
174
|
pages: ['page1', 'page2', 'page3']
|
|
178
175
|
};
|
|
179
|
-
|
|
176
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
180
177
|
currentTask: TASK
|
|
181
178
|
});
|
|
182
179
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -185,15 +182,15 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
185
182
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[1]);
|
|
186
183
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
187
184
|
});
|
|
188
|
-
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress',
|
|
189
|
-
|
|
185
|
+
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', () => {
|
|
186
|
+
const TASK = {
|
|
190
187
|
name: 'taskalwaysShowFirstPageComplete',
|
|
191
188
|
state: _models.TaskStates.TYPES.COMPLETE,
|
|
192
189
|
firstPage: 'page2',
|
|
193
190
|
alwaysShowFirstPage: true,
|
|
194
191
|
pages: ['page1', 'page2', 'page3']
|
|
195
192
|
};
|
|
196
|
-
|
|
193
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
197
194
|
currentTask: TASK
|
|
198
195
|
});
|
|
199
196
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -203,18 +200,16 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
203
200
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
204
201
|
});
|
|
205
202
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
describe("when currentTask has a state of ".concat(state), function () {
|
|
211
|
-
var TASK = {
|
|
203
|
+
const otherStates = Object.values(_models.TaskStates.TYPES).filter(t => t !== _models.TaskStates.TYPES.IN_PROGRESS && t !== _models.TaskStates.TYPES.COMPLETE);
|
|
204
|
+
otherStates.forEach(state => {
|
|
205
|
+
describe("when currentTask has a state of ".concat(state), () => {
|
|
206
|
+
const TASK = {
|
|
212
207
|
name: 'task1',
|
|
213
|
-
state
|
|
208
|
+
state,
|
|
214
209
|
pages: ['page1', 'page2', 'page3']
|
|
215
210
|
};
|
|
216
|
-
it('should handle the task having a specific first page defined',
|
|
217
|
-
|
|
211
|
+
it('should handle the task having a specific first page defined', () => {
|
|
212
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
218
213
|
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
219
214
|
firstPage: 'page2'
|
|
220
215
|
})
|
|
@@ -225,8 +220,8 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
225
220
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.firstPage);
|
|
226
221
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
227
222
|
});
|
|
228
|
-
it('should handle the task having the first page defined as null',
|
|
229
|
-
|
|
223
|
+
it('should handle the task having the first page defined as null', () => {
|
|
224
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
230
225
|
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
231
226
|
firstPage: null
|
|
232
227
|
})
|
|
@@ -237,8 +232,8 @@ describe('components.FormRenderer.onTaskAction', function () {
|
|
|
237
232
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
238
233
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
239
234
|
});
|
|
240
|
-
it('should handle the task not having a specific first page defined',
|
|
241
|
-
|
|
235
|
+
it('should handle the task not having a specific first page defined', () => {
|
|
236
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
242
237
|
currentTask: TASK
|
|
243
238
|
});
|
|
244
239
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -8,19 +8,21 @@ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _models = require("../../models");
|
|
11
|
-
|
|
11
|
+
const _excluded = ["action", "onAction"]; // Global imports
|
|
12
12
|
// Local imports
|
|
13
|
-
function _interopRequireDefault(
|
|
14
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
15
|
-
function _objectWithoutProperties(
|
|
16
|
-
function _objectWithoutPropertiesLoose(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
const DEFAULT_LABEL = exports.DEFAULT_LABEL = 'Continue';
|
|
18
|
+
const ActionButton = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
action: _action,
|
|
21
|
+
onAction
|
|
22
|
+
} = _ref,
|
|
21
23
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const action = typeof _action === 'string' ? _models.PageAction.DEFAULTS[_action] : _action;
|
|
25
|
+
const actionLabel = _models.PageAction.DEFAULTS[_action.type];
|
|
24
26
|
if (!action) {
|
|
25
27
|
return null;
|
|
26
28
|
}
|
|
@@ -29,9 +31,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
29
31
|
classModifiers: action.classModifiers,
|
|
30
32
|
start: action.start || false,
|
|
31
33
|
name: action.label,
|
|
32
|
-
onClick: action.disabled ?
|
|
33
|
-
return onAction(action);
|
|
34
|
-
}
|
|
34
|
+
onClick: action.disabled ? () => {} : () => onAction(action)
|
|
35
35
|
}), action.label || (actionLabel === null || actionLabel === void 0 ? void 0 : actionLabel.label) || DEFAULT_LABEL);
|
|
36
36
|
};
|
|
37
37
|
ActionButton.propTypes = {
|
|
@@ -1,94 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
var _react = require("@testing-library/react");
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
5
|
var _models = require("../../models");
|
|
7
6
|
var _ActionButton = _interopRequireWildcard(require("./ActionButton"));
|
|
8
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
10
|
-
function _interopRequireDefault(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // Global imports
|
|
7
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
// Global imports
|
|
11
|
+
|
|
14
12
|
// Local imports
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
describe('components', () => {
|
|
15
|
+
describe('PageActions.ActionButton', () => {
|
|
16
|
+
const ON_ACTION_CALLS = [];
|
|
17
|
+
const ON_ACTION = action => {
|
|
19
18
|
ON_ACTION_CALLS.push(action);
|
|
20
19
|
};
|
|
21
|
-
beforeEach(
|
|
20
|
+
beforeEach(() => {
|
|
22
21
|
ON_ACTION_CALLS.length = 0;
|
|
23
22
|
});
|
|
24
|
-
it('should handle an unknown action identifier',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
case 0:
|
|
46
|
-
ACTION = _models.PageAction.TYPES.SUBMIT;
|
|
47
|
-
_render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
48
|
-
action: ACTION,
|
|
49
|
-
onAction: ON_ACTION
|
|
50
|
-
})), container = _render2.container;
|
|
51
|
-
button = container.childNodes[0];
|
|
52
|
-
expect(button.tagName).toEqual('BUTTON');
|
|
53
|
-
expect(button.textContent).toEqual(_ActionButton.DEFAULT_LABEL);
|
|
23
|
+
it('should handle an unknown action identifier', async () => {
|
|
24
|
+
const ACTION = 'unknown';
|
|
25
|
+
const {
|
|
26
|
+
container
|
|
27
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
28
|
+
action: ACTION,
|
|
29
|
+
onAction: ON_ACTION
|
|
30
|
+
}));
|
|
31
|
+
expect(container.childNodes.length).toEqual(0);
|
|
32
|
+
});
|
|
33
|
+
it('should appropriately display a submit action', async () => {
|
|
34
|
+
const ACTION = _models.PageAction.TYPES.SUBMIT;
|
|
35
|
+
const {
|
|
36
|
+
container
|
|
37
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
38
|
+
action: ACTION,
|
|
39
|
+
onAction: ON_ACTION
|
|
40
|
+
}));
|
|
41
|
+
const button = container.childNodes[0];
|
|
42
|
+
expect(button.tagName).toEqual('BUTTON');
|
|
43
|
+
expect(button.textContent).toEqual(_ActionButton.DEFAULT_LABEL);
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
76
|
-
action: ACTION,
|
|
77
|
-
onAction: ON_ACTION
|
|
78
|
-
})), container = _render3.container;
|
|
79
|
-
button = container.childNodes[0];
|
|
80
|
-
expect(button.tagName).toEqual('BUTTON');
|
|
81
|
-
expect(button.textContent).toEqual(ACTION.label);
|
|
45
|
+
// Click the button and make sure it fires the onAction handler.
|
|
46
|
+
_react.fireEvent.click(button, {});
|
|
47
|
+
expect(ON_ACTION_CALLS.length).toEqual(1);
|
|
48
|
+
expect(ON_ACTION_CALLS[0]).toEqual(_models.PageAction.DEFAULTS.submit);
|
|
49
|
+
});
|
|
50
|
+
it('should appropriately display a custom action', async () => {
|
|
51
|
+
const ACTION = {
|
|
52
|
+
type: 'navigate',
|
|
53
|
+
url: '/alpha',
|
|
54
|
+
label: 'Alpha'
|
|
55
|
+
};
|
|
56
|
+
const {
|
|
57
|
+
container
|
|
58
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
59
|
+
action: ACTION,
|
|
60
|
+
onAction: ON_ACTION
|
|
61
|
+
}));
|
|
62
|
+
const button = container.childNodes[0];
|
|
63
|
+
expect(button.tagName).toEqual('BUTTON');
|
|
64
|
+
expect(button.textContent).toEqual(ACTION.label);
|
|
82
65
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case "end":
|
|
89
|
-
return _context3.stop();
|
|
90
|
-
}
|
|
91
|
-
}, _callee3);
|
|
92
|
-
})));
|
|
66
|
+
// Click the button and make sure it fires the onAction handler.
|
|
67
|
+
_react.fireEvent.click(button, {});
|
|
68
|
+
expect(ON_ACTION_CALLS.length).toEqual(1);
|
|
69
|
+
expect(ON_ACTION_CALLS[0]).toEqual(ACTION);
|
|
70
|
+
});
|
|
93
71
|
});
|
|
94
72
|
});
|
|
@@ -8,24 +8,24 @@ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _ActionButton = _interopRequireDefault(require("./ActionButton"));
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
// Global imports
|
|
13
13
|
|
|
14
14
|
// Local imports
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const PageActions = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
actions,
|
|
19
|
+
onAction
|
|
20
|
+
} = _ref;
|
|
19
21
|
if (!actions || actions.length === 0) {
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
22
|
-
return /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, null, actions.map(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}));
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, null, actions.map((action, index) => /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
25
|
+
key: index,
|
|
26
|
+
action: action,
|
|
27
|
+
onAction: onAction
|
|
28
|
+
})));
|
|
29
29
|
};
|
|
30
30
|
PageActions.propTypes = {
|
|
31
31
|
actions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({}), _propTypes.default.string])).isRequired,
|