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