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