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