@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
|
@@ -1,6 +1,5 @@
|
|
|
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");
|
|
@@ -8,16 +7,16 @@ var _setupTests = require("../../setupTests");
|
|
|
8
7
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
9
8
|
var _ActionButton = require("../PageActions/ActionButton");
|
|
10
9
|
var _FormPage = _interopRequireWildcard(require("./FormPage"));
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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
|
|
13
|
+
// Global imports
|
|
14
|
+
|
|
17
15
|
// Local imports
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
|
|
17
|
+
describe('components.FormPage', () => {
|
|
18
|
+
describe('FormPage', () => {
|
|
19
|
+
const TEXT = {
|
|
21
20
|
id: 'text',
|
|
22
21
|
fieldId: 'text',
|
|
23
22
|
type: 'text',
|
|
@@ -25,7 +24,7 @@ describe('components.FormPage', function () {
|
|
|
25
24
|
hint: 'Text hint'
|
|
26
25
|
};
|
|
27
26
|
// eslint-disable-next-line no-template-curly-in-string
|
|
28
|
-
|
|
27
|
+
const TEXT_WITH_EXPRESSION = {
|
|
29
28
|
id: 'text1',
|
|
30
29
|
fieldId: 'text1',
|
|
31
30
|
type: 'text',
|
|
@@ -33,7 +32,7 @@ describe('components.FormPage', function () {
|
|
|
33
32
|
hint: 'Text hint ${currentUser.givenName}'
|
|
34
33
|
};
|
|
35
34
|
// eslint-disable-next-line no-template-curly-in-string
|
|
36
|
-
|
|
35
|
+
const AUTO_WITH_EXPRESSION = {
|
|
37
36
|
id: 'text2',
|
|
38
37
|
fieldId: 'text2',
|
|
39
38
|
label: '${text2} ${currentUser.givenName}',
|
|
@@ -43,8 +42,8 @@ describe('components.FormPage', function () {
|
|
|
43
42
|
source: [],
|
|
44
43
|
disabled: false
|
|
45
44
|
};
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const VALUE = 'Text value';
|
|
46
|
+
const PAGE = {
|
|
48
47
|
id: 'pageId',
|
|
49
48
|
title: 'Page 1',
|
|
50
49
|
components: [TEXT],
|
|
@@ -53,7 +52,7 @@ describe('components.FormPage', function () {
|
|
|
53
52
|
text: VALUE
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
|
-
|
|
55
|
+
const PAGE_WITH_BUTTON_ACTIONS = {
|
|
57
56
|
id: 'pageId',
|
|
58
57
|
// eslint-disable-next-line no-template-curly-in-string
|
|
59
58
|
title: '${title}',
|
|
@@ -85,7 +84,7 @@ describe('components.FormPage', function () {
|
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
};
|
|
88
|
-
|
|
87
|
+
const PAGE_WITH_CONDITIONAL_BUTTONS = {
|
|
89
88
|
id: 'pageId',
|
|
90
89
|
// eslint-disable-next-line no-template-curly-in-string
|
|
91
90
|
title: '${title}',
|
|
@@ -123,58 +122,56 @@ describe('components.FormPage', function () {
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
};
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
const ON_ACTION_CALLS = [];
|
|
126
|
+
const checkInputField = (formGroup, fieldId, lbl, hnt, val) => {
|
|
128
127
|
expect(formGroup.tagName).toEqual('DIV');
|
|
129
128
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
130
|
-
|
|
129
|
+
const label = formGroup.childNodes[0];
|
|
131
130
|
expect(label.tagName).toEqual('LABEL');
|
|
132
131
|
expect(label.classList).toContain('govuk-label');
|
|
133
132
|
expect(label.textContent).toEqual(lbl);
|
|
134
133
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
135
|
-
|
|
134
|
+
const hint = formGroup.childNodes[1];
|
|
136
135
|
expect(hint.tagName).toEqual('DIV');
|
|
137
136
|
expect(hint.classList).toContain('govuk-hint');
|
|
138
137
|
expect(hint.textContent).toEqual(hnt);
|
|
139
|
-
|
|
138
|
+
const input = formGroup.childNodes[2];
|
|
140
139
|
expect(input.tagName).toEqual('INPUT');
|
|
141
140
|
expect(input.classList).toContain('govuk-input');
|
|
142
141
|
expect(input.id).toEqual(fieldId);
|
|
143
142
|
expect(input.value).toEqual(val);
|
|
144
143
|
return input;
|
|
145
144
|
};
|
|
146
|
-
|
|
145
|
+
const checkAutoCompleteField = (formGroup, fieldId, lbl, hnt, val) => {
|
|
147
146
|
expect(formGroup.tagName).toEqual('DIV');
|
|
148
147
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
149
|
-
|
|
148
|
+
const label = formGroup.childNodes[0];
|
|
150
149
|
expect(label.tagName).toEqual('LABEL');
|
|
151
150
|
expect(label.classList).toContain('govuk-label');
|
|
152
151
|
expect(label.textContent).toEqual(lbl);
|
|
153
152
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
154
|
-
|
|
153
|
+
const hint = formGroup.childNodes[1];
|
|
155
154
|
expect(hint.tagName).toEqual('DIV');
|
|
156
155
|
expect(hint.classList).toContain('govuk-hint');
|
|
157
156
|
expect(hint.textContent).toEqual(hnt);
|
|
158
|
-
|
|
157
|
+
const outerWrapper = formGroup.childNodes[2];
|
|
159
158
|
expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
|
|
160
|
-
|
|
159
|
+
const autocomplete = outerWrapper.childNodes[0];
|
|
161
160
|
expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
|
|
162
|
-
|
|
163
|
-
return e.tagName === 'INPUT';
|
|
164
|
-
})[0];
|
|
161
|
+
const input = [].concat(autocomplete.childNodes).filter(e => e.tagName === 'INPUT')[0];
|
|
165
162
|
expect(input.classList).toContain('hods-autocomplete__input');
|
|
166
163
|
expect(input.tagName).toEqual('INPUT');
|
|
167
164
|
expect(input.id).toEqual(fieldId);
|
|
168
165
|
expect(input.value).toEqual(val);
|
|
169
166
|
return input;
|
|
170
167
|
};
|
|
171
|
-
|
|
168
|
+
const checkFormButtonGroup = (buttonGroup, labels) => {
|
|
172
169
|
var _buttonGroup$childNod;
|
|
173
|
-
|
|
170
|
+
const buttons = [];
|
|
174
171
|
expect(buttonGroup.tagName).toEqual('DIV');
|
|
175
172
|
expect(buttonGroup.classList).toContain('hods-button-group');
|
|
176
173
|
expect((_buttonGroup$childNod = buttonGroup.childNodes) === null || _buttonGroup$childNod === void 0 ? void 0 : _buttonGroup$childNod.length).toEqual(labels.length);
|
|
177
|
-
buttonGroup.childNodes.forEach(
|
|
174
|
+
buttonGroup.childNodes.forEach((button, i) => {
|
|
178
175
|
expect(button.tagName).toEqual('BUTTON');
|
|
179
176
|
expect(button.classList).toContain('hods-button');
|
|
180
177
|
expect(button.textContent).toEqual(labels[i]);
|
|
@@ -182,151 +179,118 @@ describe('components.FormPage', function () {
|
|
|
182
179
|
});
|
|
183
180
|
return buttons;
|
|
184
181
|
};
|
|
185
|
-
|
|
182
|
+
const ON_ACTION = (action, patch, onError) => {
|
|
186
183
|
ON_ACTION_CALLS.push({
|
|
187
|
-
action
|
|
188
|
-
patch
|
|
189
|
-
onError
|
|
184
|
+
action,
|
|
185
|
+
patch,
|
|
186
|
+
onError
|
|
190
187
|
});
|
|
191
188
|
};
|
|
192
|
-
beforeEach(
|
|
189
|
+
beforeEach(() => {
|
|
193
190
|
PAGE.formData = {
|
|
194
191
|
text: VALUE
|
|
195
192
|
};
|
|
196
193
|
ON_ACTION_CALLS.length = 0;
|
|
197
194
|
});
|
|
198
|
-
it('should render a submit page correctly',
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
195
|
+
it('should render a submit page correctly', async () => {
|
|
196
|
+
const {
|
|
197
|
+
container
|
|
198
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
199
|
+
page: PAGE,
|
|
200
|
+
onAction: ON_ACTION
|
|
201
|
+
}));
|
|
202
|
+
const page = container.childNodes[0];
|
|
203
|
+
expect(page.tagName).toEqual('DIV');
|
|
204
|
+
expect(page.classList).toContain(_FormPage.DEFAULT_CLASS);
|
|
205
|
+
const heading = page.childNodes[0];
|
|
206
|
+
expect(heading.classList).toContain('govuk-heading-l');
|
|
207
|
+
expect(heading.textContent).toEqual(_utils.default.FormPage.getTitle(PAGE.title, PAGE.formData));
|
|
208
|
+
checkInputField(page.childNodes[1], TEXT.fieldId, "".concat(TEXT.label, " (optional)"), TEXT.hint, VALUE);
|
|
209
|
+
checkFormButtonGroup(page.childNodes[2], [_ActionButton.DEFAULT_LABEL]);
|
|
210
|
+
});
|
|
211
|
+
it('should render a submit page correctly and submit action button has interpolated label', async () => {
|
|
212
|
+
const {
|
|
213
|
+
container
|
|
214
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
215
|
+
page: PAGE_WITH_BUTTON_ACTIONS,
|
|
216
|
+
onAction: ON_ACTION
|
|
217
|
+
}));
|
|
218
|
+
const page = container.childNodes[0];
|
|
219
|
+
const FORM_DATA = PAGE_WITH_BUTTON_ACTIONS.formData;
|
|
220
|
+
expect(page.tagName).toEqual('DIV');
|
|
221
|
+
expect(page.classList).toContain(_FormPage.DEFAULT_CLASS);
|
|
222
|
+
const heading = page.childNodes[0];
|
|
223
|
+
expect(heading.classList).toContain('govuk-heading-l');
|
|
224
|
+
expect(heading.textContent).toEqual(FORM_DATA.title);
|
|
225
|
+
checkInputField(page.childNodes[1], TEXT_WITH_EXPRESSION.fieldId, 'Email to test@example.email (optional)', 'Text hint Doe', 'Text1 Text value');
|
|
226
|
+
checkAutoCompleteField(page.childNodes[2], AUTO_WITH_EXPRESSION.fieldId, "".concat(FORM_DATA.text2, " ").concat(FORM_DATA.currentUser.givenName), FORM_DATA.wrapper.email, "Text2 ".concat(VALUE));
|
|
227
|
+
checkFormButtonGroup(page.childNodes[3], ['Next Payment', 'Go back User Details']);
|
|
228
|
+
});
|
|
229
|
+
it('should handle a page change appropriately', async () => {
|
|
230
|
+
const {
|
|
231
|
+
container
|
|
232
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
233
|
+
page: PAGE,
|
|
234
|
+
onAction: ON_ACTION
|
|
235
|
+
}));
|
|
236
|
+
const page = container.childNodes[0];
|
|
237
|
+
expect(page.tagName).toEqual('DIV');
|
|
238
|
+
|
|
239
|
+
// Change the input.
|
|
240
|
+
const input = page.childNodes[1].childNodes[2];
|
|
241
|
+
const NEW_VALUE = "".concat(VALUE, ".");
|
|
242
|
+
const EVENT = {
|
|
243
|
+
target: {
|
|
244
|
+
name: TEXT.fieldId,
|
|
245
|
+
value: NEW_VALUE
|
|
243
246
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
it('should handle a page change appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
247
|
-
var _renderWithValidation3, container, page, input, NEW_VALUE, EVENT;
|
|
248
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
249
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
250
|
-
case 0:
|
|
251
|
-
_renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
252
|
-
page: PAGE,
|
|
253
|
-
onAction: ON_ACTION
|
|
254
|
-
})), container = _renderWithValidation3.container;
|
|
255
|
-
page = container.childNodes[0];
|
|
256
|
-
expect(page.tagName).toEqual('DIV');
|
|
247
|
+
};
|
|
248
|
+
_react.fireEvent.change(input, EVENT);
|
|
257
249
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
250
|
+
// And confirm the formData has been changed.
|
|
251
|
+
expect(PAGE.formData.text).toEqual(NEW_VALUE);
|
|
252
|
+
});
|
|
253
|
+
it('should handle a page action appropriately', async () => {
|
|
254
|
+
const {
|
|
255
|
+
container
|
|
256
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
257
|
+
page: PAGE,
|
|
258
|
+
onAction: ON_ACTION
|
|
259
|
+
}));
|
|
260
|
+
const page = container.childNodes[0];
|
|
268
261
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
262
|
+
// Change the input.
|
|
263
|
+
const input = page.childNodes[1].childNodes[2];
|
|
264
|
+
const NEW_VALUE = "".concat(VALUE, ".");
|
|
265
|
+
const CHANGE_EVENT = {
|
|
266
|
+
target: {
|
|
267
|
+
name: TEXT.fieldId,
|
|
268
|
+
value: NEW_VALUE
|
|
274
269
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
it('should handle a page action appropriately', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
278
|
-
var _renderWithValidation4, container, page, input, NEW_VALUE, CHANGE_EVENT, button;
|
|
279
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
280
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
281
|
-
case 0:
|
|
282
|
-
_renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
283
|
-
page: PAGE,
|
|
284
|
-
onAction: ON_ACTION
|
|
285
|
-
})), container = _renderWithValidation4.container;
|
|
286
|
-
page = container.childNodes[0]; // Change the input.
|
|
287
|
-
input = page.childNodes[1].childNodes[2];
|
|
288
|
-
NEW_VALUE = "".concat(VALUE, ".");
|
|
289
|
-
CHANGE_EVENT = {
|
|
290
|
-
target: {
|
|
291
|
-
name: TEXT.fieldId,
|
|
292
|
-
value: NEW_VALUE
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
_react.fireEvent.change(input, CHANGE_EVENT);
|
|
270
|
+
};
|
|
271
|
+
_react.fireEvent.change(input, CHANGE_EVENT);
|
|
296
272
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
273
|
+
// Then click the action button.
|
|
274
|
+
const button = page.childNodes[2].childNodes[0];
|
|
275
|
+
_react.fireEvent.click(button, {});
|
|
300
276
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
_renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
320
|
-
page: PAGE_WITH_CONDITIONAL_BUTTONS,
|
|
321
|
-
onAction: ON_ACTION
|
|
322
|
-
})), container = _renderWithValidation5.container;
|
|
323
|
-
page = container.childNodes[0];
|
|
324
|
-
checkFormButtonGroup(page.childNodes[3], ['Button 2']); // Just the second button shown
|
|
325
|
-
case 3:
|
|
326
|
-
case "end":
|
|
327
|
-
return _context5.stop();
|
|
328
|
-
}
|
|
329
|
-
}, _callee5);
|
|
330
|
-
})));
|
|
277
|
+
// And confirm an appropriate action was received.
|
|
278
|
+
expect(ON_ACTION_CALLS.length).toEqual(1);
|
|
279
|
+
expect(PAGE.formData.text).toEqual(NEW_VALUE);
|
|
280
|
+
expect(ON_ACTION_CALLS[0].action).toEqual(_models.PageAction.DEFAULTS.submit);
|
|
281
|
+
expect(ON_ACTION_CALLS[0].patch).toEqual({
|
|
282
|
+
text: NEW_VALUE
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
it('should render only the conditionally shown button', async () => {
|
|
286
|
+
const {
|
|
287
|
+
container
|
|
288
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormPage.default, {
|
|
289
|
+
page: PAGE_WITH_CONDITIONAL_BUTTONS,
|
|
290
|
+
onAction: ON_ACTION
|
|
291
|
+
}));
|
|
292
|
+
const page = container.childNodes[0];
|
|
293
|
+
checkFormButtonGroup(page.childNodes[3], ['Button 2']); // Just the second button shown
|
|
294
|
+
});
|
|
331
295
|
});
|
|
332
296
|
});
|