@ukhomeoffice/cop-react-form-renderer 6.0.6-peter → 6.7.0-alpha

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