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