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