@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +22 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
- package/dist/components/CollectionPage/CollectionPage.js +63 -73
- package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
- package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +52 -46
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +152 -110
- package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
- package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
- package/dist/components/FormComponent/Collection.js +108 -74
- package/dist/components/FormComponent/Collection.test.js +1081 -909
- package/dist/components/FormComponent/Container.js +39 -40
- package/dist/components/FormComponent/Container.test.js +412 -312
- package/dist/components/FormComponent/FormComponent.js +72 -69
- package/dist/components/FormComponent/FormComponent.test.js +414 -353
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- 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 +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- 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 +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +180 -143
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- 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 +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- 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 +97 -103
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +39 -43
- package/dist/components/FormRenderer/onPageAction.test.js +208 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +34 -21
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +226 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- 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 +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +92 -49
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +255 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +80 -57
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +94 -43
- package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- 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 +38 -44
- package/dist/models/TaskStates.js +28 -29
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +61 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +42 -0
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- 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 +18 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
- package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
- package/dist/utils/Component/getComponent.js +94 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +72 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +21 -22
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +6 -1
- package/dist/utils/Component/optionIsSelected.test.js +35 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- 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 +25 -16
- 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 +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +30 -24
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +4 -2
- package/dist/utils/FormPage/showFormPage.js +7 -3
- 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 +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -77
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +16 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- 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 +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- 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 +52 -46
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +9 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- 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 +27 -21
- 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 +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- 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 +4 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- 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 +4 -3
- 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 +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +21 -18
- package/dist/utils/Validate/validateComponent.test.js +176 -166
- package/dist/utils/Validate/validateContainer.js +20 -15
- package/dist/utils/Validate/validateContainer.test.js +52 -58
- package/dist/utils/Validate/validateDate.js +21 -15
- package/dist/utils/Validate/validateDate.test.js +32 -31
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +22 -19
- package/dist/utils/Validate/validatePage.test.js +203 -215
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +26 -11
- package/dist/utils/Validate/validateTime.test.js +62 -16
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -4,16 +4,19 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
4
4
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
5
5
|
var _setupTests = require("../../setupTests");
|
|
6
6
|
var _SummaryCardDetails = _interopRequireWildcard(require("./SummaryCardDetails"));
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
7
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
8
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
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); } // Global imports.
|
|
12
16
|
// Local imports.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const ENTRY = {
|
|
17
|
+
describe('components.CollectionSummary.SummaryCardDetails', function () {
|
|
18
|
+
var classes = _copReactComponents.Utils.classBuilder(_SummaryCardDetails.DEFAULT_CLASS, [], '');
|
|
19
|
+
var ENTRY = {
|
|
17
20
|
id: '001',
|
|
18
21
|
bannerText: 'A banner',
|
|
19
22
|
titleText: 'A title',
|
|
@@ -30,8 +33,8 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
30
33
|
childField2: 'bravo'
|
|
31
34
|
}]
|
|
32
35
|
};
|
|
33
|
-
it('should render sections and fields based on summaryLayout config', ()
|
|
34
|
-
|
|
36
|
+
it('should render sections and fields based on summaryLayout config', function () {
|
|
37
|
+
var CHILD_PAGES = [{
|
|
35
38
|
summaryLayout: {
|
|
36
39
|
sections: [{
|
|
37
40
|
title: 'Section 1',
|
|
@@ -55,35 +58,36 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
55
58
|
fieldId: 'fieldC'
|
|
56
59
|
}]
|
|
57
60
|
}];
|
|
58
|
-
|
|
61
|
+
var MASTER_PAGE = {
|
|
59
62
|
childPages: CHILD_PAGES
|
|
60
63
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}));
|
|
64
|
+
var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
65
|
+
masterPage: MASTER_PAGE,
|
|
66
|
+
childMasterPages: [],
|
|
67
|
+
formData: {},
|
|
68
|
+
entryData: ENTRY
|
|
69
|
+
})),
|
|
70
|
+
container = _renderWithValidation.container;
|
|
69
71
|
|
|
70
72
|
// Function to find an element by its text content
|
|
71
73
|
function getByTextContent(parent, text) {
|
|
72
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
74
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
75
|
+
return el.textContent === text;
|
|
76
|
+
});
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
// Check for section titles
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
81
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
78
82
|
expect(section1Title).not.toBeUndefined();
|
|
79
83
|
expect(section2Title).not.toBeUndefined();
|
|
80
|
-
|
|
84
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
81
85
|
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
82
|
-
|
|
86
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
83
87
|
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
84
88
|
});
|
|
85
|
-
it('should render sections containing containers based on summaryLayout config', ()
|
|
86
|
-
|
|
89
|
+
it('should render sections containing containers based on summaryLayout config', function () {
|
|
90
|
+
var CHILD_PAGES = [{
|
|
87
91
|
summaryLayout: {
|
|
88
92
|
sections: [{
|
|
89
93
|
title: 'Section 1',
|
|
@@ -108,7 +112,7 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
108
112
|
}]
|
|
109
113
|
}]
|
|
110
114
|
}];
|
|
111
|
-
|
|
115
|
+
var CONTAINER_ENTRY = {
|
|
112
116
|
id: '001',
|
|
113
117
|
bannerText: 'A banner',
|
|
114
118
|
titleText: 'A title',
|
|
@@ -121,29 +125,30 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
121
125
|
subThree: 'charlie'
|
|
122
126
|
}
|
|
123
127
|
};
|
|
124
|
-
|
|
128
|
+
var MASTER_PAGE = {
|
|
125
129
|
childPages: CHILD_PAGES
|
|
126
130
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}));
|
|
131
|
+
var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
132
|
+
masterPage: MASTER_PAGE,
|
|
133
|
+
childMasterPages: [],
|
|
134
|
+
formData: {},
|
|
135
|
+
entryData: CONTAINER_ENTRY
|
|
136
|
+
})),
|
|
137
|
+
container = _renderWithValidation2.container;
|
|
135
138
|
|
|
136
139
|
// Function to find an element by its text content
|
|
137
140
|
function getByTextContent(parent, text) {
|
|
138
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
141
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
142
|
+
return el.textContent === text;
|
|
143
|
+
});
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
// Check for section title
|
|
142
|
-
|
|
147
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
143
148
|
expect(section1Title).not.toBeUndefined();
|
|
144
149
|
|
|
145
150
|
// All three subcomponents from the container should have labels and values displayed
|
|
146
|
-
|
|
151
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
147
152
|
expect(section1Content.textContent).toContain('subOneLabel');
|
|
148
153
|
expect(section1Content.textContent).toContain('alpha');
|
|
149
154
|
expect(section1Content.textContent).toContain('subTwoLabel');
|
|
@@ -151,8 +156,96 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
151
156
|
expect(section1Content.textContent).toContain('subThreeLabel');
|
|
152
157
|
expect(section1Content.textContent).toContain('charlie');
|
|
153
158
|
});
|
|
154
|
-
it('should render sections
|
|
155
|
-
|
|
159
|
+
it('should render sections containing collections with dynamic titles based on summaryLayout config', function () {
|
|
160
|
+
var FORM_DATA = {
|
|
161
|
+
dummyTitleContent: "Kellogg's"
|
|
162
|
+
};
|
|
163
|
+
var CHILD_PAGES = [{
|
|
164
|
+
summaryLayout: {
|
|
165
|
+
sections: [{
|
|
166
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
167
|
+
title: 'Section 1 - ${dummyTitleContent}',
|
|
168
|
+
columns: [{
|
|
169
|
+
fields: ['collectionComponent']
|
|
170
|
+
}]
|
|
171
|
+
}]
|
|
172
|
+
},
|
|
173
|
+
formData: FORM_DATA,
|
|
174
|
+
components: [{
|
|
175
|
+
fieldId: 'collectionComponent',
|
|
176
|
+
id: 'collectionComponent',
|
|
177
|
+
type: 'collection',
|
|
178
|
+
label: 'Collection',
|
|
179
|
+
labels: {
|
|
180
|
+
item: 'north'
|
|
181
|
+
},
|
|
182
|
+
item: [{
|
|
183
|
+
id: 'north',
|
|
184
|
+
fieldId: 'north',
|
|
185
|
+
type: 'text',
|
|
186
|
+
label: 'North',
|
|
187
|
+
required: true
|
|
188
|
+
}, {
|
|
189
|
+
id: 'east',
|
|
190
|
+
fieldId: 'east',
|
|
191
|
+
type: 'text',
|
|
192
|
+
label: 'East',
|
|
193
|
+
required: true
|
|
194
|
+
}, {
|
|
195
|
+
id: 'south',
|
|
196
|
+
fieldId: 'south',
|
|
197
|
+
type: 'text',
|
|
198
|
+
label: 'South',
|
|
199
|
+
required: true
|
|
200
|
+
}, {
|
|
201
|
+
id: 'west',
|
|
202
|
+
fieldId: 'west',
|
|
203
|
+
type: 'text',
|
|
204
|
+
label: 'West',
|
|
205
|
+
required: true
|
|
206
|
+
}]
|
|
207
|
+
}]
|
|
208
|
+
}];
|
|
209
|
+
var COLLECTION_ENTRY = {
|
|
210
|
+
summaryText: 'Full details',
|
|
211
|
+
collectionComponent: [{
|
|
212
|
+
north: 'Never',
|
|
213
|
+
east: 'Eat',
|
|
214
|
+
south: 'Shredded',
|
|
215
|
+
west: 'Wheat'
|
|
216
|
+
}]
|
|
217
|
+
};
|
|
218
|
+
var MASTER_PAGE = {
|
|
219
|
+
childPages: CHILD_PAGES
|
|
220
|
+
};
|
|
221
|
+
var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
222
|
+
masterPage: MASTER_PAGE,
|
|
223
|
+
childMasterPages: [],
|
|
224
|
+
formData: {},
|
|
225
|
+
entryData: COLLECTION_ENTRY
|
|
226
|
+
})),
|
|
227
|
+
container = _renderWithValidation3.container;
|
|
228
|
+
|
|
229
|
+
// Check for section title
|
|
230
|
+
var section1Title = container.querySelector(".".concat(classes('section-title')));
|
|
231
|
+
expect(section1Title).not.toBeUndefined();
|
|
232
|
+
|
|
233
|
+
// Check for embedded variables in title
|
|
234
|
+
expect(section1Title.textContent).toEqual("Section 1 - Kellogg's");
|
|
235
|
+
|
|
236
|
+
// All four subcomponents from the container should have labels and values displayed
|
|
237
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
238
|
+
expect(section1Content.textContent).toContain('North');
|
|
239
|
+
expect(section1Content.textContent).toContain('Never');
|
|
240
|
+
expect(section1Content.textContent).toContain('East');
|
|
241
|
+
expect(section1Content.textContent).toContain('Eat');
|
|
242
|
+
expect(section1Content.textContent).toContain('South');
|
|
243
|
+
expect(section1Content.textContent).toContain('Shredded');
|
|
244
|
+
expect(section1Content.textContent).toContain('West');
|
|
245
|
+
expect(section1Content.textContent).toContain('Wheat');
|
|
246
|
+
});
|
|
247
|
+
it('should render sections if they have show_when checks and pass them', function () {
|
|
248
|
+
var CHILD_PAGES = [{
|
|
156
249
|
summaryLayout: {
|
|
157
250
|
sections: [{
|
|
158
251
|
title: 'Section 1',
|
|
@@ -181,39 +274,39 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
181
274
|
fieldId: 'fieldC'
|
|
182
275
|
}]
|
|
183
276
|
}];
|
|
184
|
-
|
|
277
|
+
var MASTER_PAGE = {
|
|
185
278
|
childPages: CHILD_PAGES
|
|
186
279
|
};
|
|
187
|
-
|
|
188
|
-
...ENTRY,
|
|
280
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
189
281
|
showSection1: true
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}));
|
|
282
|
+
});
|
|
283
|
+
var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
284
|
+
masterPage: MASTER_PAGE,
|
|
285
|
+
childMasterPages: [],
|
|
286
|
+
formData: {},
|
|
287
|
+
entryData: CUSTOM_ENTRY
|
|
288
|
+
})),
|
|
289
|
+
container = _renderWithValidation4.container;
|
|
199
290
|
|
|
200
291
|
// Function to find an element by its text content
|
|
201
292
|
function getByTextContent(parent, text) {
|
|
202
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
293
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
294
|
+
return el.textContent === text;
|
|
295
|
+
});
|
|
203
296
|
}
|
|
204
297
|
|
|
205
298
|
// Check for section titles
|
|
206
|
-
|
|
207
|
-
|
|
299
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
300
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
208
301
|
expect(section1Title).not.toBeUndefined();
|
|
209
302
|
expect(section2Title).not.toBeUndefined();
|
|
210
|
-
|
|
303
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
211
304
|
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
212
|
-
|
|
305
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
213
306
|
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
214
307
|
});
|
|
215
|
-
it('should not render sections if they have show_when checks and fail them', ()
|
|
216
|
-
|
|
308
|
+
it('should not render sections if they have show_when checks and fail them', function () {
|
|
309
|
+
var CHILD_PAGES = [{
|
|
217
310
|
summaryLayout: {
|
|
218
311
|
sections: [{
|
|
219
312
|
title: 'Section 1',
|
|
@@ -242,37 +335,37 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
242
335
|
fieldId: 'fieldC'
|
|
243
336
|
}]
|
|
244
337
|
}];
|
|
245
|
-
|
|
338
|
+
var MASTER_PAGE = {
|
|
246
339
|
childPages: CHILD_PAGES
|
|
247
340
|
};
|
|
248
|
-
|
|
249
|
-
...ENTRY,
|
|
341
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
250
342
|
showSection1: false
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}));
|
|
343
|
+
});
|
|
344
|
+
var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
345
|
+
masterPage: MASTER_PAGE,
|
|
346
|
+
childMasterPages: [],
|
|
347
|
+
formData: {},
|
|
348
|
+
entryData: CUSTOM_ENTRY
|
|
349
|
+
})),
|
|
350
|
+
container = _renderWithValidation5.container;
|
|
260
351
|
|
|
261
352
|
// Function to find an element by its text content
|
|
262
353
|
function getByTextContent(parent, text) {
|
|
263
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
354
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
355
|
+
return el.textContent === text;
|
|
356
|
+
});
|
|
264
357
|
}
|
|
265
358
|
|
|
266
359
|
// Check for section titles
|
|
267
|
-
|
|
268
|
-
|
|
360
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
361
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
269
362
|
expect(section1Title).toBeUndefined();
|
|
270
363
|
expect(section2Title).not.toBeUndefined();
|
|
271
|
-
|
|
364
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
272
365
|
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
273
366
|
});
|
|
274
|
-
it('should not render components that fail show_when checks', ()
|
|
275
|
-
|
|
367
|
+
it('should not render components that fail show_when checks', function () {
|
|
368
|
+
var CHILD_PAGES = [{
|
|
276
369
|
summaryLayout: {
|
|
277
370
|
sections: [{
|
|
278
371
|
title: 'Section 1',
|
|
@@ -301,36 +394,37 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
301
394
|
fieldId: 'fieldC'
|
|
302
395
|
}]
|
|
303
396
|
}];
|
|
304
|
-
|
|
397
|
+
var MASTER_PAGE = {
|
|
305
398
|
childPages: CHILD_PAGES
|
|
306
399
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}));
|
|
400
|
+
var _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
401
|
+
masterPage: MASTER_PAGE,
|
|
402
|
+
childMasterPages: [],
|
|
403
|
+
formData: {},
|
|
404
|
+
entryData: ENTRY
|
|
405
|
+
})),
|
|
406
|
+
container = _renderWithValidation6.container;
|
|
315
407
|
|
|
316
408
|
// Function to find an element by its text content
|
|
317
409
|
function getByTextContent(parent, text) {
|
|
318
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
410
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
411
|
+
return el.textContent === text;
|
|
412
|
+
});
|
|
319
413
|
}
|
|
320
414
|
|
|
321
415
|
// Check for section titles
|
|
322
|
-
|
|
323
|
-
|
|
416
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
417
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
324
418
|
expect(section1Title).not.toBeUndefined();
|
|
325
419
|
expect(section2Title).not.toBeUndefined();
|
|
326
|
-
|
|
420
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
327
421
|
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1); // Just Field A, Field B should be hidden.
|
|
328
422
|
|
|
329
|
-
|
|
423
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
330
424
|
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
331
425
|
});
|
|
332
|
-
it('should not render sections on pages that fail show_when checks', ()
|
|
333
|
-
|
|
426
|
+
it('should not render sections on pages that fail show_when checks', function () {
|
|
427
|
+
var CHILD_PAGES = [{
|
|
334
428
|
show_when: [{
|
|
335
429
|
field: 'testField',
|
|
336
430
|
op: '=',
|
|
@@ -364,37 +458,88 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
364
458
|
fieldId: 'fieldC'
|
|
365
459
|
}]
|
|
366
460
|
}];
|
|
367
|
-
|
|
461
|
+
var MASTER_PAGE = {
|
|
368
462
|
childPages: CHILD_PAGES
|
|
369
463
|
};
|
|
370
|
-
|
|
371
|
-
...ENTRY,
|
|
464
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
372
465
|
showSection1: false
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
}));
|
|
466
|
+
});
|
|
467
|
+
var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
468
|
+
masterPage: MASTER_PAGE,
|
|
469
|
+
childMasterPages: [],
|
|
470
|
+
formData: {
|
|
471
|
+
testField: false
|
|
472
|
+
},
|
|
473
|
+
entryData: CUSTOM_ENTRY
|
|
474
|
+
})),
|
|
475
|
+
container = _renderWithValidation7.container;
|
|
384
476
|
|
|
385
477
|
// Function to find an element by its text content
|
|
386
478
|
function getByTextContent(parent, text) {
|
|
387
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
479
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
480
|
+
return el.textContent === text;
|
|
481
|
+
});
|
|
388
482
|
}
|
|
389
483
|
|
|
390
484
|
// Check for section titles
|
|
391
|
-
|
|
392
|
-
|
|
485
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
486
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
393
487
|
expect(section1Title).toBeUndefined();
|
|
394
488
|
expect(section2Title).toBeUndefined();
|
|
395
489
|
});
|
|
396
|
-
it('should render
|
|
397
|
-
|
|
490
|
+
it('should not render columns that fail show_when checks', function () {
|
|
491
|
+
var CHILD_PAGES = [{
|
|
492
|
+
summaryLayout: {
|
|
493
|
+
sections: [{
|
|
494
|
+
title: 'Section 1',
|
|
495
|
+
columns: [{
|
|
496
|
+
fields: ['fieldA'],
|
|
497
|
+
show_when: [{
|
|
498
|
+
field: 'showSection1',
|
|
499
|
+
op: '=',
|
|
500
|
+
value: true
|
|
501
|
+
}]
|
|
502
|
+
}, {
|
|
503
|
+
fields: ['fieldB']
|
|
504
|
+
}]
|
|
505
|
+
}]
|
|
506
|
+
},
|
|
507
|
+
components: [{
|
|
508
|
+
fieldId: 'fieldA',
|
|
509
|
+
label: 'fieldA'
|
|
510
|
+
}, {
|
|
511
|
+
fieldId: 'fieldB',
|
|
512
|
+
label: 'fieldB'
|
|
513
|
+
}]
|
|
514
|
+
}];
|
|
515
|
+
var MASTER_PAGE = {
|
|
516
|
+
childPages: CHILD_PAGES
|
|
517
|
+
};
|
|
518
|
+
var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
519
|
+
masterPage: MASTER_PAGE,
|
|
520
|
+
childMasterPages: [],
|
|
521
|
+
formData: {
|
|
522
|
+
testField: false
|
|
523
|
+
},
|
|
524
|
+
entryData: ENTRY
|
|
525
|
+
})),
|
|
526
|
+
container = _renderWithValidation8.container;
|
|
527
|
+
|
|
528
|
+
// Function to find an element by its text content
|
|
529
|
+
function getByTextContent(parent, text) {
|
|
530
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
531
|
+
return el.textContent === text;
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Check for section titles
|
|
536
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
537
|
+
expect(section1Title).toBeDefined();
|
|
538
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
539
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
540
|
+
});
|
|
541
|
+
it('should render child collections', function () {
|
|
542
|
+
var CHILD_MASTER_PAGES = [{
|
|
398
543
|
collection: {
|
|
399
544
|
name: 'childCollection'
|
|
400
545
|
},
|
|
@@ -416,7 +561,7 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
416
561
|
}
|
|
417
562
|
}]
|
|
418
563
|
}];
|
|
419
|
-
|
|
564
|
+
var CHILD_PAGES = [{
|
|
420
565
|
summaryLayout: {
|
|
421
566
|
sections: [{
|
|
422
567
|
type: 'childCollection',
|
|
@@ -432,29 +577,87 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
|
|
|
432
577
|
fieldId: 'fieldC'
|
|
433
578
|
}]
|
|
434
579
|
}];
|
|
435
|
-
|
|
580
|
+
var MASTER_PAGE = {
|
|
436
581
|
childPages: [].concat(CHILD_PAGES, CHILD_MASTER_PAGES)
|
|
437
582
|
};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}));
|
|
583
|
+
var CHILD_COLLECTIONS = ['childCollection'];
|
|
584
|
+
var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
585
|
+
masterPage: MASTER_PAGE,
|
|
586
|
+
childCollections: CHILD_COLLECTIONS,
|
|
587
|
+
formData: {},
|
|
588
|
+
entryData: ENTRY
|
|
589
|
+
})),
|
|
590
|
+
container = _renderWithValidation9.container;
|
|
447
591
|
|
|
448
592
|
// Function to find an element by its text content
|
|
449
593
|
function getByTextContent(parent, text) {
|
|
450
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
594
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
595
|
+
return el.textContent === text;
|
|
596
|
+
});
|
|
451
597
|
}
|
|
452
|
-
|
|
598
|
+
var childCollectionSectionTitle = getByTextContent(container, 'Children');
|
|
453
599
|
expect(childCollectionSectionTitle).not.toBeUndefined();
|
|
454
|
-
|
|
600
|
+
var childSectionTitles = getByTextContent(container, 'Hidden Title');
|
|
455
601
|
expect(childSectionTitles).toBeUndefined(); // Individual section title for child collections should be hidden.
|
|
456
602
|
|
|
457
|
-
|
|
603
|
+
var childFields = container.querySelectorAll(".".concat(classes('section')));
|
|
458
604
|
expect(childFields.length).toEqual(2); // One for each entry in the child collection.
|
|
459
605
|
});
|
|
606
|
+
|
|
607
|
+
it('should render components if a component with the same ID has already failed a show_when', function () {
|
|
608
|
+
var CHILD_PAGES = [{
|
|
609
|
+
summaryLayout: {
|
|
610
|
+
sections: [{
|
|
611
|
+
title: 'Section 1',
|
|
612
|
+
columns: [{
|
|
613
|
+
fields: ['fieldA']
|
|
614
|
+
}, {
|
|
615
|
+
fields: ['fieldB']
|
|
616
|
+
}]
|
|
617
|
+
}]
|
|
618
|
+
},
|
|
619
|
+
components: [{
|
|
620
|
+
fieldId: 'fieldA'
|
|
621
|
+
}, {
|
|
622
|
+
fieldId: 'fieldB',
|
|
623
|
+
label: 'first',
|
|
624
|
+
show_when: [{
|
|
625
|
+
field: 'fieldA',
|
|
626
|
+
op: '=',
|
|
627
|
+
value: 'notTheRightValue'
|
|
628
|
+
}]
|
|
629
|
+
}, {
|
|
630
|
+
fieldId: 'fieldB',
|
|
631
|
+
label: 'second',
|
|
632
|
+
show_when: [{
|
|
633
|
+
field: 'fieldA',
|
|
634
|
+
op: '!=',
|
|
635
|
+
value: 'notTheRightValue'
|
|
636
|
+
}]
|
|
637
|
+
}]
|
|
638
|
+
}];
|
|
639
|
+
var MASTER_PAGE = {
|
|
640
|
+
childPages: CHILD_PAGES
|
|
641
|
+
};
|
|
642
|
+
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
|
|
643
|
+
masterPage: MASTER_PAGE,
|
|
644
|
+
childMasterPages: [],
|
|
645
|
+
formData: {},
|
|
646
|
+
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
647
|
+
fieldA: 'notTheRightValue'
|
|
648
|
+
})
|
|
649
|
+
})),
|
|
650
|
+
container = _renderWithValidation10.container;
|
|
651
|
+
|
|
652
|
+
// Function to find an element by its text content
|
|
653
|
+
function getByTextContent(parent, text) {
|
|
654
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
655
|
+
return el.textContent === text;
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
659
|
+
expect(section1Title).not.toBeUndefined();
|
|
660
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
661
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
662
|
+
});
|
|
460
663
|
});
|