@ukhomeoffice/cop-react-form-renderer 6.5.1-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.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +73 -63
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +80 -76
- package/dist/components/CollectionSummary/CollectionSummary.js +97 -107
- package/dist/components/CollectionSummary/CollectionSummary.test.js +152 -142
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +45 -51
- package/dist/components/CollectionSummary/RenderListView.test.js +78 -77
- package/dist/components/CollectionSummary/SummaryCard.js +104 -135
- package/dist/components/CollectionSummary/SummaryCard.test.js +930 -962
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -71
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +128 -135
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +30 -35
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -74
- package/dist/components/FormComponent/Collection.js +74 -108
- package/dist/components/FormComponent/Collection.test.js +909 -1081
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +69 -72
- 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.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +143 -179
- 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 +44 -47
- package/dist/components/FormRenderer/onPageAction.test.js +223 -213
- 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.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.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 +43 -94
- package/dist/context/ValidationContext/ValidationContext.test.js +56 -68
- 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 +26 -39
- 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 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +55 -26
- 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 +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +20 -22
- package/dist/utils/CollectionPage/getQuickEditPage.js +36 -28
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +1 -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 +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- 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 +16 -25
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- 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 +24 -30
- package/dist/utils/Data/getOptions.test.js +27 -27
- 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 +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- 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 +15 -20
- package/dist/utils/Validate/validateContainer.test.js +58 -52
- 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 +19 -22
- package/dist/utils/Validate/validatePage.test.js +215 -203
- 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 +2 -2
- 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/cop-airpax-after.json +0 -429
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +0 -449
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +0 -516
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +0 -593
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +0 -84
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +0 -98
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +0 -9158
- 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/clear-uncompleted-routes/test-data/test.json +0 -1605
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +0 -205
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -206
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -143
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -26
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -4,22 +4,20 @@ var _models = require("../../../models");
|
|
|
4
4
|
var _PageAction = require("../../../models/PageAction");
|
|
5
5
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
describe('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
describe('getSubmissionStatus', function () {
|
|
15
|
-
var OPTIONS = [{
|
|
7
|
+
// Local imports
|
|
8
|
+
|
|
9
|
+
describe('components', () => {
|
|
10
|
+
describe('FormRenderer', () => {
|
|
11
|
+
describe('helpers', () => {
|
|
12
|
+
describe('getSubmissionStatus', () => {
|
|
13
|
+
const OPTIONS = [{
|
|
16
14
|
value: 'romeo',
|
|
17
15
|
label: 'Romeo'
|
|
18
16
|
}, {
|
|
19
17
|
value: 'juliet',
|
|
20
18
|
label: 'Juliet'
|
|
21
19
|
}];
|
|
22
|
-
|
|
20
|
+
const RADIOS = {
|
|
23
21
|
id: 'radios',
|
|
24
22
|
fieldId: 'radios',
|
|
25
23
|
type: _models.ComponentTypes.RADIOS,
|
|
@@ -27,29 +25,29 @@ describe('components', function () {
|
|
|
27
25
|
options: OPTIONS
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
const TEXT = {
|
|
31
29
|
id: 'text',
|
|
32
30
|
fieldId: 'text',
|
|
33
31
|
type: _models.ComponentTypes.TEXT
|
|
34
32
|
};
|
|
35
|
-
|
|
33
|
+
const HTML = {
|
|
36
34
|
type: _models.ComponentTypes.HTML,
|
|
37
35
|
content: 'HTML'
|
|
38
36
|
};
|
|
39
|
-
|
|
37
|
+
const SHOW_WHEN_JULIET = {
|
|
40
38
|
field: RADIOS.fieldId,
|
|
41
39
|
op: '=',
|
|
42
40
|
value: OPTIONS[1].value
|
|
43
41
|
};
|
|
44
|
-
|
|
42
|
+
const SHOW_WHEN_ROMEO = {
|
|
45
43
|
field: RADIOS.fieldId,
|
|
46
44
|
op: '=',
|
|
47
45
|
value: OPTIONS[0].value
|
|
48
46
|
};
|
|
49
|
-
|
|
47
|
+
const FORM_DATA = {
|
|
50
48
|
radios: OPTIONS[0].value
|
|
51
49
|
}; // 'romeo'
|
|
52
|
-
|
|
50
|
+
const PAGES = [{
|
|
53
51
|
id: 'alpha'
|
|
54
52
|
}, {
|
|
55
53
|
id: 'bravo'
|
|
@@ -68,18 +66,18 @@ describe('components', function () {
|
|
|
68
66
|
components: [TEXT],
|
|
69
67
|
show_when: SHOW_WHEN_ROMEO
|
|
70
68
|
}];
|
|
71
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"),
|
|
72
|
-
it('should return undefined if the action has no page property',
|
|
73
|
-
|
|
69
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"), () => {
|
|
70
|
+
it('should return undefined if the action has no page property', () => {
|
|
71
|
+
const ACTION = {
|
|
74
72
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
75
73
|
};
|
|
76
74
|
expect((0, _getSubmissionStatus.default)(_models.FormTypes.HUB, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
77
75
|
page: undefined
|
|
78
76
|
});
|
|
79
77
|
});
|
|
80
|
-
it('should return the page on the action if it exists among the pages',
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
it('should return the page on the action if it exists among the pages', () => {
|
|
79
|
+
const PAGE = PAGES[1].id;
|
|
80
|
+
const ACTION = {
|
|
83
81
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
84
82
|
page: PAGE
|
|
85
83
|
};
|
|
@@ -87,9 +85,9 @@ describe('components', function () {
|
|
|
87
85
|
page: PAGE
|
|
88
86
|
});
|
|
89
87
|
});
|
|
90
|
-
it('should return undefined if the page on the action does not exist among the pages',
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
it('should return undefined if the page on the action does not exist among the pages', () => {
|
|
89
|
+
const PAGE = 'golf';
|
|
90
|
+
const ACTION = {
|
|
93
91
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
94
92
|
page: PAGE
|
|
95
93
|
};
|
|
@@ -98,11 +96,11 @@ describe('components', function () {
|
|
|
98
96
|
});
|
|
99
97
|
});
|
|
100
98
|
});
|
|
101
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"),
|
|
102
|
-
Object.values(_models.FormTypes).forEach(
|
|
99
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), () => {
|
|
100
|
+
Object.values(_models.FormTypes).forEach(formType => {
|
|
103
101
|
if (formType !== _models.FormTypes.TASK && formType !== _models.FormTypes.FORM_WITH_TASK) {
|
|
104
|
-
it("should return the current page if the form type is '".concat(formType, "'"),
|
|
105
|
-
|
|
102
|
+
it("should return the current page if the form type is '".concat(formType, "'"), () => {
|
|
103
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndReturn;
|
|
106
104
|
expect((0, _getSubmissionStatus.default)(formType, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
107
105
|
page: PAGES[0].id
|
|
108
106
|
});
|
|
@@ -110,15 +108,15 @@ describe('components', function () {
|
|
|
110
108
|
}
|
|
111
109
|
});
|
|
112
110
|
});
|
|
113
|
-
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"),
|
|
114
|
-
|
|
115
|
-
it("should return '".concat(_models.FormPages.HUB, "' by default"),
|
|
111
|
+
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"), () => {
|
|
112
|
+
const FORM_TYPE = _models.FormTypes.HUB;
|
|
113
|
+
it("should return '".concat(_models.FormPages.HUB, "' by default"), () => {
|
|
116
114
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
117
115
|
page: _models.FormPages.HUB
|
|
118
116
|
});
|
|
119
117
|
});
|
|
120
|
-
it('should return action.page if specified',
|
|
121
|
-
|
|
118
|
+
it('should return action.page if specified', () => {
|
|
119
|
+
const ACTION = {
|
|
122
120
|
page: 'bob'
|
|
123
121
|
};
|
|
124
122
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, undefined, ACTION, FORM_DATA)).toMatchObject({
|
|
@@ -126,63 +124,63 @@ describe('components', function () {
|
|
|
126
124
|
});
|
|
127
125
|
});
|
|
128
126
|
});
|
|
129
|
-
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
it('should return the first page by default',
|
|
127
|
+
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"), () => {
|
|
128
|
+
const FORM_TYPE = _models.FormTypes.CYA;
|
|
129
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
130
|
+
it('should return the first page by default', () => {
|
|
133
131
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, ACTION, FORM_DATA)).toMatchObject({
|
|
134
132
|
page: PAGES[0].id
|
|
135
133
|
});
|
|
136
134
|
});
|
|
137
|
-
it('should return the second page when on the first page',
|
|
135
|
+
it('should return the second page when on the first page', () => {
|
|
138
136
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
139
137
|
page: PAGES[1].id
|
|
140
138
|
});
|
|
141
139
|
});
|
|
142
|
-
it('should return the third page when on the second page',
|
|
140
|
+
it('should return the third page when on the second page', () => {
|
|
143
141
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[1].id, ACTION, FORM_DATA)).toMatchObject({
|
|
144
142
|
page: PAGES[2].id
|
|
145
143
|
});
|
|
146
144
|
});
|
|
147
|
-
it("should return the fifth page when on the third page because the fourth page show_when is not met",
|
|
145
|
+
it("should return the fifth page when on the third page because the fourth page show_when is not met", () => {
|
|
148
146
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[2].id, ACTION, FORM_DATA)).toMatchObject({
|
|
149
147
|
page: PAGES[4].id
|
|
150
148
|
});
|
|
151
149
|
});
|
|
152
|
-
it("should return the sixth page when on the fifth page because the sixth page show_when is met",
|
|
150
|
+
it("should return the sixth page when on the fifth page because the sixth page show_when is met", () => {
|
|
153
151
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[4].id, ACTION, FORM_DATA)).toMatchObject({
|
|
154
152
|
page: PAGES[5].id
|
|
155
153
|
});
|
|
156
154
|
});
|
|
157
|
-
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"),
|
|
158
|
-
|
|
155
|
+
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"), () => {
|
|
156
|
+
const lastPageIndex = PAGES.length - 1;
|
|
159
157
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[lastPageIndex].id, ACTION, FORM_DATA)).toMatchObject({
|
|
160
158
|
page: _models.FormPages.CYA
|
|
161
159
|
});
|
|
162
160
|
});
|
|
163
161
|
});
|
|
164
|
-
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"),
|
|
165
|
-
|
|
166
|
-
it('should return the first page by default',
|
|
162
|
+
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"), () => {
|
|
163
|
+
const FORM_TYPE = _models.FormTypes.WIZARD;
|
|
164
|
+
it('should return the first page by default', () => {
|
|
167
165
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
168
166
|
page: PAGES[0].id
|
|
169
167
|
});
|
|
170
168
|
});
|
|
171
|
-
it('should return the second page when on the first page',
|
|
169
|
+
it('should return the second page when on the first page', () => {
|
|
172
170
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id)).toMatchObject({
|
|
173
171
|
page: PAGES[1].id
|
|
174
172
|
});
|
|
175
173
|
});
|
|
176
|
-
it('should return undefined when on the last page',
|
|
174
|
+
it('should return undefined when on the last page', () => {
|
|
177
175
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[PAGES.length - 1].id)).toMatchObject({
|
|
178
176
|
page: undefined
|
|
179
177
|
});
|
|
180
178
|
});
|
|
181
179
|
});
|
|
182
|
-
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"),
|
|
183
|
-
|
|
184
|
-
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"),
|
|
185
|
-
|
|
180
|
+
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"), () => {
|
|
181
|
+
const FORM_TYPE = _models.FormTypes.FORM;
|
|
182
|
+
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), () => {
|
|
183
|
+
const ACTION = {
|
|
186
184
|
type: _models.PageAction.TYPES.SUBMIT,
|
|
187
185
|
nextPageId: 'bob'
|
|
188
186
|
};
|
|
@@ -199,91 +197,99 @@ describe('components', function () {
|
|
|
199
197
|
page: PAGES[0].id
|
|
200
198
|
});
|
|
201
199
|
});
|
|
202
|
-
it('should return undefined if there are no pages',
|
|
200
|
+
it('should return undefined if there are no pages', () => {
|
|
203
201
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, [])).toMatchObject({
|
|
204
202
|
page: undefined
|
|
205
203
|
});
|
|
206
204
|
});
|
|
207
205
|
});
|
|
208
|
-
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"),
|
|
209
|
-
|
|
210
|
-
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"), () => {
|
|
207
|
+
const FORM_TYPE = _models.FormTypes.TASK;
|
|
208
|
+
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"), () => {
|
|
209
|
+
const CURRENT_PAGE_ID = _models.FormPages.CYA;
|
|
210
|
+
const TASK_NAME = 'taskName';
|
|
211
|
+
const CURRENT_TASK = {
|
|
214
212
|
name: TASK_NAME
|
|
215
213
|
};
|
|
216
214
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, undefined, {}, CURRENT_TASK, true)).toMatchObject({
|
|
217
|
-
tasks:
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
tasks: {
|
|
216
|
+
[TASK_NAME]: {
|
|
217
|
+
complete: true
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
|
-
it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"), () => {
|
|
223
|
+
const CURRENT_PAGE_ID = 'eventDate';
|
|
224
|
+
const TASK_NAME = 'taskName';
|
|
225
|
+
const CURRENT_TASK = {
|
|
226
226
|
name: TASK_NAME
|
|
227
227
|
};
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const NEXT_PAGE_ID = 'eventMode';
|
|
229
|
+
const ACTION = {
|
|
230
230
|
type: _PageAction.PageActionTypes.SAVE_AND_NAVIGATE,
|
|
231
231
|
page: NEXT_PAGE_ID
|
|
232
232
|
};
|
|
233
233
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK)).toMatchObject({
|
|
234
|
-
tasks:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
tasks: {
|
|
235
|
+
[TASK_NAME]: {
|
|
236
|
+
complete: false,
|
|
237
|
+
currentPage: NEXT_PAGE_ID
|
|
238
|
+
}
|
|
239
|
+
}
|
|
238
240
|
});
|
|
239
241
|
});
|
|
240
|
-
it("should mark the current task as complete if the action indicates as much",
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
it("should mark the current task as complete if the action indicates as much", () => {
|
|
243
|
+
const CURRENT_PAGE_ID = PAGES[0].id;
|
|
244
|
+
const TASK_NAME = 'taskName';
|
|
245
|
+
const CURRENT_TASK = {
|
|
244
246
|
name: TASK_NAME,
|
|
245
247
|
pages: [CURRENT_PAGE_ID]
|
|
246
248
|
};
|
|
247
|
-
|
|
249
|
+
const ACTION = {
|
|
248
250
|
complete: true
|
|
249
251
|
};
|
|
250
252
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true)).toMatchObject({
|
|
251
|
-
tasks:
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
tasks: {
|
|
254
|
+
[TASK_NAME]: {
|
|
255
|
+
complete: true
|
|
256
|
+
}
|
|
257
|
+
}
|
|
254
258
|
});
|
|
255
259
|
});
|
|
256
|
-
it("should mark the current task as complete if the current task is a pre-task-list task",
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
+
it("should mark the current task as complete if the current task is a pre-task-list task", () => {
|
|
261
|
+
const CURRENT_PAGE_ID = PAGES[PAGES.length - 1].id;
|
|
262
|
+
const TASK_NAME = undefined;
|
|
263
|
+
const CURRENT_TASK = {
|
|
260
264
|
name: TASK_NAME
|
|
261
265
|
};
|
|
262
|
-
|
|
266
|
+
const ACTION = {
|
|
263
267
|
complete: true
|
|
264
268
|
};
|
|
265
|
-
|
|
269
|
+
const TASKS = [{
|
|
266
270
|
type: 'pre-task-list',
|
|
267
271
|
pages: PAGES
|
|
268
272
|
}];
|
|
269
|
-
|
|
273
|
+
const SECTIONS = [{
|
|
270
274
|
tasks: TASKS
|
|
271
275
|
}];
|
|
272
276
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true, SECTIONS)).toMatchObject({
|
|
273
|
-
tasks:
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
tasks: {
|
|
278
|
+
[TASK_NAME]: {
|
|
279
|
+
complete: true
|
|
280
|
+
}
|
|
281
|
+
}
|
|
276
282
|
});
|
|
277
283
|
});
|
|
278
|
-
it('should not update the current task state if the current page does not belong in the task',
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
it('should not update the current task state if the current page does not belong in the task', () => {
|
|
285
|
+
const CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
286
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
287
|
+
const CURRENT_TASK = {
|
|
282
288
|
name: 'test-task',
|
|
283
289
|
pages: ['page-a']
|
|
284
290
|
};
|
|
285
|
-
|
|
286
|
-
|
|
291
|
+
const CURRENT_PAGE_ID = 'page-b';
|
|
292
|
+
const CUSTOM_FORM_DATA = {
|
|
287
293
|
formStatus: {
|
|
288
294
|
tasks: {
|
|
289
295
|
'test-task': {
|
|
@@ -7,22 +7,20 @@ exports.default = void 0;
|
|
|
7
7
|
var _models = require("../../../models");
|
|
8
8
|
var _utils = _interopRequireDefault(require("../../../utils"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
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(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
10
|
+
// Local imports
|
|
11
|
+
|
|
16
12
|
/**
|
|
17
13
|
* @param {boolean} complete - true if task complete
|
|
18
14
|
* @param {boolean} currentPage - true if current page
|
|
19
15
|
* @param {TaskStates.TYPES|string} defaultState - default state to set task
|
|
20
16
|
* @returns {TaskStates.TYPES|string} current task state
|
|
21
17
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const getCurrentTaskState = function (_ref) {
|
|
19
|
+
let {
|
|
20
|
+
complete,
|
|
21
|
+
currentPage
|
|
22
|
+
} = _ref;
|
|
23
|
+
let defaultState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _models.TaskStates.TYPES.NOT_STARTED;
|
|
26
24
|
if (complete) {
|
|
27
25
|
return _models.TaskStates.TYPES.COMPLETE;
|
|
28
26
|
}
|
|
@@ -39,18 +37,18 @@ var getCurrentTaskState = function getCurrentTaskState(_ref) {
|
|
|
39
37
|
* @param {boolean} ignoreSkipped - skipped tasks don't need to have been completed
|
|
40
38
|
* @returns {boolean} true if dependent tasks complete
|
|
41
39
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return mustBeComplete.reduce(
|
|
45
|
-
|
|
40
|
+
const allDependentTasksComplete = function (taskStates, mustBeComplete) {
|
|
41
|
+
let ignoreSkipped = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
42
|
+
return mustBeComplete.reduce((allComplete, taskName) => {
|
|
43
|
+
const task = taskStates[taskName];
|
|
46
44
|
if (ignoreSkipped && (task === null || task === void 0 ? void 0 : task.state) === _models.TaskStates.TYPES.SKIPPED) {
|
|
47
45
|
return allComplete;
|
|
48
46
|
}
|
|
49
47
|
return allComplete && (task === null || task === void 0 ? void 0 : task.complete);
|
|
50
48
|
}, true);
|
|
51
49
|
};
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const isPreviousTaskComplete = (tasks, taskIndex) => {
|
|
51
|
+
const lastTaskState = tasks[taskIndex - 1].state;
|
|
54
52
|
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
55
53
|
return true;
|
|
56
54
|
}
|
|
@@ -71,9 +69,9 @@ var isPreviousTaskComplete = function isPreviousTaskComplete(tasks, taskIndex) {
|
|
|
71
69
|
* @returns {TYPES|string} new state
|
|
72
70
|
*/
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
const updateTaskState = function (task, taskIndex, taskList, taskStates) {
|
|
73
|
+
let nonSequential = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
74
|
+
let allowFirst = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
77
75
|
if (taskStates[task.name]) {
|
|
78
76
|
return getCurrentTaskState(taskStates[task.name], task.state);
|
|
79
77
|
}
|
|
@@ -83,7 +81,7 @@ var updateTaskState = function updateTaskState(task, taskIndex, taskList, taskSt
|
|
|
83
81
|
}
|
|
84
82
|
return _models.TaskStates.TYPES.NOT_STARTED;
|
|
85
83
|
}
|
|
86
|
-
|
|
84
|
+
let notStarted = allowFirst;
|
|
87
85
|
if (taskIndex) {
|
|
88
86
|
notStarted = isPreviousTaskComplete(taskList, taskIndex);
|
|
89
87
|
}
|
|
@@ -102,14 +100,12 @@ var updateTaskState = function updateTaskState(task, taskIndex, taskList, taskSt
|
|
|
102
100
|
* @param {boolean} allowFirst - true if first task can be started
|
|
103
101
|
* @returns {object} - updated section
|
|
104
102
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
clone.filter(
|
|
110
|
-
|
|
111
|
-
}).forEach(function (t, index) {
|
|
112
|
-
var task = t;
|
|
103
|
+
const updateTasks = (section, taskStates, nonSequential, allowFirst) => {
|
|
104
|
+
const clone = section.tasks.map(a => ({
|
|
105
|
+
...a
|
|
106
|
+
}));
|
|
107
|
+
clone.filter(t => t.state !== _models.TaskStates.TYPES.SKIPPED).forEach((t, index) => {
|
|
108
|
+
const task = t;
|
|
113
109
|
task.state = updateTaskState(task, index, clone, taskStates, nonSequential, allowFirst);
|
|
114
110
|
});
|
|
115
111
|
return clone;
|
|
@@ -124,9 +120,9 @@ var updateTasks = function updateTasks(section, taskStates, nonSequential, allow
|
|
|
124
120
|
* @returns {boolean} true if the last non-skipped section is complete, false
|
|
125
121
|
* if not.
|
|
126
122
|
*/
|
|
127
|
-
|
|
123
|
+
const isPreviousSectionComplete = (sections, currentIndex) => {
|
|
128
124
|
var _sections;
|
|
129
|
-
|
|
125
|
+
const lastTaskState = (_sections = sections[currentIndex - 1]) === null || _sections === void 0 || (_sections = _sections.tasks.slice(-1)[0]) === null || _sections === void 0 ? void 0 : _sections.state;
|
|
130
126
|
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
131
127
|
return true;
|
|
132
128
|
}
|
|
@@ -144,56 +140,62 @@ var isPreviousSectionComplete = function isPreviousSectionComplete(sections, cur
|
|
|
144
140
|
* @param {object} data - current form data
|
|
145
141
|
* @returns {object[]} - updated sections - note this is a clone
|
|
146
142
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
const getUpdatedSectionStates = function (sections, taskStates) {
|
|
144
|
+
let nonSequential = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
145
|
+
let data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
150
146
|
// Make a clone and handle any hidden sections.
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
const clone = sections.map(section => {
|
|
148
|
+
const showWhen = section.show_when ? [section.show_when].flat() : [];
|
|
153
149
|
if (data && !_utils.default.Condition.meetsAll(showWhen, data)) {
|
|
154
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
...section,
|
|
155
152
|
skipped: true,
|
|
156
|
-
tasks: section.tasks.map(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
153
|
+
tasks: section.tasks.map(task => ({
|
|
154
|
+
...task,
|
|
155
|
+
state: _models.TaskStates.TYPES.SKIPPED
|
|
156
|
+
}))
|
|
157
|
+
};
|
|
162
158
|
}
|
|
163
159
|
;
|
|
164
|
-
return
|
|
160
|
+
return {
|
|
161
|
+
...section
|
|
162
|
+
};
|
|
165
163
|
});
|
|
166
164
|
|
|
167
165
|
// Now iterate through the clone and handle any hidden tasks.
|
|
168
|
-
clone.forEach(
|
|
169
|
-
|
|
170
|
-
section.tasks = section.tasks.map(
|
|
171
|
-
|
|
166
|
+
clone.forEach(s => {
|
|
167
|
+
const section = s;
|
|
168
|
+
section.tasks = section.tasks.map(task => {
|
|
169
|
+
const showWhen = task.show_when ? [task.show_when].flat() : [];
|
|
172
170
|
if (data && !_utils.default.Condition.meetsAll(showWhen, data)) {
|
|
173
|
-
return
|
|
171
|
+
return {
|
|
172
|
+
...task,
|
|
174
173
|
state: _models.TaskStates.TYPES.SKIPPED
|
|
175
|
-
}
|
|
174
|
+
};
|
|
176
175
|
}
|
|
177
|
-
return
|
|
176
|
+
return {
|
|
177
|
+
...task
|
|
178
|
+
};
|
|
178
179
|
});
|
|
179
180
|
});
|
|
180
181
|
|
|
181
182
|
// Update the taskStates to account for skipped tasks.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
states[task.name] =
|
|
183
|
+
const states = {
|
|
184
|
+
...taskStates
|
|
185
|
+
};
|
|
186
|
+
clone.forEach(section => {
|
|
187
|
+
section.tasks.filter(t => t.state === _models.TaskStates.TYPES.SKIPPED).forEach(task => {
|
|
188
|
+
states[task.name] = {
|
|
189
|
+
...states[task.name],
|
|
188
190
|
state: _models.TaskStates.TYPES.SKIPPED
|
|
189
|
-
}
|
|
191
|
+
};
|
|
190
192
|
});
|
|
191
193
|
});
|
|
192
194
|
|
|
193
195
|
// Now figure out all the task states.
|
|
194
|
-
clone.forEach(
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
clone.forEach((s, index) => {
|
|
197
|
+
const section = s;
|
|
198
|
+
const allowFirst = index === 0 || isPreviousSectionComplete(clone, index);
|
|
197
199
|
section.tasks = updateTasks(section, states, nonSequential, allowFirst);
|
|
198
200
|
});
|
|
199
201
|
return clone;
|