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