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