@ukhomeoffice/cop-react-form-renderer 5.44.1-alpha → 5.45.2-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 +464 -769
- package/dist/components/CollectionPage/CollectionPage.js +66 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +300 -342
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +63 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +104 -77
- package/dist/components/CollectionSummary/CollectionSummary.test.js +126 -81
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/SummaryCard.js +96 -131
- package/dist/components/CollectionSummary/SummaryCard.test.js +959 -810
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +66 -0
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +86 -0
- package/dist/components/FormComponent/Collection.js +73 -107
- package/dist/components/FormComponent/Collection.test.js +809 -945
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +67 -70
- package/dist/components/FormComponent/FormComponent.test.js +284 -342
- 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 +142 -178
- 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 +9 -9
- 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 +6 -7
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +96 -110
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -73
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +43 -39
- package/dist/components/FormRenderer/onPageAction.test.js +223 -206
- 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 +58 -79
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +32 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +47 -59
- 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 +30 -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 -60
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -88
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +146 -124
- 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/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- 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 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +9 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +27 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +12 -16
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +29 -30
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- 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 -70
- 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 +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +14 -17
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +19 -25
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/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/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/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- 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 +78 -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 -77
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -15
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -23
- 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 -46
- 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 -26
- 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/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 +14 -19
- package/dist/utils/Validate/validateContainer.test.js +49 -45
- package/dist/utils/Validate/validateDate.js +11 -17
- package/dist/utils/Validate/validateDate.test.js +28 -29
- 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 +17 -18
- package/dist/utils/Validate/validatePage.test.js +185 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +7 -14
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
|
@@ -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 _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
@@ -8,22 +7,18 @@ var _testUtils = require("react-dom/test-utils");
|
|
|
8
7
|
var _setupTests = require("../../setupTests");
|
|
9
8
|
var _SummaryCard = _interopRequireWildcard(require("./SummaryCard"));
|
|
10
9
|
var _BannerStrip = require("./BannerStrip");
|
|
11
|
-
|
|
12
|
-
function
|
|
10
|
+
var _SummaryCardValidationContext = _interopRequireDefault(require("./SummaryCardValidationContext"));
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
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; }
|
|
18
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
-
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); }
|
|
20
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
-
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.
|
|
14
|
+
// Global imports.
|
|
15
|
+
|
|
22
16
|
// Local imports.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
|
|
18
|
+
describe('components.CollectionSummary.SummaryCard', () => {
|
|
19
|
+
const classes = _copReactComponents.Utils.classBuilder(_SummaryCard.DEFAULT_CLASS, [], '');
|
|
20
|
+
const ID = 'summaryCardId';
|
|
21
|
+
const ENTRY = {
|
|
27
22
|
id: '001',
|
|
28
23
|
bannerText: 'A banner',
|
|
29
24
|
titleText: 'A title',
|
|
@@ -31,217 +26,229 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
31
26
|
index: 0,
|
|
32
27
|
summaryText: 'Full details'
|
|
33
28
|
};
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const checkSetup = container => {
|
|
30
|
+
const cardDiv = container.children[0];
|
|
36
31
|
expect(cardDiv.tagName).toEqual('DIV');
|
|
37
32
|
expect(cardDiv.classList).toContain(_SummaryCard.DEFAULT_CLASS);
|
|
38
|
-
|
|
33
|
+
const headerDiv = cardDiv.children[0];
|
|
39
34
|
expect(headerDiv.tagName).toEqual('DIV');
|
|
40
35
|
expect(headerDiv.classList).toContain(classes('header'));
|
|
41
|
-
|
|
36
|
+
const headerContentDiv = headerDiv.children[0];
|
|
42
37
|
expect(headerContentDiv.tagName).toEqual('DIV');
|
|
43
38
|
expect(headerContentDiv.classList).toContain(classes('header-content'));
|
|
44
|
-
|
|
39
|
+
const headerActionDiv = headerDiv.children[1];
|
|
45
40
|
expect(headerActionDiv.tagName).toEqual('DIV');
|
|
46
41
|
expect(headerActionDiv.className).toContain(classes('header-actions'));
|
|
47
|
-
|
|
42
|
+
const bodyDiv = cardDiv.children[1];
|
|
48
43
|
expect(bodyDiv.tagName).toEqual('DIV');
|
|
49
44
|
expect(bodyDiv.classList).toContain(classes('body'));
|
|
50
45
|
return {
|
|
51
|
-
cardDiv
|
|
52
|
-
headerDiv
|
|
53
|
-
headerContentDiv
|
|
54
|
-
headerActionDiv
|
|
55
|
-
bodyDiv
|
|
46
|
+
cardDiv,
|
|
47
|
+
headerDiv,
|
|
48
|
+
headerContentDiv,
|
|
49
|
+
headerActionDiv,
|
|
50
|
+
bodyDiv
|
|
56
51
|
};
|
|
57
52
|
};
|
|
58
|
-
it('should correctly render a SummaryCard component',
|
|
59
|
-
|
|
53
|
+
it('should correctly render a SummaryCard component', () => {
|
|
54
|
+
const CONFIG = {
|
|
60
55
|
banners: ['Alpha', 'Bravo'],
|
|
61
56
|
title: 'Title text',
|
|
62
57
|
details: 'Detail text'
|
|
63
58
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
59
|
+
const {
|
|
60
|
+
container
|
|
61
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
62
|
+
id: ID,
|
|
63
|
+
entryData: ENTRY,
|
|
64
|
+
config: CONFIG,
|
|
65
|
+
parentCollectionName: "parent",
|
|
66
|
+
pages: [],
|
|
67
|
+
formData: {},
|
|
68
|
+
masterPage: {
|
|
69
|
+
childPages: []
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
const {
|
|
73
|
+
headerContentDiv
|
|
74
|
+
} = checkSetup(container);
|
|
78
75
|
expect(headerContentDiv.children.length).toEqual(3);
|
|
79
|
-
|
|
76
|
+
const headerBanners = headerContentDiv.children[0];
|
|
80
77
|
expect(headerBanners.tagName).toEqual('DIV');
|
|
81
78
|
expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
82
|
-
|
|
79
|
+
const headerTitle = headerContentDiv.children[1];
|
|
83
80
|
expect(headerTitle.tagName).toEqual('DIV');
|
|
84
81
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
85
82
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
86
|
-
|
|
83
|
+
const headerDetails = headerContentDiv.children[2];
|
|
87
84
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
88
85
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
89
86
|
expect(headerDetails.textContent).toEqual(CONFIG.details);
|
|
90
87
|
});
|
|
91
|
-
it('should not render a banner if none are supplied',
|
|
92
|
-
|
|
88
|
+
it('should not render a banner if none are supplied', () => {
|
|
89
|
+
const CONFIG = {
|
|
93
90
|
title: 'Title text',
|
|
94
91
|
details: 'Detail text'
|
|
95
92
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
93
|
+
const {
|
|
94
|
+
container
|
|
95
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
96
|
+
id: ID,
|
|
97
|
+
entryData: ENTRY,
|
|
98
|
+
config: CONFIG,
|
|
99
|
+
parentCollectionName: "parent",
|
|
100
|
+
pages: [],
|
|
101
|
+
formData: {},
|
|
102
|
+
masterPage: {
|
|
103
|
+
childPages: []
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
const {
|
|
107
|
+
headerContentDiv
|
|
108
|
+
} = checkSetup(container);
|
|
110
109
|
expect(headerContentDiv.children.length).toEqual(2);
|
|
111
110
|
|
|
112
111
|
// The only two children of the content div should be the title
|
|
113
112
|
// and the details.
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
const headerTitle = headerContentDiv.children[0];
|
|
116
115
|
expect(headerTitle.tagName).toEqual('DIV');
|
|
117
116
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
118
117
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
119
|
-
|
|
118
|
+
const headerDetails = headerContentDiv.children[1];
|
|
120
119
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
121
120
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
122
121
|
expect(headerDetails.textContent).toEqual(CONFIG.details);
|
|
123
122
|
});
|
|
124
|
-
it('should not render details if none are supplied',
|
|
125
|
-
|
|
123
|
+
it('should not render details if none are supplied', () => {
|
|
124
|
+
const CONFIG = {
|
|
126
125
|
banners: ['Alpha', 'Bravo'],
|
|
127
126
|
title: 'Title text'
|
|
128
127
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
const {
|
|
129
|
+
container
|
|
130
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
131
|
+
id: ID,
|
|
132
|
+
entryData: ENTRY,
|
|
133
|
+
config: CONFIG,
|
|
134
|
+
parentCollectionName: "parent",
|
|
135
|
+
pages: [],
|
|
136
|
+
formData: {},
|
|
137
|
+
masterPage: {
|
|
138
|
+
childPages: []
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
const {
|
|
142
|
+
headerContentDiv
|
|
143
|
+
} = checkSetup(container);
|
|
143
144
|
expect(headerContentDiv.children.length).toEqual(2);
|
|
144
|
-
|
|
145
|
+
const headerBanners = headerContentDiv.children[0];
|
|
145
146
|
expect(headerBanners.tagName).toEqual('DIV');
|
|
146
147
|
expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
|
|
147
148
|
|
|
148
149
|
// The only two children of the content div should be the banner and
|
|
149
150
|
// the title.
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
const headerTitle = headerContentDiv.children[1];
|
|
152
153
|
expect(headerTitle.tagName).toEqual('DIV');
|
|
153
154
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
154
155
|
expect(headerTitle.textContent).toEqual(CONFIG.title);
|
|
155
156
|
});
|
|
156
|
-
it('should correctly interpolate the title',
|
|
157
|
-
|
|
157
|
+
it('should correctly interpolate the title', () => {
|
|
158
|
+
const CONFIG = {
|
|
158
159
|
// eslint-disable-next-line no-template-curly-in-string
|
|
159
160
|
title: '${titleText} that is interpolated'
|
|
160
161
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
const {
|
|
163
|
+
container
|
|
164
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
165
|
+
id: ID,
|
|
166
|
+
entryData: ENTRY,
|
|
167
|
+
config: CONFIG,
|
|
168
|
+
parentCollectionName: "parent",
|
|
169
|
+
pages: [],
|
|
170
|
+
formData: {},
|
|
171
|
+
masterPage: {
|
|
172
|
+
childPages: []
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
const {
|
|
176
|
+
headerContentDiv
|
|
177
|
+
} = checkSetup(container);
|
|
178
|
+
const headerTitle = headerContentDiv.children[0];
|
|
176
179
|
expect(headerTitle.tagName).toEqual('DIV');
|
|
177
180
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
178
181
|
expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
|
|
179
182
|
});
|
|
180
|
-
it('should correctly interpolate the details',
|
|
181
|
-
|
|
183
|
+
it('should correctly interpolate the details', () => {
|
|
184
|
+
const CONFIG = {
|
|
182
185
|
title: 'Title',
|
|
183
186
|
// eslint-disable-next-line no-template-curly-in-string
|
|
184
187
|
details: '${detailsText} that are interpolated'
|
|
185
188
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
189
|
+
const {
|
|
190
|
+
container
|
|
191
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
192
|
+
id: ID,
|
|
193
|
+
entryData: ENTRY,
|
|
194
|
+
config: CONFIG,
|
|
195
|
+
parentCollectionName: "parent",
|
|
196
|
+
pages: [],
|
|
197
|
+
formData: {},
|
|
198
|
+
masterPage: {
|
|
199
|
+
childPages: []
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
const {
|
|
203
|
+
headerContentDiv
|
|
204
|
+
} = checkSetup(container);
|
|
205
|
+
const headerDetails = headerContentDiv.children[1];
|
|
201
206
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
202
207
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
203
208
|
expect(headerDetails.textContent).toEqual("".concat(ENTRY.detailsText, " that are interpolated"));
|
|
204
209
|
});
|
|
205
|
-
describe('Change action button',
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
describe('Change action button', () => {
|
|
211
|
+
let isDuplicatedValue = true;
|
|
212
|
+
let onChangeArgs = [];
|
|
213
|
+
let onChangeCalls = 0;
|
|
214
|
+
const ON_CHANGE = (page, id) => {
|
|
210
215
|
onChangeArgs.push({
|
|
211
|
-
page
|
|
212
|
-
id
|
|
216
|
+
page,
|
|
217
|
+
id
|
|
213
218
|
});
|
|
214
219
|
onChangeCalls += 1;
|
|
215
220
|
isDuplicatedValue = false;
|
|
216
221
|
};
|
|
217
|
-
beforeEach(
|
|
222
|
+
beforeEach(() => {
|
|
218
223
|
onChangeArgs = [];
|
|
219
224
|
onChangeCalls = 0;
|
|
220
225
|
});
|
|
221
|
-
it('should render correctly',
|
|
222
|
-
|
|
226
|
+
it('should render correctly', () => {
|
|
227
|
+
const CONFIG = {
|
|
223
228
|
changeAction: {
|
|
224
229
|
label: 'Change label',
|
|
225
230
|
page: 'testPage'
|
|
226
231
|
}
|
|
227
232
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
const {
|
|
234
|
+
container
|
|
235
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
236
|
+
id: ID,
|
|
237
|
+
entryData: ENTRY,
|
|
238
|
+
config: CONFIG,
|
|
239
|
+
onChange: ON_CHANGE,
|
|
240
|
+
parentCollectionName: "parent",
|
|
241
|
+
pages: [],
|
|
242
|
+
formData: {},
|
|
243
|
+
masterPage: {
|
|
244
|
+
childPages: []
|
|
245
|
+
}
|
|
246
|
+
}));
|
|
247
|
+
const {
|
|
248
|
+
headerActionDiv
|
|
249
|
+
} = checkSetup(container);
|
|
243
250
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
244
|
-
|
|
251
|
+
const changeButton = headerActionDiv.children[0];
|
|
245
252
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
246
253
|
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
247
254
|
_react.fireEvent.click(changeButton, {});
|
|
@@ -251,31 +258,33 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
251
258
|
id: ENTRY.id
|
|
252
259
|
});
|
|
253
260
|
});
|
|
254
|
-
it('should render correctly when isDuplicated is true',
|
|
255
|
-
|
|
261
|
+
it('should render correctly when isDuplicated is true', () => {
|
|
262
|
+
const CONFIG = {
|
|
256
263
|
changeAction: {
|
|
257
264
|
label: 'Change label',
|
|
258
265
|
page: 'testPage'
|
|
259
266
|
}
|
|
260
267
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
268
|
+
const {
|
|
269
|
+
container
|
|
270
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
271
|
+
id: ID,
|
|
272
|
+
entryData: ENTRY,
|
|
273
|
+
config: CONFIG,
|
|
274
|
+
onChange: ON_CHANGE,
|
|
275
|
+
parentCollectionName: "parent",
|
|
276
|
+
pages: [],
|
|
277
|
+
formData: {},
|
|
278
|
+
masterPage: {
|
|
279
|
+
childPages: []
|
|
280
|
+
},
|
|
281
|
+
isDuplicated: isDuplicatedValue
|
|
282
|
+
}));
|
|
283
|
+
const {
|
|
284
|
+
headerActionDiv
|
|
285
|
+
} = checkSetup(container);
|
|
277
286
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
278
|
-
|
|
287
|
+
const changeButton = headerActionDiv.children[0];
|
|
279
288
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
280
289
|
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
281
290
|
_react.fireEvent.click(changeButton, {});
|
|
@@ -288,315 +297,338 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
288
297
|
// Check that the isDuplicated prop is now false
|
|
289
298
|
expect(isDuplicatedValue).toBe(false);
|
|
290
299
|
});
|
|
291
|
-
it('should use the default label when one is not provided',
|
|
292
|
-
|
|
300
|
+
it('should use the default label when one is not provided', () => {
|
|
301
|
+
const CONFIG = {
|
|
293
302
|
changeAction: {
|
|
294
303
|
page: 'testPage'
|
|
295
304
|
}
|
|
296
305
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
const {
|
|
307
|
+
container
|
|
308
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
309
|
+
id: ID,
|
|
310
|
+
entryData: ENTRY,
|
|
311
|
+
config: CONFIG,
|
|
312
|
+
onChange: ON_CHANGE,
|
|
313
|
+
parentCollectionName: "parent",
|
|
314
|
+
pages: [],
|
|
315
|
+
formData: {},
|
|
316
|
+
masterPage: {
|
|
317
|
+
childPages: []
|
|
318
|
+
}
|
|
319
|
+
}));
|
|
320
|
+
const {
|
|
321
|
+
headerActionDiv
|
|
322
|
+
} = checkSetup(container);
|
|
312
323
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
313
|
-
|
|
324
|
+
const changeButton = headerActionDiv.children[0];
|
|
314
325
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
315
326
|
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
316
327
|
});
|
|
317
|
-
it('should not render when no config is provided for it',
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
328
|
+
it('should not render when no config is provided for it', () => {
|
|
329
|
+
const {
|
|
330
|
+
container
|
|
331
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
332
|
+
id: ID,
|
|
333
|
+
entryData: ENTRY,
|
|
334
|
+
config: {},
|
|
335
|
+
onChange: ON_CHANGE,
|
|
336
|
+
parentCollectionName: "parent",
|
|
337
|
+
pages: [],
|
|
338
|
+
formData: {},
|
|
339
|
+
masterPage: {
|
|
340
|
+
childPages: []
|
|
341
|
+
}
|
|
342
|
+
}));
|
|
343
|
+
const {
|
|
344
|
+
headerActionDiv
|
|
345
|
+
} = checkSetup(container);
|
|
333
346
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
334
347
|
});
|
|
335
|
-
it('should not render when onChange is not supplied',
|
|
336
|
-
|
|
348
|
+
it('should not render when onChange is not supplied', () => {
|
|
349
|
+
const CONFIG = {
|
|
337
350
|
changeAction: {
|
|
338
351
|
label: 'Change label',
|
|
339
352
|
page: 'testPage'
|
|
340
353
|
}
|
|
341
354
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
const {
|
|
356
|
+
container
|
|
357
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
358
|
+
id: ID,
|
|
359
|
+
entryData: ENTRY,
|
|
360
|
+
config: CONFIG,
|
|
361
|
+
parentCollectionName: "parent",
|
|
362
|
+
pages: [],
|
|
363
|
+
formData: {},
|
|
364
|
+
masterPage: {
|
|
365
|
+
childPages: []
|
|
366
|
+
}
|
|
367
|
+
}));
|
|
368
|
+
const {
|
|
369
|
+
headerActionDiv
|
|
370
|
+
} = checkSetup(container);
|
|
356
371
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
357
372
|
});
|
|
358
373
|
});
|
|
359
|
-
describe('Delete action button',
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
374
|
+
describe('Delete action button', () => {
|
|
375
|
+
let onDeleteArgs = [];
|
|
376
|
+
let onDeleteCalls = 0;
|
|
377
|
+
const ON_DELETE = entry => {
|
|
363
378
|
onDeleteArgs.push(entry);
|
|
364
379
|
onDeleteCalls += 1;
|
|
365
380
|
};
|
|
366
|
-
beforeEach(
|
|
381
|
+
beforeEach(() => {
|
|
367
382
|
onDeleteArgs = [];
|
|
368
383
|
onDeleteCalls = 0;
|
|
369
384
|
});
|
|
370
|
-
it('should render correctly',
|
|
371
|
-
|
|
385
|
+
it('should render correctly', () => {
|
|
386
|
+
const CONFIG = {
|
|
372
387
|
deleteAction: {
|
|
373
388
|
label: 'Delete label'
|
|
374
389
|
}
|
|
375
390
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
+
const {
|
|
392
|
+
container
|
|
393
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
394
|
+
id: ID,
|
|
395
|
+
entryData: ENTRY,
|
|
396
|
+
config: CONFIG,
|
|
397
|
+
onDelete: ON_DELETE,
|
|
398
|
+
parentCollectionName: "parent",
|
|
399
|
+
pages: [],
|
|
400
|
+
formData: {},
|
|
401
|
+
masterPage: {
|
|
402
|
+
childPages: []
|
|
403
|
+
}
|
|
404
|
+
}));
|
|
405
|
+
const {
|
|
406
|
+
headerActionDiv
|
|
407
|
+
} = checkSetup(container);
|
|
391
408
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
392
|
-
|
|
409
|
+
const deleteButton = headerActionDiv.children[0];
|
|
393
410
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
394
411
|
expect(deleteButton.textContent).toEqual(CONFIG.deleteAction.label);
|
|
395
412
|
_react.fireEvent.click(deleteButton, {});
|
|
396
413
|
expect(onDeleteCalls).toEqual(1);
|
|
397
414
|
expect(onDeleteArgs[0]).toMatchObject(ENTRY);
|
|
398
415
|
});
|
|
399
|
-
it('should use the default label when one is not provided',
|
|
400
|
-
|
|
416
|
+
it('should use the default label when one is not provided', () => {
|
|
417
|
+
const CONFIG = {
|
|
401
418
|
deleteAction: {}
|
|
402
419
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
420
|
+
const {
|
|
421
|
+
container
|
|
422
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
423
|
+
id: ID,
|
|
424
|
+
entryData: ENTRY,
|
|
425
|
+
config: CONFIG,
|
|
426
|
+
onDelete: ON_DELETE,
|
|
427
|
+
parentCollectionName: "parent",
|
|
428
|
+
pages: [],
|
|
429
|
+
formData: {},
|
|
430
|
+
masterPage: {
|
|
431
|
+
childPages: []
|
|
432
|
+
}
|
|
433
|
+
}));
|
|
434
|
+
const {
|
|
435
|
+
headerActionDiv
|
|
436
|
+
} = checkSetup(container);
|
|
418
437
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
419
|
-
|
|
438
|
+
const deleteButton = headerActionDiv.children[0];
|
|
420
439
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
421
440
|
expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
|
|
422
441
|
});
|
|
423
|
-
it('should not render when no config is provided for it',
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
442
|
+
it('should not render when no config is provided for it', () => {
|
|
443
|
+
const {
|
|
444
|
+
container
|
|
445
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
446
|
+
id: ID,
|
|
447
|
+
entryData: ENTRY,
|
|
448
|
+
config: {},
|
|
449
|
+
onDelete: ON_DELETE,
|
|
450
|
+
parentCollectionName: "parent",
|
|
451
|
+
pages: [],
|
|
452
|
+
formData: {},
|
|
453
|
+
masterPage: {
|
|
454
|
+
childPages: []
|
|
455
|
+
}
|
|
456
|
+
}));
|
|
457
|
+
const {
|
|
458
|
+
headerActionDiv
|
|
459
|
+
} = checkSetup(container);
|
|
439
460
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
440
461
|
});
|
|
441
|
-
it('should not render when onDelete is not supplied',
|
|
442
|
-
|
|
462
|
+
it('should not render when onDelete is not supplied', () => {
|
|
463
|
+
const CONFIG = {
|
|
443
464
|
deleteAction: {
|
|
444
465
|
label: 'Delete label'
|
|
445
466
|
}
|
|
446
467
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
468
|
+
const {
|
|
469
|
+
container
|
|
470
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
471
|
+
id: ID,
|
|
472
|
+
entryData: ENTRY,
|
|
473
|
+
config: CONFIG,
|
|
474
|
+
parentCollectionName: "parent",
|
|
475
|
+
pages: [],
|
|
476
|
+
formData: {},
|
|
477
|
+
masterPage: {
|
|
478
|
+
childPages: []
|
|
479
|
+
}
|
|
480
|
+
}));
|
|
481
|
+
const {
|
|
482
|
+
headerActionDiv
|
|
483
|
+
} = checkSetup(container);
|
|
461
484
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
462
485
|
});
|
|
463
|
-
it('should correctly render the Details section with entry data',
|
|
464
|
-
|
|
486
|
+
it('should correctly render the Details section with entry data', () => {
|
|
487
|
+
const CONFIG = {
|
|
465
488
|
deleteAction: {
|
|
466
489
|
label: 'Delete label'
|
|
467
490
|
}
|
|
468
491
|
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
492
|
+
const {
|
|
493
|
+
container
|
|
494
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
495
|
+
id: ID,
|
|
496
|
+
entryData: ENTRY,
|
|
497
|
+
config: CONFIG,
|
|
498
|
+
parentCollectionName: "parent",
|
|
499
|
+
pages: [],
|
|
500
|
+
formData: {},
|
|
501
|
+
masterPage: {
|
|
502
|
+
childPages: []
|
|
503
|
+
}
|
|
504
|
+
}));
|
|
505
|
+
const detailsSection = container.querySelector('.details');
|
|
482
506
|
expect(detailsSection).not.toBeNull();
|
|
483
507
|
expect(detailsSection.textContent).toContain(ENTRY.summaryText);
|
|
484
508
|
});
|
|
485
509
|
});
|
|
486
|
-
describe('Duplicate action button',
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
510
|
+
describe('Duplicate action button', () => {
|
|
511
|
+
let onDuplicateArgs = [];
|
|
512
|
+
let onDuplicateCalls = 0;
|
|
513
|
+
const ON_DUPLICATE = entry => {
|
|
490
514
|
onDuplicateArgs.push(entry);
|
|
491
515
|
onDuplicateCalls += 1;
|
|
492
516
|
};
|
|
493
|
-
beforeEach(
|
|
517
|
+
beforeEach(() => {
|
|
494
518
|
onDuplicateArgs = [];
|
|
495
519
|
onDuplicateCalls = 0;
|
|
496
520
|
});
|
|
497
|
-
it('should render correctly',
|
|
498
|
-
|
|
521
|
+
it('should render correctly', () => {
|
|
522
|
+
const CONFIG = {
|
|
499
523
|
duplicateAction: {
|
|
500
524
|
label: 'Duplicate label'
|
|
501
525
|
}
|
|
502
526
|
};
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
527
|
+
const {
|
|
528
|
+
container
|
|
529
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
530
|
+
id: ID,
|
|
531
|
+
entryData: ENTRY,
|
|
532
|
+
config: CONFIG,
|
|
533
|
+
onDuplicate: ON_DUPLICATE,
|
|
534
|
+
parentCollectionName: "parent",
|
|
535
|
+
pages: [],
|
|
536
|
+
formData: {},
|
|
537
|
+
masterPage: {
|
|
538
|
+
childPages: []
|
|
539
|
+
}
|
|
540
|
+
}));
|
|
541
|
+
const {
|
|
542
|
+
headerActionDiv
|
|
543
|
+
} = checkSetup(container);
|
|
518
544
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
519
|
-
|
|
545
|
+
const duplicateButton = headerActionDiv.children[0];
|
|
520
546
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
521
547
|
expect(duplicateButton.textContent).toEqual(CONFIG.duplicateAction.label);
|
|
522
548
|
_react.fireEvent.click(duplicateButton, {});
|
|
523
549
|
expect(onDuplicateCalls).toEqual(1);
|
|
524
550
|
expect(onDuplicateArgs[0]).toMatchObject(ENTRY);
|
|
525
551
|
});
|
|
526
|
-
it('should use the default label when one is not provided',
|
|
527
|
-
|
|
552
|
+
it('should use the default label when one is not provided', () => {
|
|
553
|
+
const CONFIG = {
|
|
528
554
|
duplicateAction: {}
|
|
529
555
|
};
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
556
|
+
const {
|
|
557
|
+
container
|
|
558
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
559
|
+
id: ID,
|
|
560
|
+
entryData: ENTRY,
|
|
561
|
+
config: CONFIG,
|
|
562
|
+
onDuplicate: ON_DUPLICATE,
|
|
563
|
+
parentCollectionName: "parent",
|
|
564
|
+
pages: [],
|
|
565
|
+
formData: {},
|
|
566
|
+
masterPage: {
|
|
567
|
+
childPages: []
|
|
568
|
+
}
|
|
569
|
+
}));
|
|
570
|
+
const {
|
|
571
|
+
headerActionDiv
|
|
572
|
+
} = checkSetup(container);
|
|
545
573
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
546
|
-
|
|
574
|
+
const duplicateButton = headerActionDiv.children[0];
|
|
547
575
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
548
576
|
expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
|
|
549
577
|
});
|
|
550
|
-
it('should not render when no config is provided for it',
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
578
|
+
it('should not render when no config is provided for it', () => {
|
|
579
|
+
const {
|
|
580
|
+
container
|
|
581
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
582
|
+
id: ID,
|
|
583
|
+
entryData: ENTRY,
|
|
584
|
+
config: {},
|
|
585
|
+
onDuplicate: ON_DUPLICATE,
|
|
586
|
+
parentCollectionName: "parent",
|
|
587
|
+
pages: [],
|
|
588
|
+
formData: {},
|
|
589
|
+
masterPage: {
|
|
590
|
+
childPages: []
|
|
591
|
+
}
|
|
592
|
+
}));
|
|
593
|
+
const {
|
|
594
|
+
headerActionDiv
|
|
595
|
+
} = checkSetup(container);
|
|
566
596
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
567
597
|
});
|
|
568
|
-
it('should not render when onDuplicate is not supplied',
|
|
569
|
-
|
|
598
|
+
it('should not render when onDuplicate is not supplied', () => {
|
|
599
|
+
const CONFIG = {
|
|
570
600
|
duplicateAction: {
|
|
571
601
|
label: 'Duplicate label'
|
|
572
602
|
}
|
|
573
603
|
};
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
604
|
+
const {
|
|
605
|
+
container
|
|
606
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
607
|
+
id: ID,
|
|
608
|
+
entryData: ENTRY,
|
|
609
|
+
config: CONFIG,
|
|
610
|
+
parentCollectionName: "parent",
|
|
611
|
+
pages: [],
|
|
612
|
+
formData: {},
|
|
613
|
+
masterPage: {
|
|
614
|
+
childPages: []
|
|
615
|
+
}
|
|
616
|
+
}));
|
|
617
|
+
const {
|
|
618
|
+
headerActionDiv
|
|
619
|
+
} = checkSetup(container);
|
|
588
620
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
589
621
|
});
|
|
590
622
|
});
|
|
591
|
-
describe('Quick Edit action button',
|
|
592
|
-
|
|
623
|
+
describe('Quick Edit action button', () => {
|
|
624
|
+
const CONFIG = {
|
|
593
625
|
quickEdit: {
|
|
594
626
|
components: [{
|
|
595
627
|
use: 'testText'
|
|
596
628
|
}]
|
|
597
629
|
}
|
|
598
630
|
};
|
|
599
|
-
|
|
631
|
+
const PAGES = [{
|
|
600
632
|
id: 'parentPage',
|
|
601
633
|
name: 'parentPage',
|
|
602
634
|
components: [{
|
|
@@ -618,26 +650,28 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
618
650
|
}]
|
|
619
651
|
}
|
|
620
652
|
}];
|
|
621
|
-
it('should render correctly',
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
653
|
+
it('should render correctly', () => {
|
|
654
|
+
const {
|
|
655
|
+
container
|
|
656
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
657
|
+
id: ID,
|
|
658
|
+
entryData: ENTRY,
|
|
659
|
+
config: CONFIG,
|
|
660
|
+
pages: PAGES,
|
|
661
|
+
parentCollectionName: "parent",
|
|
662
|
+
formData: {},
|
|
663
|
+
masterPage: {
|
|
664
|
+
childPages: []
|
|
665
|
+
},
|
|
666
|
+
isDuplicated: true
|
|
667
|
+
}));
|
|
668
|
+
const {
|
|
669
|
+
headerActionDiv
|
|
670
|
+
} = checkSetup(container);
|
|
637
671
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
638
672
|
|
|
639
673
|
// Shows edit button but no quick edit
|
|
640
|
-
|
|
674
|
+
const editButton = headerActionDiv.children[0];
|
|
641
675
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
642
676
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
643
677
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -645,13 +679,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
645
679
|
// shows quickedit once clicked
|
|
646
680
|
_react.fireEvent.click(editButton, {});
|
|
647
681
|
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
648
|
-
|
|
682
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
649
683
|
expect(quickEdit.textContent).toContain('Test text');
|
|
650
684
|
|
|
651
685
|
// quick edit has proper buttons
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
686
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
687
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
688
|
+
const cancelButton = quickEditButtons.childNodes[1];
|
|
655
689
|
expect(saveButton.textContent).toContain('Save');
|
|
656
690
|
expect(cancelButton.textContent).toContain('Cancel');
|
|
657
691
|
|
|
@@ -660,34 +694,185 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
660
694
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
661
695
|
});
|
|
662
696
|
|
|
663
|
-
it('should not render when no config is provided for it',
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
697
|
+
it('should not render when no config is provided for it', () => {
|
|
698
|
+
const {
|
|
699
|
+
container
|
|
700
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
701
|
+
id: ID,
|
|
702
|
+
entryData: ENTRY,
|
|
703
|
+
config: {},
|
|
704
|
+
parentCollectionName: "parent",
|
|
705
|
+
pages: [],
|
|
706
|
+
formData: {},
|
|
707
|
+
masterPage: {
|
|
708
|
+
childPages: []
|
|
709
|
+
},
|
|
710
|
+
isDuplicated: true
|
|
711
|
+
}));
|
|
712
|
+
const {
|
|
713
|
+
headerActionDiv
|
|
714
|
+
} = checkSetup(container);
|
|
679
715
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
680
716
|
});
|
|
681
717
|
});
|
|
682
|
-
describe('Quick Edit
|
|
683
|
-
|
|
718
|
+
describe('Quick Edit errors', () => {
|
|
719
|
+
const CUSTOM_ENTRY = {
|
|
720
|
+
id: '123',
|
|
721
|
+
testText: 'value'
|
|
722
|
+
};
|
|
723
|
+
const CONFIG = {
|
|
724
|
+
quickEdit: {
|
|
725
|
+
components: [{
|
|
726
|
+
use: 'testText'
|
|
727
|
+
}]
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
const PAGES = [{
|
|
731
|
+
id: 'parentPage',
|
|
732
|
+
name: 'parentPage',
|
|
733
|
+
components: [{
|
|
734
|
+
id: 'testText',
|
|
735
|
+
type: 'text',
|
|
736
|
+
label: 'Test text',
|
|
737
|
+
fieldId: 'testText',
|
|
738
|
+
required: true,
|
|
739
|
+
use: 'testText',
|
|
740
|
+
cya_label: 'Test text',
|
|
741
|
+
full_path: 'testText',
|
|
742
|
+
custom_errors: [{
|
|
743
|
+
type: 'required',
|
|
744
|
+
message: 'Custom error message'
|
|
745
|
+
}]
|
|
746
|
+
}],
|
|
747
|
+
formData: {
|
|
748
|
+
parents: [{
|
|
749
|
+
id: '123',
|
|
750
|
+
index: 0
|
|
751
|
+
}]
|
|
752
|
+
}
|
|
753
|
+
}];
|
|
754
|
+
it('should initally show errors passed in from top-level', () => {
|
|
755
|
+
const TOP_LEVEL_ERRORS = [{
|
|
756
|
+
id: 'testText',
|
|
757
|
+
entryId: '123',
|
|
758
|
+
error: 'top-level error message'
|
|
759
|
+
}];
|
|
760
|
+
const {
|
|
761
|
+
container
|
|
762
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
763
|
+
entryId: CUSTOM_ENTRY.id,
|
|
764
|
+
topLevelErrors: TOP_LEVEL_ERRORS
|
|
765
|
+
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
766
|
+
id: ID,
|
|
767
|
+
entryData: CUSTOM_ENTRY,
|
|
768
|
+
config: CONFIG,
|
|
769
|
+
pages: PAGES,
|
|
770
|
+
parentCollectionName: "parent",
|
|
771
|
+
formData: {},
|
|
772
|
+
masterPage: {
|
|
773
|
+
childPages: []
|
|
774
|
+
},
|
|
775
|
+
isDuplicated: true
|
|
776
|
+
})));
|
|
777
|
+
const {
|
|
778
|
+
headerActionDiv
|
|
779
|
+
} = checkSetup(container);
|
|
780
|
+
expect(headerActionDiv.children.length).toEqual(1);
|
|
781
|
+
|
|
782
|
+
// Shows edit button but no quick edit
|
|
783
|
+
const editButton = headerActionDiv.children[0];
|
|
784
|
+
expect(editButton.tagName).toEqual('BUTTON');
|
|
785
|
+
expect(editButton.textContent).toEqual('Quick Edit');
|
|
786
|
+
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
787
|
+
|
|
788
|
+
// shows quickedit once clicked
|
|
789
|
+
_react.fireEvent.click(editButton, {});
|
|
790
|
+
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
791
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
792
|
+
expect(quickEdit.textContent).toContain('Test text');
|
|
793
|
+
|
|
794
|
+
// quick edit is showing top-level error
|
|
795
|
+
const errorSummary = quickEdit.childNodes[0];
|
|
796
|
+
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
797
|
+
});
|
|
798
|
+
it('should only show errors from validation when it happens, ignoring top-level errors', async () => {
|
|
799
|
+
const TOP_LEVEL_ERRORS = [{
|
|
800
|
+
id: 'testText',
|
|
801
|
+
entryId: '123',
|
|
802
|
+
error: 'top-level error message'
|
|
803
|
+
}];
|
|
804
|
+
const {
|
|
805
|
+
container
|
|
806
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
807
|
+
entryId: CUSTOM_ENTRY.id,
|
|
808
|
+
topLevelErrors: TOP_LEVEL_ERRORS
|
|
809
|
+
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
810
|
+
id: ID,
|
|
811
|
+
entryData: CUSTOM_ENTRY,
|
|
812
|
+
config: CONFIG,
|
|
813
|
+
pages: PAGES,
|
|
814
|
+
parentCollectionName: "parent",
|
|
815
|
+
formData: {},
|
|
816
|
+
masterPage: {
|
|
817
|
+
childPages: []
|
|
818
|
+
},
|
|
819
|
+
onQuickEdit: () => {},
|
|
820
|
+
isDuplicated: true
|
|
821
|
+
})));
|
|
822
|
+
const {
|
|
823
|
+
headerActionDiv
|
|
824
|
+
} = checkSetup(container);
|
|
825
|
+
expect(headerActionDiv.children.length).toEqual(1);
|
|
826
|
+
|
|
827
|
+
// Shows edit button but no quick edit
|
|
828
|
+
const editButton = headerActionDiv.children[0];
|
|
829
|
+
expect(editButton.tagName).toEqual('BUTTON');
|
|
830
|
+
expect(editButton.textContent).toEqual('Quick Edit');
|
|
831
|
+
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
832
|
+
|
|
833
|
+
// shows quickedit once clicked
|
|
834
|
+
_react.fireEvent.click(editButton, {});
|
|
835
|
+
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
836
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
837
|
+
expect(quickEdit.textContent).toContain('Test text');
|
|
838
|
+
|
|
839
|
+
// quick edit is initially showing top-level error
|
|
840
|
+
const errorSummary = quickEdit.childNodes[0];
|
|
841
|
+
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
842
|
+
|
|
843
|
+
// remove value from required text component
|
|
844
|
+
const component = quickEdit.childNodes[2];
|
|
845
|
+
const componentInput = component.childNodes[3];
|
|
846
|
+
await (0, _testUtils.act)(async () => {
|
|
847
|
+
_react.fireEvent.change(componentInput, {
|
|
848
|
+
target: {
|
|
849
|
+
value: ''
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// click 'save' to trigger validation, which will fail as the component
|
|
855
|
+
// cleared above is marked as 'required'.
|
|
856
|
+
const quickEditButtons = quickEdit.childNodes[3];
|
|
857
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
858
|
+
expect(saveButton.textContent).toContain('Save');
|
|
859
|
+
await (0, _testUtils.act)(async () => {
|
|
860
|
+
_react.fireEvent.click(saveButton, {});
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
// quick edit should now be showing the errors from validation
|
|
864
|
+
expect(errorSummary.textContent).toContain('Custom error message');
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
describe('Quick Edit save changes', () => {
|
|
868
|
+
const CONFIG = {
|
|
684
869
|
quickEdit: {
|
|
685
870
|
components: [{
|
|
686
871
|
use: 'testText'
|
|
687
872
|
}]
|
|
688
873
|
}
|
|
689
874
|
};
|
|
690
|
-
|
|
875
|
+
const PAGES = [{
|
|
691
876
|
id: 'parentPage',
|
|
692
877
|
name: 'parentPage',
|
|
693
878
|
components: [{
|
|
@@ -714,26 +899,28 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
714
899
|
}]
|
|
715
900
|
}
|
|
716
901
|
}];
|
|
717
|
-
it('should render correctly',
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
902
|
+
it('should render correctly', () => {
|
|
903
|
+
const {
|
|
904
|
+
container
|
|
905
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
906
|
+
id: ID,
|
|
907
|
+
entryData: ENTRY,
|
|
908
|
+
config: CONFIG,
|
|
909
|
+
pages: PAGES,
|
|
910
|
+
parentCollectionName: "parent",
|
|
911
|
+
formData: {},
|
|
912
|
+
masterPage: {
|
|
913
|
+
childPages: []
|
|
914
|
+
},
|
|
915
|
+
isDuplicated: true
|
|
916
|
+
}));
|
|
917
|
+
const {
|
|
918
|
+
headerActionDiv
|
|
919
|
+
} = checkSetup(container);
|
|
733
920
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
734
921
|
|
|
735
922
|
// Shows edit button but no quick edit
|
|
736
|
-
|
|
923
|
+
const editButton = headerActionDiv.children[0];
|
|
737
924
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
738
925
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
739
926
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -741,13 +928,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
741
928
|
// shows quickedit once clicked
|
|
742
929
|
_react.fireEvent.click(editButton, {});
|
|
743
930
|
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
744
|
-
|
|
931
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
745
932
|
expect(quickEdit.textContent).toContain('Test text');
|
|
746
933
|
|
|
747
934
|
// quick edit has proper buttons
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
935
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
936
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
937
|
+
const cancelButton = quickEditButtons.childNodes[1];
|
|
751
938
|
expect(saveButton.textContent).toContain('Save');
|
|
752
939
|
expect(cancelButton.textContent).toContain('Cancel');
|
|
753
940
|
|
|
@@ -756,405 +943,368 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
756
943
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
757
944
|
});
|
|
758
945
|
|
|
759
|
-
it('should not validate or save if nothing has changed',
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
onSubmit:
|
|
763
|
-
return ON_SUBMIT_CALLS.push(patch);
|
|
764
|
-
}
|
|
946
|
+
it('should not validate or save if nothing has changed', () => {
|
|
947
|
+
const ON_SUBMIT_CALLS = [];
|
|
948
|
+
const hooks = {
|
|
949
|
+
onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
|
|
765
950
|
};
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
951
|
+
const {
|
|
952
|
+
container
|
|
953
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
954
|
+
id: ID,
|
|
955
|
+
entryData: ENTRY,
|
|
956
|
+
config: CONFIG,
|
|
957
|
+
pages: PAGES,
|
|
958
|
+
parentCollectionName: "parents",
|
|
959
|
+
formData: {},
|
|
960
|
+
masterPage: {
|
|
961
|
+
childPages: []
|
|
962
|
+
},
|
|
963
|
+
isDuplicated: true
|
|
964
|
+
}), {
|
|
965
|
+
hooks
|
|
966
|
+
});
|
|
967
|
+
const {
|
|
968
|
+
headerActionDiv
|
|
969
|
+
} = checkSetup(container);
|
|
783
970
|
|
|
784
971
|
// Shows edit button but no quick edit
|
|
785
|
-
|
|
972
|
+
const editButton = headerActionDiv.children[0];
|
|
786
973
|
|
|
787
974
|
// shows quickedit once clicked
|
|
788
975
|
_react.fireEvent.click(editButton, {});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
976
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
977
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
978
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
792
979
|
_react.fireEvent.click(saveButton, {});
|
|
793
980
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
794
981
|
});
|
|
795
|
-
it('should return after local validation if errors are present',
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
case "end":
|
|
865
|
-
return _context2.stop();
|
|
866
|
-
}
|
|
867
|
-
}, _callee2);
|
|
868
|
-
})));
|
|
869
|
-
case 17:
|
|
870
|
-
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
871
|
-
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
872
|
-
case 19:
|
|
873
|
-
case "end":
|
|
874
|
-
return _context3.stop();
|
|
982
|
+
it('should return after local validation if errors are present', async () => {
|
|
983
|
+
const ON_SUBMIT_CALLS = [];
|
|
984
|
+
const hooks = {
|
|
985
|
+
onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
|
|
986
|
+
};
|
|
987
|
+
const ON_QUICK_EDIT_CALLS = [];
|
|
988
|
+
const ON_QUICK_EDIT = _ref => {
|
|
989
|
+
let {
|
|
990
|
+
target
|
|
991
|
+
} = _ref;
|
|
992
|
+
ON_QUICK_EDIT_CALLS.push(target);
|
|
993
|
+
};
|
|
994
|
+
const {
|
|
995
|
+
container
|
|
996
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
997
|
+
id: ID,
|
|
998
|
+
entryData: {
|
|
999
|
+
...ENTRY,
|
|
1000
|
+
index: 0
|
|
1001
|
+
},
|
|
1002
|
+
config: CONFIG,
|
|
1003
|
+
pages: PAGES,
|
|
1004
|
+
parentCollectionName: "parents",
|
|
1005
|
+
onQuickEdit: ON_QUICK_EDIT,
|
|
1006
|
+
formData: {
|
|
1007
|
+
parents: [{
|
|
1008
|
+
testText: 'hello'
|
|
1009
|
+
}]
|
|
1010
|
+
},
|
|
1011
|
+
masterPage: {
|
|
1012
|
+
childPages: []
|
|
1013
|
+
},
|
|
1014
|
+
isDuplicated: true
|
|
1015
|
+
}), {
|
|
1016
|
+
hooks
|
|
1017
|
+
});
|
|
1018
|
+
const {
|
|
1019
|
+
headerActionDiv
|
|
1020
|
+
} = checkSetup(container);
|
|
1021
|
+
const editButton = headerActionDiv.children[0];
|
|
1022
|
+
_react.fireEvent.click(editButton, {});
|
|
1023
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
1024
|
+
const component = quickEdit.childNodes[1];
|
|
1025
|
+
const componentInput = component.childNodes[2];
|
|
1026
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
1027
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
1028
|
+
// Field has validation to force the length of this field to be greater than 2 so this should fail
|
|
1029
|
+
await (0, _testUtils.act)(async () => {
|
|
1030
|
+
_react.fireEvent.change(componentInput, {
|
|
1031
|
+
target: {
|
|
1032
|
+
value: 'a'
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
});
|
|
1036
|
+
await (0, _testUtils.act)(async () => {
|
|
1037
|
+
_react.fireEvent.click(saveButton, {});
|
|
1038
|
+
});
|
|
1039
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
1040
|
+
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
1041
|
+
});
|
|
1042
|
+
it('should run hook validation when a value changes and local validation is passed', async () => {
|
|
1043
|
+
const ON_SUBMIT_CALLS = [];
|
|
1044
|
+
const hooks = {
|
|
1045
|
+
onSubmit: (type, patch, notRequired, onError) => {
|
|
1046
|
+
ON_SUBMIT_CALLS.push(patch);
|
|
1047
|
+
onError([{
|
|
1048
|
+
error: 'message',
|
|
1049
|
+
id: '0'
|
|
1050
|
+
}]);
|
|
875
1051
|
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
editButton = headerActionDiv.children[0];
|
|
919
|
-
_react.fireEvent.click(editButton, {});
|
|
920
|
-
quickEdit = container.childNodes[0].childNodes[1]; // Make a change
|
|
921
|
-
component = quickEdit.childNodes[1];
|
|
922
|
-
componentInput = component.childNodes[2];
|
|
923
|
-
_react.fireEvent.change(componentInput, {
|
|
924
|
-
target: {
|
|
925
|
-
value: 'new value'
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
quickEditButtons = quickEdit.childNodes[2];
|
|
929
|
-
saveButton = quickEditButtons.childNodes[0];
|
|
930
|
-
_context5.next = 16;
|
|
931
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
932
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
933
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
934
|
-
case 0:
|
|
935
|
-
_react.fireEvent.click(saveButton, {});
|
|
936
|
-
case 1:
|
|
937
|
-
case "end":
|
|
938
|
-
return _context4.stop();
|
|
939
|
-
}
|
|
940
|
-
}, _callee4);
|
|
941
|
-
})));
|
|
942
|
-
case 16:
|
|
943
|
-
expect(ON_SUBMIT_CALLS[0]).toEqual({
|
|
944
|
-
testText: 'new value'
|
|
945
|
-
});
|
|
946
|
-
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
947
|
-
case 18:
|
|
948
|
-
case "end":
|
|
949
|
-
return _context5.stop();
|
|
1052
|
+
};
|
|
1053
|
+
const ON_QUICK_EDIT_CALLS = [];
|
|
1054
|
+
const ON_QUICK_EDIT = _ref2 => {
|
|
1055
|
+
let {
|
|
1056
|
+
target
|
|
1057
|
+
} = _ref2;
|
|
1058
|
+
ON_QUICK_EDIT_CALLS.push(target);
|
|
1059
|
+
};
|
|
1060
|
+
const {
|
|
1061
|
+
container
|
|
1062
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1063
|
+
id: ID,
|
|
1064
|
+
entryData: ENTRY,
|
|
1065
|
+
config: CONFIG,
|
|
1066
|
+
pages: PAGES,
|
|
1067
|
+
parentCollectionName: "parents",
|
|
1068
|
+
onQuickEdit: ON_QUICK_EDIT,
|
|
1069
|
+
formData: {
|
|
1070
|
+
parents: [{
|
|
1071
|
+
alreadyProvidedField: 'hello'
|
|
1072
|
+
}]
|
|
1073
|
+
},
|
|
1074
|
+
masterPage: {
|
|
1075
|
+
childPages: []
|
|
1076
|
+
},
|
|
1077
|
+
isDuplicated: true
|
|
1078
|
+
}), {
|
|
1079
|
+
hooks
|
|
1080
|
+
});
|
|
1081
|
+
const {
|
|
1082
|
+
headerActionDiv
|
|
1083
|
+
} = checkSetup(container);
|
|
1084
|
+
const editButton = headerActionDiv.children[0];
|
|
1085
|
+
_react.fireEvent.click(editButton, {});
|
|
1086
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
1087
|
+
|
|
1088
|
+
// Make a change
|
|
1089
|
+
const component = quickEdit.childNodes[1];
|
|
1090
|
+
const componentInput = component.childNodes[2];
|
|
1091
|
+
_react.fireEvent.change(componentInput, {
|
|
1092
|
+
target: {
|
|
1093
|
+
value: 'new value'
|
|
950
1094
|
}
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
_context7.next = 17;
|
|
1007
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
1008
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1009
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
1010
|
-
case 0:
|
|
1011
|
-
_react.fireEvent.click(saveButton, {});
|
|
1012
|
-
case 1:
|
|
1013
|
-
case "end":
|
|
1014
|
-
return _context6.stop();
|
|
1015
|
-
}
|
|
1016
|
-
}, _callee6);
|
|
1017
|
-
})));
|
|
1018
|
-
case 17:
|
|
1019
|
-
expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
|
|
1020
|
-
expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
|
|
1021
|
-
alreadyProvidedField: 'hello',
|
|
1022
|
-
testText: 'new value'
|
|
1023
|
-
});
|
|
1095
|
+
});
|
|
1096
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
1097
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
1098
|
+
await (0, _testUtils.act)(async () => {
|
|
1099
|
+
_react.fireEvent.click(saveButton, {});
|
|
1100
|
+
});
|
|
1101
|
+
expect(ON_SUBMIT_CALLS[0]).toEqual({
|
|
1102
|
+
testText: 'new value'
|
|
1103
|
+
});
|
|
1104
|
+
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
1105
|
+
});
|
|
1106
|
+
it('should apply changes if no errors are present', async () => {
|
|
1107
|
+
let isDuplicatedValue = true;
|
|
1108
|
+
const ON_SUBMIT_CALLS = [];
|
|
1109
|
+
const hooks = {
|
|
1110
|
+
onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
|
|
1111
|
+
};
|
|
1112
|
+
const ON_QUICK_EDIT_CALLS = [];
|
|
1113
|
+
const ON_QUICK_EDIT = _ref3 => {
|
|
1114
|
+
let {
|
|
1115
|
+
target
|
|
1116
|
+
} = _ref3;
|
|
1117
|
+
ON_QUICK_EDIT_CALLS.push(target);
|
|
1118
|
+
isDuplicatedValue = false;
|
|
1119
|
+
};
|
|
1120
|
+
const {
|
|
1121
|
+
container
|
|
1122
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1123
|
+
id: ID,
|
|
1124
|
+
entryData: {
|
|
1125
|
+
index: 0,
|
|
1126
|
+
id: '0'
|
|
1127
|
+
},
|
|
1128
|
+
config: CONFIG,
|
|
1129
|
+
pages: PAGES,
|
|
1130
|
+
parentCollectionName: "parents",
|
|
1131
|
+
onQuickEdit: ON_QUICK_EDIT,
|
|
1132
|
+
formData: {
|
|
1133
|
+
parents: [{
|
|
1134
|
+
alreadyProvidedField: 'hello'
|
|
1135
|
+
}]
|
|
1136
|
+
},
|
|
1137
|
+
masterPage: {
|
|
1138
|
+
childPages: []
|
|
1139
|
+
},
|
|
1140
|
+
isDuplicated: isDuplicatedValue
|
|
1141
|
+
}), {
|
|
1142
|
+
hooks
|
|
1143
|
+
});
|
|
1144
|
+
const {
|
|
1145
|
+
headerActionDiv
|
|
1146
|
+
} = checkSetup(container);
|
|
1147
|
+
const editButton = headerActionDiv.children[0];
|
|
1148
|
+
_react.fireEvent.click(editButton, {});
|
|
1149
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
1024
1150
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1151
|
+
// Make a change that will be accepted
|
|
1152
|
+
const component = quickEdit.childNodes[1];
|
|
1153
|
+
const componentInput = component.childNodes[2];
|
|
1154
|
+
_react.fireEvent.change(componentInput, {
|
|
1155
|
+
target: {
|
|
1156
|
+
value: 'new value'
|
|
1030
1157
|
}
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1158
|
+
});
|
|
1159
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
1160
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
1161
|
+
await (0, _testUtils.act)(async () => {
|
|
1162
|
+
_react.fireEvent.click(saveButton, {});
|
|
1163
|
+
});
|
|
1164
|
+
expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
|
|
1165
|
+
expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
|
|
1166
|
+
alreadyProvidedField: 'hello',
|
|
1167
|
+
testText: 'new value'
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
// Check that the isDuplicated prop is now false
|
|
1171
|
+
expect(isDuplicatedValue).toBe(false);
|
|
1172
|
+
});
|
|
1033
1173
|
});
|
|
1034
|
-
describe('Details prop behavior',
|
|
1035
|
-
it('should render the provided details',
|
|
1036
|
-
|
|
1037
|
-
|
|
1174
|
+
describe('Details prop behavior', () => {
|
|
1175
|
+
it('should render the provided details', () => {
|
|
1176
|
+
const DETAILS = 'Sample details';
|
|
1177
|
+
const CONFIG = {
|
|
1038
1178
|
title: 'Title',
|
|
1039
1179
|
details: DETAILS
|
|
1040
1180
|
};
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1181
|
+
const {
|
|
1182
|
+
container
|
|
1183
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1184
|
+
id: ID,
|
|
1185
|
+
entryData: ENTRY,
|
|
1186
|
+
config: CONFIG,
|
|
1187
|
+
parentCollectionName: "parent",
|
|
1188
|
+
pages: [],
|
|
1189
|
+
formData: {},
|
|
1190
|
+
masterPage: {
|
|
1191
|
+
childPages: []
|
|
1192
|
+
}
|
|
1193
|
+
}));
|
|
1194
|
+
const {
|
|
1195
|
+
headerContentDiv
|
|
1196
|
+
} = checkSetup(container);
|
|
1197
|
+
const headerDetails = headerContentDiv.children[1];
|
|
1056
1198
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
1057
1199
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
1058
1200
|
expect(headerDetails.textContent).toEqual(DETAILS);
|
|
1059
1201
|
});
|
|
1060
|
-
it('should not render details when they are empty',
|
|
1061
|
-
|
|
1202
|
+
it('should not render details when they are empty', () => {
|
|
1203
|
+
const CONFIG = {
|
|
1062
1204
|
title: 'Title',
|
|
1063
1205
|
details: ''
|
|
1064
1206
|
};
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1207
|
+
const {
|
|
1208
|
+
container
|
|
1209
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1210
|
+
id: ID,
|
|
1211
|
+
entryData: ENTRY,
|
|
1212
|
+
config: CONFIG,
|
|
1213
|
+
parentCollectionName: "parent",
|
|
1214
|
+
pages: [],
|
|
1215
|
+
formData: {},
|
|
1216
|
+
masterPage: {
|
|
1217
|
+
childPages: []
|
|
1218
|
+
}
|
|
1219
|
+
}));
|
|
1220
|
+
const {
|
|
1221
|
+
headerContentDiv
|
|
1222
|
+
} = checkSetup(container);
|
|
1079
1223
|
// If no details are provided, we expect only the header title to be rendered.
|
|
1080
1224
|
expect(headerContentDiv.children.length).toEqual(1);
|
|
1081
|
-
|
|
1225
|
+
const headerTitle = headerContentDiv.children[0];
|
|
1082
1226
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
1083
1227
|
});
|
|
1084
|
-
it('should render the interpolated details',
|
|
1085
|
-
|
|
1086
|
-
|
|
1228
|
+
it('should render the interpolated details', () => {
|
|
1229
|
+
const DETAILS = 'Full {label}';
|
|
1230
|
+
const INTERPOLATED_ENTRY = {
|
|
1231
|
+
...ENTRY,
|
|
1087
1232
|
label: 'Details'
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1233
|
+
};
|
|
1234
|
+
const CONFIG = {
|
|
1090
1235
|
title: 'Title',
|
|
1091
1236
|
details: DETAILS
|
|
1092
1237
|
};
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1238
|
+
const {
|
|
1239
|
+
container
|
|
1240
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1241
|
+
id: ID,
|
|
1242
|
+
entryData: INTERPOLATED_ENTRY,
|
|
1243
|
+
config: CONFIG,
|
|
1244
|
+
parentCollectionName: "parent",
|
|
1245
|
+
pages: [],
|
|
1246
|
+
formData: {},
|
|
1247
|
+
masterPage: {
|
|
1248
|
+
childPages: []
|
|
1249
|
+
}
|
|
1250
|
+
}));
|
|
1251
|
+
const {
|
|
1252
|
+
headerContentDiv
|
|
1253
|
+
} = checkSetup(container);
|
|
1254
|
+
const headerDetails = headerContentDiv.children[1];
|
|
1255
|
+
const expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
|
|
1109
1256
|
expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
|
|
1110
1257
|
});
|
|
1111
|
-
it('should not render the details div if config.details is not provided',
|
|
1112
|
-
|
|
1258
|
+
it('should not render the details div if config.details is not provided', () => {
|
|
1259
|
+
const CONFIG = {
|
|
1113
1260
|
title: 'Title'
|
|
1114
1261
|
};
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1262
|
+
const {
|
|
1263
|
+
container
|
|
1264
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1265
|
+
id: ID,
|
|
1266
|
+
entryData: ENTRY,
|
|
1267
|
+
config: CONFIG,
|
|
1268
|
+
parentCollectionName: "parent",
|
|
1269
|
+
pages: [],
|
|
1270
|
+
formData: {},
|
|
1271
|
+
masterPage: {
|
|
1272
|
+
childPages: []
|
|
1273
|
+
}
|
|
1274
|
+
}));
|
|
1275
|
+
const {
|
|
1276
|
+
headerContentDiv
|
|
1277
|
+
} = checkSetup(container);
|
|
1278
|
+
const headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
1130
1279
|
expect(headerDetails).toBeNull();
|
|
1131
1280
|
});
|
|
1132
|
-
it('should not render the entire details section when hideDetails prop is true',
|
|
1133
|
-
|
|
1134
|
-
|
|
1281
|
+
it('should not render the entire details section when hideDetails prop is true', () => {
|
|
1282
|
+
const DETAILS = 'Sample details that should not be displayed';
|
|
1283
|
+
const CONFIG = {
|
|
1135
1284
|
title: 'Title',
|
|
1136
1285
|
details: DETAILS
|
|
1137
1286
|
};
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1287
|
+
const {
|
|
1288
|
+
container
|
|
1289
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1290
|
+
id: ID,
|
|
1291
|
+
entryData: ENTRY,
|
|
1292
|
+
config: CONFIG,
|
|
1293
|
+
parentCollectionName: "parent",
|
|
1294
|
+
pages: [],
|
|
1295
|
+
formData: {},
|
|
1296
|
+
hideDetails: true,
|
|
1297
|
+
masterPage: {
|
|
1298
|
+
childPages: []
|
|
1299
|
+
}
|
|
1300
|
+
}));
|
|
1301
|
+
const detailsComponent = container.querySelector('.details');
|
|
1152
1302
|
expect(detailsComponent).toBeNull();
|
|
1153
1303
|
});
|
|
1154
1304
|
});
|
|
1155
|
-
describe('SummaryLayout config behavior',
|
|
1156
|
-
it('should render sections and fields based on summaryLayout config',
|
|
1157
|
-
|
|
1305
|
+
describe('SummaryLayout config behavior', () => {
|
|
1306
|
+
it('should render sections and fields based on summaryLayout config', () => {
|
|
1307
|
+
const CHILD_PAGE_SAMPLE = [{
|
|
1158
1308
|
summaryLayout: {
|
|
1159
1309
|
sections: [{
|
|
1160
1310
|
title: 'Section 1',
|
|
@@ -1174,40 +1324,39 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1174
1324
|
fieldId: 'fieldC'
|
|
1175
1325
|
}]
|
|
1176
1326
|
}];
|
|
1177
|
-
|
|
1327
|
+
const CONFIG = {
|
|
1178
1328
|
title: 'Title'
|
|
1179
1329
|
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1330
|
+
const {
|
|
1331
|
+
container
|
|
1332
|
+
} = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1333
|
+
id: ID,
|
|
1334
|
+
entryData: ENTRY,
|
|
1335
|
+
config: CONFIG,
|
|
1336
|
+
parentCollectionName: "parent",
|
|
1337
|
+
pages: CHILD_PAGE_SAMPLE,
|
|
1338
|
+
formData: {},
|
|
1339
|
+
masterPage: {
|
|
1340
|
+
childPages: []
|
|
1341
|
+
}
|
|
1342
|
+
}));
|
|
1192
1343
|
|
|
1193
1344
|
// Function to find an element by its text content
|
|
1194
1345
|
function getByTextContent(parent, text) {
|
|
1195
|
-
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(
|
|
1196
|
-
return el.textContent === text;
|
|
1197
|
-
});
|
|
1346
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
|
|
1198
1347
|
}
|
|
1199
1348
|
|
|
1200
1349
|
// Check for section titles
|
|
1201
|
-
|
|
1202
|
-
|
|
1350
|
+
const section1Title = getByTextContent(container, 'Section 1');
|
|
1351
|
+
const section2Title = getByTextContent(container, 'Section 2');
|
|
1203
1352
|
expect(section1Title).not.toBeNull();
|
|
1204
1353
|
expect(section2Title).not.toBeNull();
|
|
1205
1354
|
if (section1Title) {
|
|
1206
|
-
|
|
1355
|
+
const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1207
1356
|
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
1208
1357
|
}
|
|
1209
1358
|
if (section2Title) {
|
|
1210
|
-
|
|
1359
|
+
const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1211
1360
|
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1212
1361
|
}
|
|
1213
1362
|
});
|