@ukhomeoffice/cop-react-form-renderer 6.0.6-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.scss +2 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +75 -59
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +15 -14
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.test.js +98 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +144 -135
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +167 -197
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +54 -56
- package/dist/components/CollectionSummary/RenderListView.scss +10 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +89 -78
- package/dist/components/CollectionSummary/SummaryCard.js +135 -145
- package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +943 -932
- package/dist/components/CollectionSummary/SummaryCardDetails.js +120 -62
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +261 -120
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +38 -33
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -73
- package/dist/components/FormComponent/Collection.js +81 -108
- package/dist/components/FormComponent/Collection.test.js +909 -943
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +80 -71
- 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.scss +1 -1
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +150 -183
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- 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 +50 -48
- package/dist/components/FormRenderer/onPageAction.test.js +241 -217
- 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.scss +2 -2
- 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.scss +1 -1
- 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 +65 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -61
- 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 +27 -40
- 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 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +29 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -4
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +7 -27
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +29 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +66 -22
- 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 +55 -0
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +153 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +3 -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 +16 -17
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +38 -20
- 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 +28 -19
- package/dist/utils/Condition/meetsCondition.test.js +476 -376
- 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 +29 -25
- package/dist/utils/Data/getOptions.test.js +93 -20
- 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 +42 -0
- package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
- 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 +16 -19
- package/dist/utils/Validate/validateContainer.test.js +84 -45
- 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 +24 -18
- package/dist/utils/Validate/validatePage.test.js +263 -182
- 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 +5 -5
- 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/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/helpers/clearOutUncompletedRoutes.js +0 -175
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -113
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -20
- 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,428 +195,431 @@ 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
|
-
|
|
245
|
-
var ON_CHANGE = function ON_CHANGE(page, id) {
|
|
248
|
+
describe('Change action button', () => {
|
|
249
|
+
let onChangeArgs = [];
|
|
250
|
+
let onChangeCalls = 0;
|
|
251
|
+
const ON_CHANGE = (page, id) => {
|
|
246
252
|
onChangeArgs.push({
|
|
247
|
-
page
|
|
248
|
-
id
|
|
253
|
+
page,
|
|
254
|
+
id
|
|
249
255
|
});
|
|
250
256
|
onChangeCalls += 1;
|
|
251
|
-
inErrorValue = false;
|
|
252
257
|
};
|
|
253
|
-
beforeEach(
|
|
258
|
+
beforeEach(() => {
|
|
254
259
|
onChangeArgs = [];
|
|
255
260
|
onChangeCalls = 0;
|
|
256
261
|
});
|
|
257
|
-
it('should render correctly',
|
|
258
|
-
|
|
262
|
+
it('should render correctly', () => {
|
|
263
|
+
const CONFIG = {
|
|
259
264
|
changeAction: {
|
|
260
265
|
label: 'Change label',
|
|
261
|
-
page: 'testPage'
|
|
266
|
+
page: 'testPage',
|
|
267
|
+
aria_label: [{
|
|
268
|
+
text: 'testText'
|
|
269
|
+
}]
|
|
262
270
|
}
|
|
263
271
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
container = _renderWithValidation7.container;
|
|
276
|
-
var _checkSetup7 = checkSetup(container),
|
|
277
|
-
headerActionDiv = _checkSetup7.headerActionDiv;
|
|
278
|
-
expect(headerActionDiv.children.length).toEqual(1);
|
|
279
|
-
var changeButton = headerActionDiv.children[0];
|
|
280
|
-
expect(changeButton.tagName).toEqual('BUTTON');
|
|
281
|
-
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
282
|
-
_react.fireEvent.click(changeButton, {});
|
|
283
|
-
expect(onChangeCalls).toEqual(1);
|
|
284
|
-
expect(onChangeArgs[0]).toMatchObject({
|
|
285
|
-
page: CONFIG.changeAction.page,
|
|
286
|
-
id: ENTRY.id
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
it('should render correctly when inError is true', function () {
|
|
290
|
-
var CONFIG = {
|
|
291
|
-
changeAction: {
|
|
292
|
-
label: 'Change label',
|
|
293
|
-
page: 'testPage'
|
|
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: []
|
|
294
283
|
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
config: CONFIG,
|
|
300
|
-
onChange: ON_CHANGE,
|
|
301
|
-
parentCollectionName: "parent",
|
|
302
|
-
formData: {},
|
|
303
|
-
masterPage: {
|
|
304
|
-
childPages: []
|
|
305
|
-
},
|
|
306
|
-
inError: inErrorValue
|
|
307
|
-
})),
|
|
308
|
-
container = _renderWithValidation8.container;
|
|
309
|
-
var _checkSetup8 = checkSetup(container),
|
|
310
|
-
headerActionDiv = _checkSetup8.headerActionDiv;
|
|
284
|
+
}));
|
|
285
|
+
const {
|
|
286
|
+
headerActionDiv
|
|
287
|
+
} = checkSetup(container);
|
|
311
288
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
312
|
-
|
|
289
|
+
const changeButton = headerActionDiv.children[0];
|
|
290
|
+
expect(changeButton.name).toEqual('Change');
|
|
313
291
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
314
292
|
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
293
|
+
expect(changeButton.getAttribute('aria-label')).toEqual(CONFIG.changeAction.aria_label[0].text);
|
|
315
294
|
_react.fireEvent.click(changeButton, {});
|
|
316
295
|
expect(onChangeCalls).toEqual(1);
|
|
317
296
|
expect(onChangeArgs[0]).toMatchObject({
|
|
318
297
|
page: CONFIG.changeAction.page,
|
|
319
298
|
id: ENTRY.id
|
|
320
299
|
});
|
|
321
|
-
|
|
322
|
-
// Check that the inError prop is now false
|
|
323
|
-
expect(inErrorValue).toBe(false);
|
|
324
300
|
});
|
|
325
|
-
it('should use the default label when one is not provided',
|
|
326
|
-
|
|
301
|
+
it('should use the default label when one is not provided', () => {
|
|
302
|
+
const CONFIG = {
|
|
327
303
|
changeAction: {
|
|
328
304
|
page: 'testPage'
|
|
329
305
|
}
|
|
330
306
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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);
|
|
345
323
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
346
|
-
|
|
324
|
+
const changeButton = headerActionDiv.children[0];
|
|
347
325
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
348
326
|
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
349
327
|
});
|
|
350
|
-
it('should not render when no config is provided for it',
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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);
|
|
365
345
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
366
346
|
});
|
|
367
|
-
it('should not render when onChange is not supplied',
|
|
368
|
-
|
|
347
|
+
it('should not render when onChange is not supplied', () => {
|
|
348
|
+
const CONFIG = {
|
|
369
349
|
changeAction: {
|
|
370
350
|
label: 'Change label',
|
|
371
351
|
page: 'testPage'
|
|
372
352
|
}
|
|
373
353
|
};
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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);
|
|
387
369
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
388
370
|
});
|
|
389
371
|
});
|
|
390
|
-
describe('Delete action button',
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
372
|
+
describe('Delete action button', () => {
|
|
373
|
+
let onDeleteArgs = [];
|
|
374
|
+
let onDeleteCalls = 0;
|
|
375
|
+
const ON_DELETE = entry => {
|
|
394
376
|
onDeleteArgs.push(entry);
|
|
395
377
|
onDeleteCalls += 1;
|
|
396
378
|
};
|
|
397
|
-
beforeEach(
|
|
379
|
+
beforeEach(() => {
|
|
398
380
|
onDeleteArgs = [];
|
|
399
381
|
onDeleteCalls = 0;
|
|
400
382
|
});
|
|
401
|
-
it('should render correctly',
|
|
402
|
-
|
|
383
|
+
it('should render correctly', () => {
|
|
384
|
+
const CONFIG = {
|
|
403
385
|
deleteAction: {
|
|
404
|
-
label: 'Delete label'
|
|
386
|
+
label: 'Delete label',
|
|
387
|
+
aria_label: [{
|
|
388
|
+
text: 'testText'
|
|
389
|
+
}]
|
|
405
390
|
}
|
|
406
391
|
};
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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);
|
|
421
408
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
422
|
-
|
|
409
|
+
const deleteButton = headerActionDiv.children[0];
|
|
410
|
+
expect(deleteButton.name).toEqual('Delete');
|
|
423
411
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
424
412
|
expect(deleteButton.textContent).toEqual(CONFIG.deleteAction.label);
|
|
413
|
+
expect(deleteButton.getAttribute('aria-label')).toEqual(CONFIG.deleteAction.aria_label[0].text);
|
|
425
414
|
_react.fireEvent.click(deleteButton, {});
|
|
426
415
|
expect(onDeleteCalls).toEqual(1);
|
|
427
416
|
expect(onDeleteArgs[0]).toMatchObject(ENTRY);
|
|
428
417
|
});
|
|
429
|
-
it('should use the default label when one is not provided',
|
|
430
|
-
|
|
418
|
+
it('should use the default label when one is not provided', () => {
|
|
419
|
+
const CONFIG = {
|
|
431
420
|
deleteAction: {}
|
|
432
421
|
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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);
|
|
447
438
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
448
|
-
|
|
439
|
+
const deleteButton = headerActionDiv.children[0];
|
|
449
440
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
450
441
|
expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
|
|
451
442
|
});
|
|
452
|
-
it('should not render when no config is provided for it',
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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);
|
|
467
460
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
468
461
|
});
|
|
469
|
-
it('should not render when onDelete is not supplied',
|
|
470
|
-
|
|
462
|
+
it('should not render when onDelete is not supplied', () => {
|
|
463
|
+
const CONFIG = {
|
|
471
464
|
deleteAction: {
|
|
472
465
|
label: 'Delete label'
|
|
473
466
|
}
|
|
474
467
|
};
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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);
|
|
488
483
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
489
484
|
});
|
|
490
|
-
it('should correctly render the Details section with entry data',
|
|
491
|
-
|
|
485
|
+
it('should correctly render the Details section with entry data', () => {
|
|
486
|
+
const CONFIG = {
|
|
492
487
|
deleteAction: {
|
|
493
488
|
label: 'Delete label'
|
|
494
489
|
}
|
|
495
490
|
};
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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');
|
|
508
504
|
expect(detailsSection).not.toBeNull();
|
|
509
505
|
expect(detailsSection.textContent).toContain(ENTRY.summaryText);
|
|
510
506
|
});
|
|
511
507
|
});
|
|
512
|
-
describe('Duplicate action button',
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
508
|
+
describe('Duplicate action button', () => {
|
|
509
|
+
let onDuplicateArgs = [];
|
|
510
|
+
let onDuplicateCalls = 0;
|
|
511
|
+
const ON_DUPLICATE = entry => {
|
|
516
512
|
onDuplicateArgs.push(entry);
|
|
517
513
|
onDuplicateCalls += 1;
|
|
518
514
|
};
|
|
519
|
-
beforeEach(
|
|
515
|
+
beforeEach(() => {
|
|
520
516
|
onDuplicateArgs = [];
|
|
521
517
|
onDuplicateCalls = 0;
|
|
522
518
|
});
|
|
523
|
-
it('should render correctly',
|
|
524
|
-
|
|
519
|
+
it('should render correctly', () => {
|
|
520
|
+
const CONFIG = {
|
|
525
521
|
duplicateAction: {
|
|
526
522
|
label: 'Duplicate label'
|
|
527
523
|
}
|
|
528
524
|
};
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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);
|
|
543
541
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
544
|
-
|
|
542
|
+
const duplicateButton = headerActionDiv.children[0];
|
|
543
|
+
expect(duplicateButton.name).toEqual('Duplicate');
|
|
545
544
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
546
545
|
expect(duplicateButton.textContent).toEqual(CONFIG.duplicateAction.label);
|
|
547
546
|
_react.fireEvent.click(duplicateButton, {});
|
|
548
547
|
expect(onDuplicateCalls).toEqual(1);
|
|
549
548
|
expect(onDuplicateArgs[0]).toMatchObject(ENTRY);
|
|
550
549
|
});
|
|
551
|
-
it('should use the default label when one is not provided',
|
|
552
|
-
|
|
550
|
+
it('should use the default label when one is not provided', () => {
|
|
551
|
+
const CONFIG = {
|
|
553
552
|
duplicateAction: {}
|
|
554
553
|
};
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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);
|
|
569
570
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
570
|
-
|
|
571
|
+
const duplicateButton = headerActionDiv.children[0];
|
|
571
572
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
572
573
|
expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
|
|
573
574
|
});
|
|
574
|
-
it('should not render when no config is provided for it',
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
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);
|
|
589
592
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
590
593
|
});
|
|
591
|
-
it('should not render when onDuplicate is not supplied',
|
|
592
|
-
|
|
594
|
+
it('should not render when onDuplicate is not supplied', () => {
|
|
595
|
+
const CONFIG = {
|
|
593
596
|
duplicateAction: {
|
|
594
597
|
label: 'Duplicate label'
|
|
595
598
|
}
|
|
596
599
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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);
|
|
610
615
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
611
616
|
});
|
|
612
617
|
});
|
|
613
|
-
describe('Quick Edit action button',
|
|
614
|
-
|
|
618
|
+
describe('Quick Edit action button', () => {
|
|
619
|
+
const CONFIG = {
|
|
615
620
|
quickEdit: {}
|
|
616
621
|
};
|
|
617
|
-
|
|
622
|
+
const PAGES = [{
|
|
618
623
|
id: 'parentPage',
|
|
619
624
|
name: 'parentPage',
|
|
620
625
|
components: [{
|
|
@@ -637,25 +642,27 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
637
642
|
}]
|
|
638
643
|
}
|
|
639
644
|
}];
|
|
640
|
-
it('should render correctly',
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
headerActionDiv
|
|
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);
|
|
655
661
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
656
662
|
|
|
657
663
|
// Shows edit button but no quick edit
|
|
658
|
-
|
|
664
|
+
const editButton = headerActionDiv.children[0];
|
|
665
|
+
expect(editButton.name).toEqual('QuickEdit');
|
|
659
666
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
660
667
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
661
668
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -663,13 +670,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
663
670
|
// shows quickedit once clicked
|
|
664
671
|
_react.fireEvent.click(editButton, {});
|
|
665
672
|
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
666
|
-
|
|
673
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
667
674
|
expect(quickEdit.textContent).toContain('Test text');
|
|
668
675
|
|
|
669
676
|
// quick edit has proper buttons
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
677
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
678
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
679
|
+
const cancelButton = quickEditButtons.childNodes[1];
|
|
673
680
|
expect(saveButton.textContent).toContain('Save');
|
|
674
681
|
expect(cancelButton.textContent).toContain('Cancel');
|
|
675
682
|
|
|
@@ -677,34 +684,34 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
677
684
|
_react.fireEvent.click(cancelButton, {});
|
|
678
685
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
679
686
|
});
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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);
|
|
696
703
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
697
704
|
});
|
|
698
705
|
});
|
|
699
|
-
describe('Quick Edit errors',
|
|
700
|
-
|
|
706
|
+
describe('Quick Edit errors', () => {
|
|
707
|
+
const CUSTOM_ENTRY = {
|
|
701
708
|
id: '123',
|
|
702
709
|
testText: 'value'
|
|
703
710
|
};
|
|
704
|
-
|
|
711
|
+
const CONFIG = {
|
|
705
712
|
quickEdit: {}
|
|
706
713
|
};
|
|
707
|
-
|
|
714
|
+
const PAGES = [{
|
|
708
715
|
id: 'parentPage',
|
|
709
716
|
name: 'parentPage',
|
|
710
717
|
components: [{
|
|
@@ -729,33 +736,34 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
729
736
|
}]
|
|
730
737
|
}
|
|
731
738
|
}];
|
|
732
|
-
it('should initally show errors passed in from top-level',
|
|
733
|
-
|
|
739
|
+
it('should initally show errors passed in from top-level', () => {
|
|
740
|
+
const TOP_LEVEL_ERRORS = [{
|
|
734
741
|
id: 'testText',
|
|
735
742
|
entryId: '123',
|
|
736
743
|
error: 'top-level error message'
|
|
737
744
|
}];
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
headerActionDiv
|
|
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);
|
|
755
763
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
756
764
|
|
|
757
765
|
// Shows edit button but no quick edit
|
|
758
|
-
|
|
766
|
+
const editButton = headerActionDiv.children[0];
|
|
759
767
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
760
768
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
761
769
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -763,109 +771,85 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
763
771
|
// shows quickedit once clicked
|
|
764
772
|
_react.fireEvent.click(editButton, {});
|
|
765
773
|
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
766
|
-
|
|
774
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
767
775
|
expect(quickEdit.textContent).toContain('Test text');
|
|
768
776
|
|
|
769
777
|
// quick edit is showing top-level error
|
|
770
|
-
|
|
778
|
+
const errorSummary = quickEdit.childNodes[0];
|
|
771
779
|
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
772
780
|
});
|
|
773
|
-
it('should only show errors from validation when it happens, ignoring top-level errors',
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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
|
|
813
|
+
|
|
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');
|
|
800
819
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
expect(editButton.textContent).toEqual('Quick Edit');
|
|
805
|
-
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
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);
|
|
806
823
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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
|
+
});
|
|
812
834
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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
|
+
});
|
|
816
843
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
_context3.next = 18;
|
|
821
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
822
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
823
|
-
while (1) switch (_context.prev = _context.next) {
|
|
824
|
-
case 0:
|
|
825
|
-
_react.fireEvent.change(componentInput, {
|
|
826
|
-
target: {
|
|
827
|
-
value: ''
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
case 1:
|
|
831
|
-
case "end":
|
|
832
|
-
return _context.stop();
|
|
833
|
-
}
|
|
834
|
-
}, _callee);
|
|
835
|
-
})));
|
|
836
|
-
case 18:
|
|
837
|
-
// click 'save' to trigger validation, which will fail as the component
|
|
838
|
-
// cleared above is marked as 'required'.
|
|
839
|
-
quickEditButtons = quickEdit.childNodes[3];
|
|
840
|
-
saveButton = quickEditButtons.childNodes[0];
|
|
841
|
-
expect(saveButton.textContent).toContain('Save');
|
|
842
|
-
_context3.next = 23;
|
|
843
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
844
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
845
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
846
|
-
case 0:
|
|
847
|
-
_react.fireEvent.click(saveButton, {});
|
|
848
|
-
case 1:
|
|
849
|
-
case "end":
|
|
850
|
-
return _context2.stop();
|
|
851
|
-
}
|
|
852
|
-
}, _callee2);
|
|
853
|
-
})));
|
|
854
|
-
case 23:
|
|
855
|
-
// quick edit should now be showing the errors from validation
|
|
856
|
-
expect(errorSummary.textContent).toContain('Custom error message');
|
|
857
|
-
case 24:
|
|
858
|
-
case "end":
|
|
859
|
-
return _context3.stop();
|
|
860
|
-
}
|
|
861
|
-
}, _callee3);
|
|
862
|
-
})));
|
|
844
|
+
// quick edit should now be showing the errors from validation
|
|
845
|
+
expect(errorSummary.textContent).toContain('Custom error message');
|
|
846
|
+
});
|
|
863
847
|
});
|
|
864
|
-
describe('Quick Edit save changes',
|
|
865
|
-
|
|
848
|
+
describe('Quick Edit save changes', () => {
|
|
849
|
+
const CONFIG = {
|
|
866
850
|
quickEdit: {}
|
|
867
851
|
};
|
|
868
|
-
|
|
852
|
+
const PAGES = [{
|
|
869
853
|
id: 'parentPage',
|
|
870
854
|
name: 'parentPage',
|
|
871
855
|
components: [{
|
|
@@ -893,25 +877,26 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
893
877
|
}]
|
|
894
878
|
}
|
|
895
879
|
}];
|
|
896
|
-
it('should render correctly',
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
headerActionDiv
|
|
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);
|
|
911
896
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
912
897
|
|
|
913
898
|
// Shows edit button but no quick edit
|
|
914
|
-
|
|
899
|
+
const editButton = headerActionDiv.children[0];
|
|
915
900
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
916
901
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
917
902
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -919,13 +904,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
919
904
|
// shows quickedit once clicked
|
|
920
905
|
_react.fireEvent.click(editButton, {});
|
|
921
906
|
expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
|
|
922
|
-
|
|
907
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
923
908
|
expect(quickEdit.textContent).toContain('Test text');
|
|
924
909
|
|
|
925
910
|
// quick edit has proper buttons
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
911
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
912
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
913
|
+
const cancelButton = quickEditButtons.childNodes[1];
|
|
929
914
|
expect(saveButton.textContent).toContain('Save');
|
|
930
915
|
expect(cancelButton.textContent).toContain('Cancel');
|
|
931
916
|
|
|
@@ -933,306 +918,321 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
933
918
|
_react.fireEvent.click(cancelButton, {});
|
|
934
919
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
935
920
|
});
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
onSubmit: function onSubmit(type, patch) {
|
|
941
|
-
return ON_SUBMIT_CALLS.push(patch);
|
|
942
|
-
}
|
|
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)
|
|
943
925
|
};
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
headerActionDiv
|
|
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);
|
|
960
943
|
|
|
961
944
|
// Shows edit button but no quick edit
|
|
962
|
-
|
|
945
|
+
const editButton = headerActionDiv.children[0];
|
|
963
946
|
|
|
964
947
|
// shows quickedit once clicked
|
|
965
948
|
_react.fireEvent.click(editButton, {});
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
949
|
+
const quickEdit = container.childNodes[0].childNodes[1];
|
|
950
|
+
const quickEditButtons = quickEdit.childNodes[2];
|
|
951
|
+
const saveButton = quickEditButtons.childNodes[0];
|
|
969
952
|
_react.fireEvent.click(saveButton, {});
|
|
970
953
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
971
954
|
});
|
|
972
|
-
it('should return after local validation if errors are present',
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
childPages: PAGES
|
|
1003
|
-
},
|
|
1004
|
-
inError: true
|
|
1005
|
-
}), {
|
|
1006
|
-
hooks: hooks
|
|
1007
|
-
}), container = _renderWithValidation27.container;
|
|
1008
|
-
_checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
|
|
1009
|
-
editButton = headerActionDiv.children[0];
|
|
1010
|
-
_react.fireEvent.click(editButton, {});
|
|
1011
|
-
quickEdit = container.childNodes[0].childNodes[1];
|
|
1012
|
-
component = quickEdit.childNodes[1];
|
|
1013
|
-
componentInput = component.childNodes[2];
|
|
1014
|
-
quickEditButtons = quickEdit.childNodes[2];
|
|
1015
|
-
saveButton = quickEditButtons.childNodes[0]; // Field has validation to force the length of this field to be greater than 2 so this should fail
|
|
1016
|
-
_context6.next = 15;
|
|
1017
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1018
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1019
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1020
|
-
case 0:
|
|
1021
|
-
_react.fireEvent.change(componentInput, {
|
|
1022
|
-
target: {
|
|
1023
|
-
value: 'a'
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
1026
|
-
case 1:
|
|
1027
|
-
case "end":
|
|
1028
|
-
return _context4.stop();
|
|
1029
|
-
}
|
|
1030
|
-
}, _callee4);
|
|
1031
|
-
})));
|
|
1032
|
-
case 15:
|
|
1033
|
-
_context6.next = 17;
|
|
1034
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
1035
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1036
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
1037
|
-
case 0:
|
|
1038
|
-
_react.fireEvent.click(saveButton, {});
|
|
1039
|
-
case 1:
|
|
1040
|
-
case "end":
|
|
1041
|
-
return _context5.stop();
|
|
1042
|
-
}
|
|
1043
|
-
}, _callee5);
|
|
1044
|
-
})));
|
|
1045
|
-
case 17:
|
|
1046
|
-
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
1047
|
-
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
1048
|
-
case 19:
|
|
1049
|
-
case "end":
|
|
1050
|
-
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
|
|
1051
985
|
}
|
|
1052
|
-
},
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
inError: true
|
|
1089
|
-
}), {
|
|
1090
|
-
hooks: hooks
|
|
1091
|
-
}), container = _renderWithValidation28.container;
|
|
1092
|
-
_checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
|
|
1093
|
-
editButton = headerActionDiv.children[0];
|
|
1094
|
-
_react.fireEvent.click(editButton, {});
|
|
1095
|
-
quickEdit = container.childNodes[0].childNodes[1]; // Make a change
|
|
1096
|
-
component = quickEdit.childNodes[1];
|
|
1097
|
-
componentInput = component.childNodes[2];
|
|
1098
|
-
_react.fireEvent.change(componentInput, {
|
|
1099
|
-
target: {
|
|
1100
|
-
value: 'new value'
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
|
-
quickEditButtons = quickEdit.childNodes[2];
|
|
1104
|
-
saveButton = quickEditButtons.childNodes[0];
|
|
1105
|
-
_context8.next = 16;
|
|
1106
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1107
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1108
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1109
|
-
case 0:
|
|
1110
|
-
_react.fireEvent.click(saveButton, {});
|
|
1111
|
-
case 1:
|
|
1112
|
-
case "end":
|
|
1113
|
-
return _context7.stop();
|
|
1114
|
-
}
|
|
1115
|
-
}, _callee7);
|
|
1116
|
-
})));
|
|
1117
|
-
case 16:
|
|
1118
|
-
expect(ON_SUBMIT_CALLS[0]).toEqual({
|
|
1119
|
-
testText: 'new value'
|
|
1120
|
-
});
|
|
1121
|
-
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
1122
|
-
case 18:
|
|
1123
|
-
case "end":
|
|
1124
|
-
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
|
+
}]);
|
|
1125
1022
|
}
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
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
|
|
1046
|
+
}
|
|
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'
|
|
1063
|
+
}
|
|
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];
|
|
1198
1184
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
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'
|
|
1204
1191
|
}
|
|
1205
|
-
}
|
|
1206
|
-
|
|
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
|
+
});
|
|
1207
1205
|
});
|
|
1208
|
-
describe('Details prop behavior',
|
|
1209
|
-
it('should render the provided details',
|
|
1210
|
-
|
|
1211
|
-
|
|
1206
|
+
describe('Details prop behavior', () => {
|
|
1207
|
+
it('should render the provided details', () => {
|
|
1208
|
+
const DETAILS = 'Sample details';
|
|
1209
|
+
const CONFIG = {
|
|
1212
1210
|
title: 'Title',
|
|
1213
1211
|
details: DETAILS
|
|
1214
1212
|
};
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
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];
|
|
1230
1230
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
1231
1231
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
1232
1232
|
expect(headerDetails.textContent).toEqual(DETAILS);
|
|
1233
1233
|
});
|
|
1234
|
-
it('should render conditional details',
|
|
1235
|
-
|
|
1234
|
+
it('should render conditional details', () => {
|
|
1235
|
+
const CONFIG = {
|
|
1236
1236
|
title: 'Title',
|
|
1237
1237
|
details: [{
|
|
1238
1238
|
text: 'Details A',
|
|
@@ -1250,119 +1250,130 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1250
1250
|
}]
|
|
1251
1251
|
}]
|
|
1252
1252
|
};
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
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];
|
|
1270
1273
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
1271
1274
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
1272
1275
|
expect(headerDetails.textContent).toEqual('Details B');
|
|
1273
1276
|
});
|
|
1274
|
-
it('should not render details when they are empty',
|
|
1275
|
-
|
|
1277
|
+
it('should not render details when they are empty', () => {
|
|
1278
|
+
const CONFIG = {
|
|
1276
1279
|
title: 'Title',
|
|
1277
1280
|
details: ''
|
|
1278
1281
|
};
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
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);
|
|
1293
1298
|
// If no details are provided, we expect only the header title to be rendered.
|
|
1294
1299
|
expect(headerContentDiv.children.length).toEqual(1);
|
|
1295
|
-
|
|
1300
|
+
const headerTitle = headerContentDiv.children[0];
|
|
1296
1301
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
1297
1302
|
});
|
|
1298
|
-
it('should render the interpolated details',
|
|
1299
|
-
|
|
1300
|
-
|
|
1303
|
+
it('should render the interpolated details', () => {
|
|
1304
|
+
const DETAILS = 'Full {label}';
|
|
1305
|
+
const INTERPOLATED_ENTRY = {
|
|
1306
|
+
...ENTRY,
|
|
1301
1307
|
label: 'Details'
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1308
|
+
};
|
|
1309
|
+
const CONFIG = {
|
|
1304
1310
|
title: 'Title',
|
|
1305
1311
|
details: DETAILS
|
|
1306
1312
|
};
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
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);
|
|
1323
1331
|
expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
|
|
1324
1332
|
});
|
|
1325
|
-
it('should not render the details div if config.details is not provided',
|
|
1326
|
-
|
|
1333
|
+
it('should not render the details div if config.details is not provided', () => {
|
|
1334
|
+
const CONFIG = {
|
|
1327
1335
|
title: 'Title'
|
|
1328
1336
|
};
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
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"));
|
|
1344
1354
|
expect(headerDetails).toBeNull();
|
|
1345
1355
|
});
|
|
1346
|
-
it('should not render the entire details section when hideDetails prop is true',
|
|
1347
|
-
|
|
1348
|
-
|
|
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 = {
|
|
1349
1359
|
title: 'Title',
|
|
1350
1360
|
details: DETAILS
|
|
1351
1361
|
};
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
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');
|
|
1366
1377
|
expect(detailsComponent).toBeNull();
|
|
1367
1378
|
});
|
|
1368
1379
|
});
|