@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +22 -16
  2. package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
  5. package/dist/components/CollectionPage/CollectionPage.js +63 -73
  6. package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
  7. package/dist/components/CollectionSummary/BannerStrip.js +13 -13
  8. package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
  9. package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
  10. package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
  11. package/dist/components/CollectionSummary/Confirmation.js +12 -14
  12. package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
  13. package/dist/components/CollectionSummary/RenderListView.js +52 -46
  14. package/dist/components/CollectionSummary/RenderListView.scss +1 -1
  15. package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
  16. package/dist/components/CollectionSummary/SummaryCard.js +152 -110
  17. package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
  18. package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
  19. package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
  20. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
  21. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
  22. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
  23. package/dist/components/FormComponent/Collection.js +108 -74
  24. package/dist/components/FormComponent/Collection.test.js +1081 -909
  25. package/dist/components/FormComponent/Container.js +39 -40
  26. package/dist/components/FormComponent/Container.test.js +412 -312
  27. package/dist/components/FormComponent/FormComponent.js +72 -69
  28. package/dist/components/FormComponent/FormComponent.test.js +414 -353
  29. package/dist/components/FormComponent/helpers/addLabel.js +7 -4
  30. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  31. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
  32. package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
  33. package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
  34. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
  35. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
  36. package/dist/components/FormComponent/helpers/index.js +4 -4
  37. package/dist/components/FormPage/FormPage.js +80 -65
  38. package/dist/components/FormPage/FormPage.test.js +163 -127
  39. package/dist/components/FormRenderer/FormRenderer.js +180 -143
  40. package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
  41. package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
  42. package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
  43. package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
  44. package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
  45. package/dist/components/FormRenderer/handlers/index.js +1 -1
  46. package/dist/components/FormRenderer/handlers/navigate.js +3 -3
  47. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  48. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  49. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
  50. package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
  51. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
  52. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
  53. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
  54. package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
  55. package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
  56. package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
  57. package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
  58. package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
  59. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
  60. package/dist/components/FormRenderer/helpers/getPage.js +4 -2
  61. package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
  62. package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
  63. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
  64. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
  65. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +97 -103
  66. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
  67. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -71
  68. package/dist/components/FormRenderer/helpers/index.js +1 -1
  69. package/dist/components/FormRenderer/onCYAAction.js +51 -59
  70. package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
  71. package/dist/components/FormRenderer/onPageAction.js +39 -43
  72. package/dist/components/FormRenderer/onPageAction.test.js +208 -223
  73. package/dist/components/FormRenderer/onTaskAction.js +13 -9
  74. package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
  75. package/dist/components/PageActions/ActionButton.js +15 -12
  76. package/dist/components/PageActions/ActionButton.test.js +78 -56
  77. package/dist/components/PageActions/PageActions.js +10 -10
  78. package/dist/components/PageActions/PageActions.test.js +115 -86
  79. package/dist/components/SummaryList/GroupAction.js +17 -9
  80. package/dist/components/SummaryList/GroupAction.test.js +33 -37
  81. package/dist/components/SummaryList/RowAction.js +16 -11
  82. package/dist/components/SummaryList/RowAction.test.js +33 -37
  83. package/dist/components/SummaryList/SummaryList.js +34 -21
  84. package/dist/components/SummaryList/SummaryList.scss +15 -0
  85. package/dist/components/SummaryList/SummaryList.test.js +226 -143
  86. package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
  87. package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
  88. package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
  89. package/dist/components/SummaryList/SummaryListRow.js +4 -6
  90. package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
  91. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
  92. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
  93. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
  94. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
  95. package/dist/components/SummaryList/helpers/index.js +1 -1
  96. package/dist/components/TaskList/Task.js +29 -19
  97. package/dist/components/TaskList/Task.test.js +76 -83
  98. package/dist/components/TaskList/TaskList.js +92 -49
  99. package/dist/components/TaskList/TaskList.scss +24 -0
  100. package/dist/components/TaskList/TaskList.test.js +255 -113
  101. package/dist/components/TaskList/TaskState.js +5 -7
  102. package/dist/components/TaskList/TaskState.test.js +45 -52
  103. package/dist/components/index.js +7 -7
  104. package/dist/context/HooksContext/HooksContext.js +80 -57
  105. package/dist/context/HooksContext/HooksContext.test.js +35 -26
  106. package/dist/context/HooksContext/index.js +4 -3
  107. package/dist/context/ValidationContext/ValidationContext.js +94 -43
  108. package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
  109. package/dist/context/ValidationContext/index.js +4 -3
  110. package/dist/context/index.js +2 -2
  111. package/dist/hooks/index.js +10 -9
  112. package/dist/hooks/useAxios.js +40 -14
  113. package/dist/hooks/useGetRequest.js +97 -61
  114. package/dist/hooks/useHooks.js +3 -1
  115. package/dist/hooks/useRefData.js +39 -26
  116. package/dist/hooks/useValidation.js +3 -1
  117. package/dist/index.js +14 -13
  118. package/dist/models/CollectionLabels.js +1 -1
  119. package/dist/models/ComponentTypes.js +25 -25
  120. package/dist/models/EventTypes.js +4 -4
  121. package/dist/models/FormPages.js +4 -4
  122. package/dist/models/FormTypes.js +8 -8
  123. package/dist/models/HubFormats.js +3 -3
  124. package/dist/models/PageAction.js +38 -44
  125. package/dist/models/TaskStates.js +28 -29
  126. package/dist/models/index.js +9 -9
  127. package/dist/setupTests.js +31 -30
  128. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  129. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
  130. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
  131. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
  132. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
  133. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
  134. package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
  135. package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
  136. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
  137. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
  138. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
  139. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +61 -58
  140. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
  141. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
  142. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
  143. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
  144. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
  145. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
  146. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +42 -0
  147. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
  148. package/dist/utils/CheckYourAnswers/index.js +1 -1
  149. package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
  150. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
  151. package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
  152. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
  153. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
  154. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -17
  155. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
  156. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
  157. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  158. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
  159. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
  160. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
  161. package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
  162. package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
  163. package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
  164. package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
  165. package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
  166. package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
  167. package/dist/utils/CollectionPage/index.js +1 -1
  168. package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
  169. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
  170. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
  171. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
  172. package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
  173. package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
  174. package/dist/utils/Component/addShowWhen.js +8 -4
  175. package/dist/utils/Component/addShowWhen.test.js +37 -37
  176. package/dist/utils/Component/applyToComponentTree.js +18 -18
  177. package/dist/utils/Component/applyToComponentTree.test.js +32 -27
  178. package/dist/utils/Component/cleanAttributes.js +13 -10
  179. package/dist/utils/Component/cleanAttributes.test.js +18 -17
  180. package/dist/utils/Component/elevateNestedComponents.js +7 -6
  181. package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
  182. package/dist/utils/Component/getComponent.js +94 -88
  183. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
  184. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
  185. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
  186. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
  187. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
  188. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
  189. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
  190. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
  191. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
  192. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
  193. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
  194. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
  195. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
  196. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
  197. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
  198. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +72 -57
  199. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
  200. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
  201. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
  202. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
  203. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
  204. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
  205. package/dist/utils/Component/getDefaultValue.js +8 -6
  206. package/dist/utils/Component/getDefaultValue.test.js +12 -12
  207. package/dist/utils/Component/getDefaultValueFromConfig.js +21 -22
  208. package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
  209. package/dist/utils/Component/index.js +1 -1
  210. package/dist/utils/Component/isEditable.js +4 -2
  211. package/dist/utils/Component/isEditable.test.js +15 -14
  212. package/dist/utils/Component/optionIsSelected.js +6 -1
  213. package/dist/utils/Component/optionIsSelected.test.js +35 -9
  214. package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
  215. package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
  216. package/dist/utils/Component/showComponent.js +1 -1
  217. package/dist/utils/Component/showComponent.test.js +28 -28
  218. package/dist/utils/Component/wrapInFormGroup.js +2 -2
  219. package/dist/utils/Condition/index.js +1 -1
  220. package/dist/utils/Condition/meetsAllConditions.js +8 -8
  221. package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
  222. package/dist/utils/Condition/meetsCondition.js +25 -16
  223. package/dist/utils/Condition/meetsCondition.test.js +402 -402
  224. package/dist/utils/Condition/meetsOneCondition.js +5 -5
  225. package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
  226. package/dist/utils/Condition/setupConditions.js +18 -13
  227. package/dist/utils/Condition/setupConditions.test.js +7 -7
  228. package/dist/utils/Container/getEditableComponents.js +5 -3
  229. package/dist/utils/Container/getEditableComponents.test.js +45 -43
  230. package/dist/utils/Container/index.js +1 -1
  231. package/dist/utils/Container/setupNesting.js +20 -16
  232. package/dist/utils/Container/setupNesting.test.js +30 -27
  233. package/dist/utils/Container/showContainer.js +7 -3
  234. package/dist/utils/Container/showContainer.test.js +30 -30
  235. package/dist/utils/Data/applyFormula.js +48 -38
  236. package/dist/utils/Data/applyFormula.test.js +20 -20
  237. package/dist/utils/Data/getAutocompleteSource.js +26 -18
  238. package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
  239. package/dist/utils/Data/getDataPath.js +28 -18
  240. package/dist/utils/Data/getDataPath.test.js +12 -12
  241. package/dist/utils/Data/getOptions.js +30 -24
  242. package/dist/utils/Data/getOptions.test.js +27 -27
  243. package/dist/utils/Data/getSourceData.js +19 -6
  244. package/dist/utils/Data/getSourceData.test.js +80 -84
  245. package/dist/utils/Data/index.js +1 -1
  246. package/dist/utils/Data/nestInRefdataOptions.js +16 -9
  247. package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
  248. package/dist/utils/Data/refDataToOptions.js +13 -10
  249. package/dist/utils/Data/refDataToOptions.test.js +19 -19
  250. package/dist/utils/Data/setDataItem.js +8 -7
  251. package/dist/utils/Data/setDataItem.test.js +37 -37
  252. package/dist/utils/Data/setupFormData.js +21 -13
  253. package/dist/utils/Data/setupFormData.test.js +50 -51
  254. package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
  255. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
  256. package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
  257. package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
  258. package/dist/utils/FormPage/getConditionalText.js +3 -3
  259. package/dist/utils/FormPage/getConditionalText.test.js +29 -29
  260. package/dist/utils/FormPage/getFormPage.js +16 -15
  261. package/dist/utils/FormPage/getFormPage.test.js +46 -47
  262. package/dist/utils/FormPage/getFormPages.js +12 -7
  263. package/dist/utils/FormPage/getFormPages.test.js +23 -20
  264. package/dist/utils/FormPage/getPageActions.js +15 -9
  265. package/dist/utils/FormPage/getPageActions.test.js +32 -32
  266. package/dist/utils/FormPage/getParagraphFromText.js +7 -5
  267. package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
  268. package/dist/utils/FormPage/index.js +4 -2
  269. package/dist/utils/FormPage/showFormPage.js +7 -3
  270. package/dist/utils/FormPage/showFormPage.test.js +32 -32
  271. package/dist/utils/FormPage/showFormPageCYA.js +1 -1
  272. package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
  273. package/dist/utils/FormPage/useComponent.js +28 -21
  274. package/dist/utils/FormPage/useComponent.test.js +79 -77
  275. package/dist/utils/Format/formatData.js +1 -1
  276. package/dist/utils/Format/formatData.test.js +18 -18
  277. package/dist/utils/Format/formatDataForComponent.js +6 -5
  278. package/dist/utils/Format/formatDataForComponent.test.js +78 -50
  279. package/dist/utils/Format/formatDataForForm.js +8 -6
  280. package/dist/utils/Format/formatDataForForm.test.js +16 -13
  281. package/dist/utils/Format/formatDataForPage.js +5 -4
  282. package/dist/utils/Format/formatDataForPage.test.js +25 -20
  283. package/dist/utils/Format/index.js +1 -1
  284. package/dist/utils/Hub/getFormHub.js +1 -1
  285. package/dist/utils/Hub/getFormHub.test.js +31 -28
  286. package/dist/utils/Hub/index.js +1 -1
  287. package/dist/utils/Meta/constants.js +2 -2
  288. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  289. package/dist/utils/Meta/documents/getDocuments.test.js +16 -24
  290. package/dist/utils/Meta/documents/index.js +1 -1
  291. package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
  292. package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
  293. package/dist/utils/Meta/index.js +1 -1
  294. package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
  295. package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
  296. package/dist/utils/Operate/getFirstOf.js +5 -5
  297. package/dist/utils/Operate/getFirstOf.test.js +31 -31
  298. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
  299. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +52 -46
  300. package/dist/utils/Operate/getLength.js +50 -0
  301. package/dist/utils/Operate/getLength.test.js +89 -0
  302. package/dist/utils/Operate/index.js +1 -1
  303. package/dist/utils/Operate/persistValueInFormData.js +3 -3
  304. package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
  305. package/dist/utils/Operate/runPageOperations.js +9 -7
  306. package/dist/utils/Operate/runPageOperations.test.js +36 -35
  307. package/dist/utils/Operate/setValueInFormData.js +2 -2
  308. package/dist/utils/Operate/setValueInFormData.test.js +16 -16
  309. package/dist/utils/Operate/shouldRun.js +6 -6
  310. package/dist/utils/Operate/shouldRun.test.js +27 -21
  311. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  312. package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
  313. package/dist/utils/Validate/additional/index.js +6 -6
  314. package/dist/utils/Validate/additional/index.test.js +12 -12
  315. package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
  316. package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
  317. package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
  318. package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
  319. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
  320. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
  321. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  322. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
  323. package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
  324. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
  325. package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
  326. package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
  327. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  328. package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
  329. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  330. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
  331. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  332. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
  333. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  334. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
  335. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +4 -4
  336. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
  337. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  338. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
  339. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  340. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
  341. package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
  342. package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
  343. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  344. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
  345. package/dist/utils/Validate/additional/utils.js +22 -9
  346. package/dist/utils/Validate/index.js +1 -1
  347. package/dist/utils/Validate/validateCollection.js +25 -19
  348. package/dist/utils/Validate/validateCollection.test.js +66 -74
  349. package/dist/utils/Validate/validateComponent.js +21 -18
  350. package/dist/utils/Validate/validateComponent.test.js +176 -166
  351. package/dist/utils/Validate/validateContainer.js +20 -15
  352. package/dist/utils/Validate/validateContainer.test.js +52 -58
  353. package/dist/utils/Validate/validateDate.js +21 -15
  354. package/dist/utils/Validate/validateDate.test.js +32 -31
  355. package/dist/utils/Validate/validateEmail.js +8 -6
  356. package/dist/utils/Validate/validateEmail.test.js +25 -25
  357. package/dist/utils/Validate/validateMultifile.js +7 -5
  358. package/dist/utils/Validate/validateMultifile.test.js +18 -17
  359. package/dist/utils/Validate/validatePage.js +22 -19
  360. package/dist/utils/Validate/validatePage.test.js +203 -215
  361. package/dist/utils/Validate/validateRegex.js +5 -3
  362. package/dist/utils/Validate/validateRegex.test.js +14 -14
  363. package/dist/utils/Validate/validateRequired.js +6 -4
  364. package/dist/utils/Validate/validateRequired.test.js +18 -18
  365. package/dist/utils/Validate/validateTextArea.js +6 -4
  366. package/dist/utils/Validate/validateTextArea.test.js +20 -20
  367. package/dist/utils/Validate/validateTime.js +26 -11
  368. package/dist/utils/Validate/validateTime.test.js +62 -16
  369. package/dist/utils/index.js +9 -7
  370. package/package.json +2 -2
  371. package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
  372. package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
@@ -4,16 +4,19 @@ var _react = _interopRequireDefault(require("react"));
4
4
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
5
5
  var _setupTests = require("../../setupTests");
6
6
  var _SummaryCardDetails = _interopRequireWildcard(require("./SummaryCardDetails"));
7
- 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); }
8
- 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; }
7
+ 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); }
8
+ 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; }
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- // Global imports.
11
-
10
+ 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); }
11
+ 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; }
12
+ 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; }
13
+ 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; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Global imports.
12
16
  // Local imports.
13
-
14
- describe('components.CollectionSummary.SummaryCardDetails', () => {
15
- const classes = _copReactComponents.Utils.classBuilder(_SummaryCardDetails.DEFAULT_CLASS, [], '');
16
- const ENTRY = {
17
+ describe('components.CollectionSummary.SummaryCardDetails', function () {
18
+ var classes = _copReactComponents.Utils.classBuilder(_SummaryCardDetails.DEFAULT_CLASS, [], '');
19
+ var ENTRY = {
17
20
  id: '001',
18
21
  bannerText: 'A banner',
19
22
  titleText: 'A title',
@@ -30,8 +33,8 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
30
33
  childField2: 'bravo'
31
34
  }]
32
35
  };
33
- it('should render sections and fields based on summaryLayout config', () => {
34
- const CHILD_PAGES = [{
36
+ it('should render sections and fields based on summaryLayout config', function () {
37
+ var CHILD_PAGES = [{
35
38
  summaryLayout: {
36
39
  sections: [{
37
40
  title: 'Section 1',
@@ -55,35 +58,36 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
55
58
  fieldId: 'fieldC'
56
59
  }]
57
60
  }];
58
- const MASTER_PAGE = {
61
+ var MASTER_PAGE = {
59
62
  childPages: CHILD_PAGES
60
63
  };
61
- const {
62
- container
63
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
64
- masterPage: MASTER_PAGE,
65
- childMasterPages: [],
66
- formData: {},
67
- entryData: ENTRY
68
- }));
64
+ var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
65
+ masterPage: MASTER_PAGE,
66
+ childMasterPages: [],
67
+ formData: {},
68
+ entryData: ENTRY
69
+ })),
70
+ container = _renderWithValidation.container;
69
71
 
70
72
  // Function to find an element by its text content
71
73
  function getByTextContent(parent, text) {
72
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
74
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
75
+ return el.textContent === text;
76
+ });
73
77
  }
74
78
 
75
79
  // Check for section titles
76
- const section1Title = getByTextContent(container, 'Section 1');
77
- const section2Title = getByTextContent(container, 'Section 2');
80
+ var section1Title = getByTextContent(container, 'Section 1');
81
+ var section2Title = getByTextContent(container, 'Section 2');
78
82
  expect(section1Title).not.toBeUndefined();
79
83
  expect(section2Title).not.toBeUndefined();
80
- const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
84
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
81
85
  expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
82
- const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
86
+ var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
83
87
  expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
84
88
  });
85
- it('should render sections containing containers based on summaryLayout config', () => {
86
- const CHILD_PAGES = [{
89
+ it('should render sections containing containers based on summaryLayout config', function () {
90
+ var CHILD_PAGES = [{
87
91
  summaryLayout: {
88
92
  sections: [{
89
93
  title: 'Section 1',
@@ -108,7 +112,7 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
108
112
  }]
109
113
  }]
110
114
  }];
111
- const CONTAINER_ENTRY = {
115
+ var CONTAINER_ENTRY = {
112
116
  id: '001',
113
117
  bannerText: 'A banner',
114
118
  titleText: 'A title',
@@ -121,29 +125,30 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
121
125
  subThree: 'charlie'
122
126
  }
123
127
  };
124
- const MASTER_PAGE = {
128
+ var MASTER_PAGE = {
125
129
  childPages: CHILD_PAGES
126
130
  };
127
- const {
128
- container
129
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
130
- masterPage: MASTER_PAGE,
131
- childMasterPages: [],
132
- formData: {},
133
- entryData: CONTAINER_ENTRY
134
- }));
131
+ var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
132
+ masterPage: MASTER_PAGE,
133
+ childMasterPages: [],
134
+ formData: {},
135
+ entryData: CONTAINER_ENTRY
136
+ })),
137
+ container = _renderWithValidation2.container;
135
138
 
136
139
  // Function to find an element by its text content
137
140
  function getByTextContent(parent, text) {
138
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
141
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
142
+ return el.textContent === text;
143
+ });
139
144
  }
140
145
 
141
146
  // Check for section title
142
- const section1Title = getByTextContent(container, 'Section 1');
147
+ var section1Title = getByTextContent(container, 'Section 1');
143
148
  expect(section1Title).not.toBeUndefined();
144
149
 
145
150
  // All three subcomponents from the container should have labels and values displayed
146
- const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
151
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
147
152
  expect(section1Content.textContent).toContain('subOneLabel');
148
153
  expect(section1Content.textContent).toContain('alpha');
149
154
  expect(section1Content.textContent).toContain('subTwoLabel');
@@ -151,8 +156,96 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
151
156
  expect(section1Content.textContent).toContain('subThreeLabel');
152
157
  expect(section1Content.textContent).toContain('charlie');
153
158
  });
154
- it('should render sections if they have show_when checks and pass them', () => {
155
- const CHILD_PAGES = [{
159
+ it('should render sections containing collections with dynamic titles based on summaryLayout config', function () {
160
+ var FORM_DATA = {
161
+ dummyTitleContent: "Kellogg's"
162
+ };
163
+ var CHILD_PAGES = [{
164
+ summaryLayout: {
165
+ sections: [{
166
+ // eslint-disable-next-line no-template-curly-in-string
167
+ title: 'Section 1 - ${dummyTitleContent}',
168
+ columns: [{
169
+ fields: ['collectionComponent']
170
+ }]
171
+ }]
172
+ },
173
+ formData: FORM_DATA,
174
+ components: [{
175
+ fieldId: 'collectionComponent',
176
+ id: 'collectionComponent',
177
+ type: 'collection',
178
+ label: 'Collection',
179
+ labels: {
180
+ item: 'north'
181
+ },
182
+ item: [{
183
+ id: 'north',
184
+ fieldId: 'north',
185
+ type: 'text',
186
+ label: 'North',
187
+ required: true
188
+ }, {
189
+ id: 'east',
190
+ fieldId: 'east',
191
+ type: 'text',
192
+ label: 'East',
193
+ required: true
194
+ }, {
195
+ id: 'south',
196
+ fieldId: 'south',
197
+ type: 'text',
198
+ label: 'South',
199
+ required: true
200
+ }, {
201
+ id: 'west',
202
+ fieldId: 'west',
203
+ type: 'text',
204
+ label: 'West',
205
+ required: true
206
+ }]
207
+ }]
208
+ }];
209
+ var COLLECTION_ENTRY = {
210
+ summaryText: 'Full details',
211
+ collectionComponent: [{
212
+ north: 'Never',
213
+ east: 'Eat',
214
+ south: 'Shredded',
215
+ west: 'Wheat'
216
+ }]
217
+ };
218
+ var MASTER_PAGE = {
219
+ childPages: CHILD_PAGES
220
+ };
221
+ var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
222
+ masterPage: MASTER_PAGE,
223
+ childMasterPages: [],
224
+ formData: {},
225
+ entryData: COLLECTION_ENTRY
226
+ })),
227
+ container = _renderWithValidation3.container;
228
+
229
+ // Check for section title
230
+ var section1Title = container.querySelector(".".concat(classes('section-title')));
231
+ expect(section1Title).not.toBeUndefined();
232
+
233
+ // Check for embedded variables in title
234
+ expect(section1Title.textContent).toEqual("Section 1 - Kellogg's");
235
+
236
+ // All four subcomponents from the container should have labels and values displayed
237
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
238
+ expect(section1Content.textContent).toContain('North');
239
+ expect(section1Content.textContent).toContain('Never');
240
+ expect(section1Content.textContent).toContain('East');
241
+ expect(section1Content.textContent).toContain('Eat');
242
+ expect(section1Content.textContent).toContain('South');
243
+ expect(section1Content.textContent).toContain('Shredded');
244
+ expect(section1Content.textContent).toContain('West');
245
+ expect(section1Content.textContent).toContain('Wheat');
246
+ });
247
+ it('should render sections if they have show_when checks and pass them', function () {
248
+ var CHILD_PAGES = [{
156
249
  summaryLayout: {
157
250
  sections: [{
158
251
  title: 'Section 1',
@@ -181,39 +274,39 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
181
274
  fieldId: 'fieldC'
182
275
  }]
183
276
  }];
184
- const MASTER_PAGE = {
277
+ var MASTER_PAGE = {
185
278
  childPages: CHILD_PAGES
186
279
  };
187
- const CUSTOM_ENTRY = {
188
- ...ENTRY,
280
+ var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
189
281
  showSection1: true
190
- };
191
- const {
192
- container
193
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
194
- masterPage: MASTER_PAGE,
195
- childMasterPages: [],
196
- formData: {},
197
- entryData: CUSTOM_ENTRY
198
- }));
282
+ });
283
+ var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
284
+ masterPage: MASTER_PAGE,
285
+ childMasterPages: [],
286
+ formData: {},
287
+ entryData: CUSTOM_ENTRY
288
+ })),
289
+ container = _renderWithValidation4.container;
199
290
 
200
291
  // Function to find an element by its text content
201
292
  function getByTextContent(parent, text) {
202
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
293
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
294
+ return el.textContent === text;
295
+ });
203
296
  }
204
297
 
205
298
  // Check for section titles
206
- const section1Title = getByTextContent(container, 'Section 1');
207
- const section2Title = getByTextContent(container, 'Section 2');
299
+ var section1Title = getByTextContent(container, 'Section 1');
300
+ var section2Title = getByTextContent(container, 'Section 2');
208
301
  expect(section1Title).not.toBeUndefined();
209
302
  expect(section2Title).not.toBeUndefined();
210
- const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
303
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
211
304
  expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
212
- const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
305
+ var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
213
306
  expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
214
307
  });
215
- it('should not render sections if they have show_when checks and fail them', () => {
216
- const CHILD_PAGES = [{
308
+ it('should not render sections if they have show_when checks and fail them', function () {
309
+ var CHILD_PAGES = [{
217
310
  summaryLayout: {
218
311
  sections: [{
219
312
  title: 'Section 1',
@@ -242,37 +335,37 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
242
335
  fieldId: 'fieldC'
243
336
  }]
244
337
  }];
245
- const MASTER_PAGE = {
338
+ var MASTER_PAGE = {
246
339
  childPages: CHILD_PAGES
247
340
  };
248
- const CUSTOM_ENTRY = {
249
- ...ENTRY,
341
+ var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
250
342
  showSection1: false
251
- };
252
- const {
253
- container
254
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
255
- masterPage: MASTER_PAGE,
256
- childMasterPages: [],
257
- formData: {},
258
- entryData: CUSTOM_ENTRY
259
- }));
343
+ });
344
+ var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
345
+ masterPage: MASTER_PAGE,
346
+ childMasterPages: [],
347
+ formData: {},
348
+ entryData: CUSTOM_ENTRY
349
+ })),
350
+ container = _renderWithValidation5.container;
260
351
 
261
352
  // Function to find an element by its text content
262
353
  function getByTextContent(parent, text) {
263
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
354
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
355
+ return el.textContent === text;
356
+ });
264
357
  }
265
358
 
266
359
  // Check for section titles
267
- const section1Title = getByTextContent(container, 'Section 1');
268
- const section2Title = getByTextContent(container, 'Section 2');
360
+ var section1Title = getByTextContent(container, 'Section 1');
361
+ var section2Title = getByTextContent(container, 'Section 2');
269
362
  expect(section1Title).toBeUndefined();
270
363
  expect(section2Title).not.toBeUndefined();
271
- const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
364
+ var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
272
365
  expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
273
366
  });
274
- it('should not render components that fail show_when checks', () => {
275
- const CHILD_PAGES = [{
367
+ it('should not render components that fail show_when checks', function () {
368
+ var CHILD_PAGES = [{
276
369
  summaryLayout: {
277
370
  sections: [{
278
371
  title: 'Section 1',
@@ -301,36 +394,37 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
301
394
  fieldId: 'fieldC'
302
395
  }]
303
396
  }];
304
- const MASTER_PAGE = {
397
+ var MASTER_PAGE = {
305
398
  childPages: CHILD_PAGES
306
399
  };
307
- const {
308
- container
309
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
310
- masterPage: MASTER_PAGE,
311
- childMasterPages: [],
312
- formData: {},
313
- entryData: ENTRY
314
- }));
400
+ var _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
401
+ masterPage: MASTER_PAGE,
402
+ childMasterPages: [],
403
+ formData: {},
404
+ entryData: ENTRY
405
+ })),
406
+ container = _renderWithValidation6.container;
315
407
 
316
408
  // Function to find an element by its text content
317
409
  function getByTextContent(parent, text) {
318
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
410
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
411
+ return el.textContent === text;
412
+ });
319
413
  }
320
414
 
321
415
  // Check for section titles
322
- const section1Title = getByTextContent(container, 'Section 1');
323
- const section2Title = getByTextContent(container, 'Section 2');
416
+ var section1Title = getByTextContent(container, 'Section 1');
417
+ var section2Title = getByTextContent(container, 'Section 2');
324
418
  expect(section1Title).not.toBeUndefined();
325
419
  expect(section2Title).not.toBeUndefined();
326
- const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
420
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
327
421
  expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1); // Just Field A, Field B should be hidden.
328
422
 
329
- const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
423
+ var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
330
424
  expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
331
425
  });
332
- it('should not render sections on pages that fail show_when checks', () => {
333
- const CHILD_PAGES = [{
426
+ it('should not render sections on pages that fail show_when checks', function () {
427
+ var CHILD_PAGES = [{
334
428
  show_when: [{
335
429
  field: 'testField',
336
430
  op: '=',
@@ -364,37 +458,88 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
364
458
  fieldId: 'fieldC'
365
459
  }]
366
460
  }];
367
- const MASTER_PAGE = {
461
+ var MASTER_PAGE = {
368
462
  childPages: CHILD_PAGES
369
463
  };
370
- const CUSTOM_ENTRY = {
371
- ...ENTRY,
464
+ var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
372
465
  showSection1: false
373
- };
374
- const {
375
- container
376
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
377
- masterPage: MASTER_PAGE,
378
- childMasterPages: [],
379
- formData: {
380
- testField: false
381
- },
382
- entryData: CUSTOM_ENTRY
383
- }));
466
+ });
467
+ var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
468
+ masterPage: MASTER_PAGE,
469
+ childMasterPages: [],
470
+ formData: {
471
+ testField: false
472
+ },
473
+ entryData: CUSTOM_ENTRY
474
+ })),
475
+ container = _renderWithValidation7.container;
384
476
 
385
477
  // Function to find an element by its text content
386
478
  function getByTextContent(parent, text) {
387
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
479
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
480
+ return el.textContent === text;
481
+ });
388
482
  }
389
483
 
390
484
  // Check for section titles
391
- const section1Title = getByTextContent(container, 'Section 1');
392
- const section2Title = getByTextContent(container, 'Section 2');
485
+ var section1Title = getByTextContent(container, 'Section 1');
486
+ var section2Title = getByTextContent(container, 'Section 2');
393
487
  expect(section1Title).toBeUndefined();
394
488
  expect(section2Title).toBeUndefined();
395
489
  });
396
- it('should render child collections', () => {
397
- const CHILD_MASTER_PAGES = [{
490
+ it('should not render columns that fail show_when checks', function () {
491
+ var CHILD_PAGES = [{
492
+ summaryLayout: {
493
+ sections: [{
494
+ title: 'Section 1',
495
+ columns: [{
496
+ fields: ['fieldA'],
497
+ show_when: [{
498
+ field: 'showSection1',
499
+ op: '=',
500
+ value: true
501
+ }]
502
+ }, {
503
+ fields: ['fieldB']
504
+ }]
505
+ }]
506
+ },
507
+ components: [{
508
+ fieldId: 'fieldA',
509
+ label: 'fieldA'
510
+ }, {
511
+ fieldId: 'fieldB',
512
+ label: 'fieldB'
513
+ }]
514
+ }];
515
+ var MASTER_PAGE = {
516
+ childPages: CHILD_PAGES
517
+ };
518
+ var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
519
+ masterPage: MASTER_PAGE,
520
+ childMasterPages: [],
521
+ formData: {
522
+ testField: false
523
+ },
524
+ entryData: ENTRY
525
+ })),
526
+ container = _renderWithValidation8.container;
527
+
528
+ // Function to find an element by its text content
529
+ function getByTextContent(parent, text) {
530
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
531
+ return el.textContent === text;
532
+ });
533
+ }
534
+
535
+ // Check for section titles
536
+ var section1Title = getByTextContent(container, 'Section 1');
537
+ expect(section1Title).toBeDefined();
538
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
539
+ expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
540
+ });
541
+ it('should render child collections', function () {
542
+ var CHILD_MASTER_PAGES = [{
398
543
  collection: {
399
544
  name: 'childCollection'
400
545
  },
@@ -416,7 +561,7 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
416
561
  }
417
562
  }]
418
563
  }];
419
- const CHILD_PAGES = [{
564
+ var CHILD_PAGES = [{
420
565
  summaryLayout: {
421
566
  sections: [{
422
567
  type: 'childCollection',
@@ -432,29 +577,87 @@ describe('components.CollectionSummary.SummaryCardDetails', () => {
432
577
  fieldId: 'fieldC'
433
578
  }]
434
579
  }];
435
- const MASTER_PAGE = {
580
+ var MASTER_PAGE = {
436
581
  childPages: [].concat(CHILD_PAGES, CHILD_MASTER_PAGES)
437
582
  };
438
- const CHILD_COLLECTIONS = ['childCollection'];
439
- const {
440
- container
441
- } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
442
- masterPage: MASTER_PAGE,
443
- childCollections: CHILD_COLLECTIONS,
444
- formData: {},
445
- entryData: ENTRY
446
- }));
583
+ var CHILD_COLLECTIONS = ['childCollection'];
584
+ var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
585
+ masterPage: MASTER_PAGE,
586
+ childCollections: CHILD_COLLECTIONS,
587
+ formData: {},
588
+ entryData: ENTRY
589
+ })),
590
+ container = _renderWithValidation9.container;
447
591
 
448
592
  // Function to find an element by its text content
449
593
  function getByTextContent(parent, text) {
450
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
594
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
595
+ return el.textContent === text;
596
+ });
451
597
  }
452
- const childCollectionSectionTitle = getByTextContent(container, 'Children');
598
+ var childCollectionSectionTitle = getByTextContent(container, 'Children');
453
599
  expect(childCollectionSectionTitle).not.toBeUndefined();
454
- const childSectionTitles = getByTextContent(container, 'Hidden Title');
600
+ var childSectionTitles = getByTextContent(container, 'Hidden Title');
455
601
  expect(childSectionTitles).toBeUndefined(); // Individual section title for child collections should be hidden.
456
602
 
457
- const childFields = container.querySelectorAll(".".concat(classes('section')));
603
+ var childFields = container.querySelectorAll(".".concat(classes('section')));
458
604
  expect(childFields.length).toEqual(2); // One for each entry in the child collection.
459
605
  });
606
+
607
+ it('should render components if a component with the same ID has already failed a show_when', function () {
608
+ var CHILD_PAGES = [{
609
+ summaryLayout: {
610
+ sections: [{
611
+ title: 'Section 1',
612
+ columns: [{
613
+ fields: ['fieldA']
614
+ }, {
615
+ fields: ['fieldB']
616
+ }]
617
+ }]
618
+ },
619
+ components: [{
620
+ fieldId: 'fieldA'
621
+ }, {
622
+ fieldId: 'fieldB',
623
+ label: 'first',
624
+ show_when: [{
625
+ field: 'fieldA',
626
+ op: '=',
627
+ value: 'notTheRightValue'
628
+ }]
629
+ }, {
630
+ fieldId: 'fieldB',
631
+ label: 'second',
632
+ show_when: [{
633
+ field: 'fieldA',
634
+ op: '!=',
635
+ value: 'notTheRightValue'
636
+ }]
637
+ }]
638
+ }];
639
+ var MASTER_PAGE = {
640
+ childPages: CHILD_PAGES
641
+ };
642
+ var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react.default.createElement(_SummaryCardDetails.default, {
643
+ masterPage: MASTER_PAGE,
644
+ childMasterPages: [],
645
+ formData: {},
646
+ entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
647
+ fieldA: 'notTheRightValue'
648
+ })
649
+ })),
650
+ container = _renderWithValidation10.container;
651
+
652
+ // Function to find an element by its text content
653
+ function getByTextContent(parent, text) {
654
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
655
+ return el.textContent === text;
656
+ });
657
+ }
658
+ var section1Title = getByTextContent(container, 'Section 1');
659
+ expect(section1Title).not.toBeUndefined();
660
+ var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
661
+ expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
662
+ });
460
663
  });