@capillarytech/creatives-library 8.0.250-alpha.2 → 8.0.251

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 (276) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +1 -3
  4. package/initialReducer.js +0 -2
  5. package/package.json +1 -1
  6. package/services/api.js +0 -15
  7. package/services/tests/api.test.js +0 -34
  8. package/translations/en.json +3 -4
  9. package/utils/common.js +0 -11
  10. package/utils/commonUtils.js +5 -28
  11. package/utils/tests/commonUtil.test.js +0 -224
  12. package/utils/tests/transformerUtils.test.js +0 -297
  13. package/utils/transformTemplateConfig.js +10 -0
  14. package/utils/transformerUtils.js +0 -40
  15. package/v2Components/CapDeviceContent/index.js +56 -61
  16. package/v2Components/CapImageUpload/constants.js +0 -2
  17. package/v2Components/CapImageUpload/index.js +16 -65
  18. package/v2Components/CapImageUpload/index.scss +1 -4
  19. package/v2Components/CapImageUpload/messages.js +1 -5
  20. package/v2Components/CapTagList/index.js +1 -6
  21. package/v2Components/CapTagListWithInput/index.js +1 -5
  22. package/v2Components/CapTagListWithInput/messages.js +1 -1
  23. package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
  24. package/v2Components/ErrorInfoNote/index.js +72 -455
  25. package/v2Components/ErrorInfoNote/messages.js +6 -36
  26. package/v2Components/ErrorInfoNote/style.scss +4 -280
  27. package/v2Components/FormBuilder/tests/index.test.js +4 -13
  28. package/v2Components/HtmlEditor/HTMLEditor.js +94 -547
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1358
  30. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +16 -27
  31. package/v2Components/HtmlEditor/_htmlEditor.scss +45 -108
  32. package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
  33. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +101 -22
  34. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +140 -146
  35. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
  36. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  37. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +0 -9
  38. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
  39. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
  40. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
  41. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
  42. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
  43. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  44. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
  45. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +6 -3
  46. package/v2Components/HtmlEditor/components/PreviewPane/index.js +34 -24
  47. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  48. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
  49. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -49
  50. package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +34 -50
  51. package/v2Components/HtmlEditor/components/ValidationPanel/index.js +41 -70
  52. package/v2Components/HtmlEditor/constants.js +20 -42
  53. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
  54. package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
  55. package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
  56. package/v2Components/HtmlEditor/hooks/useValidation.js +53 -189
  57. package/v2Components/HtmlEditor/index.js +1 -1
  58. package/v2Components/HtmlEditor/messages.js +85 -95
  59. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +45 -94
  60. package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +0 -134
  61. package/v2Components/HtmlEditor/utils/contentSanitizer.js +41 -40
  62. package/v2Components/HtmlEditor/utils/htmlValidator.js +72 -71
  63. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +102 -134
  64. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
  65. package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -66
  66. package/v2Components/MobilePushPreviewV2/index.js +7 -32
  67. package/v2Components/TemplatePreview/_templatePreview.scss +24 -55
  68. package/v2Components/TemplatePreview/index.js +32 -47
  69. package/v2Components/TemplatePreview/messages.js +0 -4
  70. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +0 -1
  71. package/v2Containers/App/constants.js +0 -5
  72. package/v2Containers/BeeEditor/index.js +90 -172
  73. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +3 -4
  74. package/v2Containers/CreativesContainer/SlideBoxContent.js +53 -184
  75. package/v2Containers/CreativesContainer/SlideBoxFooter.js +13 -163
  76. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -3
  77. package/v2Containers/CreativesContainer/constants.js +0 -4
  78. package/v2Containers/CreativesContainer/index.js +46 -407
  79. package/v2Containers/CreativesContainer/messages.js +0 -12
  80. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -210
  81. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +2 -11
  82. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +50 -342
  83. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -106
  84. package/v2Containers/Email/actions.js +0 -7
  85. package/v2Containers/Email/constants.js +1 -5
  86. package/v2Containers/Email/index.js +29 -234
  87. package/v2Containers/Email/messages.js +0 -32
  88. package/v2Containers/Email/reducer.js +1 -12
  89. package/v2Containers/Email/sagas.js +7 -61
  90. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
  91. package/v2Containers/Email/tests/reducer.test.js +0 -46
  92. package/v2Containers/Email/tests/sagas.test.js +29 -320
  93. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +19 -207
  94. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
  95. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
  96. package/v2Containers/EmailWrapper/constants.js +0 -2
  97. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +77 -629
  98. package/v2Containers/EmailWrapper/index.js +23 -103
  99. package/v2Containers/EmailWrapper/messages.js +1 -61
  100. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
  101. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -594
  102. package/v2Containers/InApp/actions.js +0 -7
  103. package/v2Containers/InApp/constants.js +4 -20
  104. package/v2Containers/InApp/index.js +359 -802
  105. package/v2Containers/InApp/index.scss +3 -4
  106. package/v2Containers/InApp/messages.js +3 -7
  107. package/v2Containers/InApp/reducer.js +3 -21
  108. package/v2Containers/InApp/sagas.js +9 -29
  109. package/v2Containers/InApp/selectors.js +5 -25
  110. package/v2Containers/InApp/tests/index.test.js +50 -154
  111. package/v2Containers/InApp/tests/reducer.test.js +0 -34
  112. package/v2Containers/InApp/tests/sagas.test.js +9 -61
  113. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +9 -15
  114. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +6 -10
  115. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +75 -102
  116. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +54 -81
  117. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +174 -244
  118. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +12 -16
  119. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +36 -52
  120. package/v2Containers/TagList/index.js +19 -62
  121. package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
  122. package/v2Containers/Templates/_templates.scss +1 -265
  123. package/v2Containers/Templates/actions.js +1 -2
  124. package/v2Containers/Templates/constants.js +0 -1
  125. package/v2Containers/Templates/index.js +38 -363
  126. package/v2Containers/Templates/messages.js +0 -28
  127. package/v2Containers/Templates/reducer.js +0 -4
  128. package/v2Containers/Templates/tests/index.test.js +0 -10
  129. package/v2Containers/TemplatesV2/index.js +7 -15
  130. package/v2Containers/TemplatesV2/messages.js +0 -4
  131. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +486 -682
  132. package/utils/imageUrlUpload.js +0 -141
  133. package/v2Components/CapImageUrlUpload/constants.js +0 -26
  134. package/v2Components/CapImageUrlUpload/index.js +0 -365
  135. package/v2Components/CapImageUrlUpload/index.scss +0 -35
  136. package/v2Components/CapImageUrlUpload/messages.js +0 -47
  137. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -874
  138. package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +0 -6
  139. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -254
  140. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -364
  141. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
  142. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.apiErrors.test.js +0 -795
  143. package/v2Components/HtmlEditor/utils/validationConstants.js +0 -40
  144. package/v2Containers/BeePopupEditor/_beePopupEditor.scss +0 -14
  145. package/v2Containers/BeePopupEditor/constants.js +0 -10
  146. package/v2Containers/BeePopupEditor/index.js +0 -194
  147. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
  148. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1285
  149. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +0 -1870
  150. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +0 -520
  151. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +0 -643
  152. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
  153. package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
  154. package/v2Containers/InApp/tests/selectors.test.js +0 -612
  155. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -151
  156. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
  157. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -23
  158. package/v2Containers/InAppWrapper/constants.js +0 -16
  159. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
  160. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
  161. package/v2Containers/InAppWrapper/index.js +0 -148
  162. package/v2Containers/InAppWrapper/messages.js +0 -49
  163. package/v2Containers/InappAdvance/index.js +0 -1099
  164. package/v2Containers/InappAdvance/index.scss +0 -10
  165. package/v2Containers/InappAdvance/tests/index.test.js +0 -448
  166. package/v2Containers/WebPush/Create/components/BrandIconSection.js +0 -108
  167. package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -172
  168. package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
  169. package/v2Containers/WebPush/Create/components/ButtonList.js +0 -107
  170. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +0 -160
  171. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +0 -476
  172. package/v2Containers/WebPush/Create/components/FormActions.js +0 -54
  173. package/v2Containers/WebPush/Create/components/FormActions.test.js +0 -163
  174. package/v2Containers/WebPush/Create/components/MediaSection.js +0 -143
  175. package/v2Containers/WebPush/Create/components/MediaSection.test.js +0 -341
  176. package/v2Containers/WebPush/Create/components/MessageSection.js +0 -103
  177. package/v2Containers/WebPush/Create/components/MessageSection.test.js +0 -268
  178. package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +0 -87
  179. package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +0 -210
  180. package/v2Containers/WebPush/Create/components/TemplateNameSection.js +0 -54
  181. package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +0 -143
  182. package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +0 -82
  183. package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +0 -16
  184. package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +0 -41
  185. package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +0 -54
  186. package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +0 -37
  187. package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +0 -21
  188. package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
  189. package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
  190. package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
  191. package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -515
  192. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
  193. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
  194. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -46
  195. package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +0 -150
  196. package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +0 -406
  197. package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +0 -30
  198. package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +0 -151
  199. package/v2Containers/WebPush/Create/hooks/useImageUpload.js +0 -104
  200. package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +0 -538
  201. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +0 -122
  202. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -633
  203. package/v2Containers/WebPush/Create/index.js +0 -1148
  204. package/v2Containers/WebPush/Create/index.scss +0 -134
  205. package/v2Containers/WebPush/Create/messages.js +0 -203
  206. package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -228
  207. package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -294
  208. package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -90
  209. package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -305
  210. package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -23
  211. package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -155
  212. package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
  213. package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
  214. package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +0 -9
  215. package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +0 -9
  216. package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
  217. package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
  218. package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +0 -106
  219. package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
  220. package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +0 -9
  221. package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +0 -9
  222. package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
  223. package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
  224. package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +0 -9
  225. package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +0 -9
  226. package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -47
  227. package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -141
  228. package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
  229. package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -68
  230. package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -61
  231. package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -99
  232. package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -733
  233. package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +0 -571
  234. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -81
  235. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +0 -81
  236. package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -50
  237. package/v2Containers/WebPush/Create/preview/constants.js +0 -637
  238. package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -79
  239. package/v2Containers/WebPush/Create/preview/preview.scss +0 -351
  240. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -370
  241. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
  242. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
  243. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
  244. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -47
  245. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
  246. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
  247. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
  248. package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -207
  249. package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -153
  250. package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
  251. package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -101
  252. package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -229
  253. package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
  254. package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1081
  255. package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
  256. package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -1327
  257. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -131
  258. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -112
  259. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
  260. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -129
  261. package/v2Containers/WebPush/Create/utils/payloadBuilder.js +0 -96
  262. package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +0 -396
  263. package/v2Containers/WebPush/Create/utils/previewUtils.js +0 -89
  264. package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -115
  265. package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
  266. package/v2Containers/WebPush/Create/utils/validation.js +0 -75
  267. package/v2Containers/WebPush/Create/utils/validation.test.js +0 -283
  268. package/v2Containers/WebPush/actions.js +0 -60
  269. package/v2Containers/WebPush/constants.js +0 -132
  270. package/v2Containers/WebPush/index.js +0 -2
  271. package/v2Containers/WebPush/reducer.js +0 -104
  272. package/v2Containers/WebPush/sagas.js +0 -119
  273. package/v2Containers/WebPush/selectors.js +0 -65
  274. package/v2Containers/WebPush/tests/reducer.test.js +0 -863
  275. package/v2Containers/WebPush/tests/sagas.test.js +0 -566
  276. package/v2Containers/WebPush/tests/selectors.test.js +0 -960
@@ -1,795 +0,0 @@
1
- /**
2
- * useValidation Hook Tests - API Validation Errors Coverage
3
- *
4
- * Additional tests to cover API validation errors and other uncovered lines
5
- */
6
-
7
- import React from 'react';
8
- import { render, screen, act } from '@testing-library/react';
9
- import '@testing-library/jest-dom';
10
- import { useValidation } from '../useValidation';
11
-
12
- // Mock validation utilities
13
- jest.mock('../../utils/htmlValidator', () => ({
14
- validateHTML: jest.fn((content, variant, formatMessage) => ({
15
- isValid: true,
16
- errors: [],
17
- warnings: [],
18
- info: [],
19
- })),
20
- extractAndValidateCSS: jest.fn((content, formatMessage) => ({
21
- isValid: true,
22
- errors: [],
23
- warnings: [],
24
- info: [],
25
- })),
26
- }));
27
-
28
- jest.mock('../../utils/contentSanitizer', () => ({
29
- sanitizeHTML: jest.fn((content, variant, level, formatMessage) => ({
30
- sanitized: content,
31
- warnings: [],
32
- })),
33
- isContentSafe: jest.fn((content) => true),
34
- findUnsafeContent: jest.fn((content) => []),
35
- }));
36
-
37
- // Test wrapper component
38
- const TestComponent = ({ content, variant, options, onStateChange }) => {
39
- const validationState = useValidation(content, variant, options);
40
-
41
- React.useEffect(() => {
42
- if (onStateChange) {
43
- onStateChange(validationState);
44
- }
45
- });
46
-
47
- return (
48
- <div>
49
- <div data-testid="is-validating">{String(validationState.isValidating)}</div>
50
- <div data-testid="is-valid">{String(validationState.isValid)}</div>
51
- <div data-testid="is-secure">{String(validationState.isSecure)}</div>
52
- <div data-testid="is-clean">{String(validationState.isClean())}</div>
53
- <div data-testid="has-errors">{String(validationState.hasErrors)}</div>
54
- <div data-testid="has-warnings">{String(validationState.hasWarnings)}</div>
55
- <div data-testid="total-errors">{validationState.summary.totalErrors}</div>
56
- <div data-testid="total-warnings">{validationState.summary.totalWarnings}</div>
57
- <div data-testid="all-issues-count">{validationState.getAllIssues().length}</div>
58
- <div data-testid="liquid-errors-count">
59
- {validationState.getAllIssues().filter(issue => issue.source === 'liquid-validator').length}
60
- </div>
61
- <div data-testid="standard-errors-count">
62
- {validationState.getAllIssues().filter(issue => issue.source === 'api-validator').length}
63
- </div>
64
-
65
- <button onClick={() => validationState.forceValidation()} data-testid="force-validate">
66
- Force Validate
67
- </button>
68
- <button onClick={() => validationState.clearValidation()} data-testid="clear">
69
- Clear
70
- </button>
71
- </div>
72
- );
73
- };
74
-
75
- describe('useValidation - API Validation Errors', () => {
76
- beforeEach(() => {
77
- jest.useFakeTimers();
78
- });
79
-
80
- afterEach(() => {
81
- jest.runOnlyPendingTimers();
82
- jest.useRealTimers();
83
- });
84
-
85
- describe('API Validation Errors Integration', () => {
86
- it('includes liquid API errors in getAllIssues', async () => {
87
- const apiValidationErrors = {
88
- liquidErrors: ['Liquid error on line 5', 'Another liquid error'],
89
- standardErrors: [],
90
- };
91
-
92
- render(
93
- <TestComponent
94
- content="<p>Test</p>"
95
- options={{ apiValidationErrors }}
96
- />
97
- );
98
-
99
- await act(async () => {
100
- jest.advanceTimersByTime(500);
101
- await Promise.resolve();
102
- await Promise.resolve();
103
- await Promise.resolve();
104
- });
105
-
106
- // API errors should be included in getAllIssues
107
- const liquidCount = parseInt(screen.getByTestId('liquid-errors-count').textContent, 10);
108
- const allCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
109
- expect(liquidCount).toBeGreaterThanOrEqual(2);
110
- expect(allCount).toBeGreaterThanOrEqual(2);
111
- });
112
-
113
- it('includes standard API errors in getAllIssues', async () => {
114
- const apiValidationErrors = {
115
- liquidErrors: [],
116
- standardErrors: ['Standard error on line 3', 'Another standard error'],
117
- };
118
-
119
- render(
120
- <TestComponent
121
- content="<p>Test</p>"
122
- options={{ apiValidationErrors }}
123
- />
124
- );
125
-
126
- await act(async () => {
127
- jest.advanceTimersByTime(500);
128
- await Promise.resolve();
129
- await Promise.resolve();
130
- await Promise.resolve();
131
- });
132
-
133
- // API errors should be included in getAllIssues
134
- const standardCount = parseInt(screen.getByTestId('standard-errors-count').textContent, 10);
135
- const allCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
136
- expect(standardCount).toBeGreaterThanOrEqual(2);
137
- expect(allCount).toBeGreaterThanOrEqual(2);
138
- });
139
-
140
- it('includes both liquid and standard API errors', async () => {
141
- const apiValidationErrors = {
142
- liquidErrors: ['Liquid error'],
143
- standardErrors: ['Standard error'],
144
- };
145
-
146
- render(
147
- <TestComponent
148
- content="<p>Test</p>"
149
- options={{ apiValidationErrors }}
150
- />
151
- );
152
-
153
- await act(async () => {
154
- jest.advanceTimersByTime(500);
155
- await Promise.resolve();
156
- await Promise.resolve();
157
- await Promise.resolve();
158
- });
159
-
160
- // API errors should be included in getAllIssues
161
- const liquidCount = parseInt(screen.getByTestId('liquid-errors-count').textContent, 10);
162
- const standardCount = parseInt(screen.getByTestId('standard-errors-count').textContent, 10);
163
- const allCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
164
- expect(liquidCount).toBeGreaterThanOrEqual(1);
165
- expect(standardCount).toBeGreaterThanOrEqual(1);
166
- expect(allCount).toBeGreaterThanOrEqual(2);
167
- });
168
-
169
- it('extracts line numbers from API error messages', async () => {
170
- const apiValidationErrors = {
171
- liquidErrors: ['Error at line 10: Invalid syntax'],
172
- standardErrors: ['Error at line 5: Missing tag'],
173
- };
174
-
175
- render(
176
- <TestComponent
177
- content="<p>Test</p>"
178
- options={{ apiValidationErrors }}
179
- />
180
- );
181
-
182
- await act(async () => {
183
- jest.advanceTimersByTime(500);
184
- await Promise.resolve();
185
- await Promise.resolve();
186
- await Promise.resolve();
187
- });
188
-
189
- const allIssues = screen.getByTestId('all-issues-count');
190
- expect(allIssues).toBeInTheDocument();
191
- });
192
-
193
- it('handles API errors with no line numbers', async () => {
194
- const apiValidationErrors = {
195
- liquidErrors: ['General liquid error'],
196
- standardErrors: ['General standard error'],
197
- };
198
-
199
- render(
200
- <TestComponent
201
- content="<p>Test</p>"
202
- options={{ apiValidationErrors }}
203
- />
204
- );
205
-
206
- await act(async () => {
207
- jest.advanceTimersByTime(500);
208
- await Promise.resolve();
209
- await Promise.resolve();
210
- await Promise.resolve();
211
- });
212
-
213
- // Should include at least the 2 API errors
214
- const allCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
215
- expect(allCount).toBeGreaterThanOrEqual(2);
216
- });
217
-
218
- it('sets correct source for liquid API errors', async () => {
219
- const apiValidationErrors = {
220
- liquidErrors: ['Liquid error'],
221
- standardErrors: [],
222
- };
223
-
224
- render(
225
- <TestComponent
226
- content="<p>Test</p>"
227
- options={{ apiValidationErrors }}
228
- />
229
- );
230
-
231
- await act(async () => {
232
- jest.advanceTimersByTime(500);
233
- await Promise.resolve();
234
- await Promise.resolve();
235
- await Promise.resolve();
236
- });
237
-
238
- // Liquid errors should have source 'liquid-validator'
239
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
240
- });
241
-
242
- it('sets correct source for standard API errors', async () => {
243
- const apiValidationErrors = {
244
- liquidErrors: [],
245
- standardErrors: ['Standard error'],
246
- };
247
-
248
- render(
249
- <TestComponent
250
- content="<p>Test</p>"
251
- options={{ apiValidationErrors }}
252
- />
253
- );
254
-
255
- await act(async () => {
256
- jest.advanceTimersByTime(500);
257
- await Promise.resolve();
258
- await Promise.resolve();
259
- await Promise.resolve();
260
- });
261
-
262
- // Standard errors should have source 'api-validator'
263
- expect(screen.getByTestId('standard-errors-count')).toHaveTextContent('1');
264
- });
265
- });
266
-
267
- describe('API Errors with hasErrors', () => {
268
- it('sets hasErrors to true when API errors exist', async () => {
269
- const apiValidationErrors = {
270
- liquidErrors: ['Liquid error'],
271
- standardErrors: [],
272
- };
273
-
274
- render(
275
- <TestComponent
276
- content="<p>Test</p>"
277
- options={{ apiValidationErrors }}
278
- />
279
- );
280
-
281
- await act(async () => {
282
- jest.advanceTimersByTime(500);
283
- await Promise.resolve();
284
- await Promise.resolve();
285
- await Promise.resolve();
286
- });
287
-
288
- // hasErrors should be true when API errors exist
289
- expect(screen.getByTestId('has-errors')).toHaveTextContent('true');
290
- });
291
-
292
- it('sets hasErrors to false when no API errors and no validation errors', async () => {
293
- const apiValidationErrors = {
294
- liquidErrors: [],
295
- standardErrors: [],
296
- };
297
-
298
- render(
299
- <TestComponent
300
- content="<p>Test</p>"
301
- options={{ apiValidationErrors }}
302
- />
303
- );
304
-
305
- await act(async () => {
306
- jest.advanceTimersByTime(500);
307
- await Promise.resolve();
308
- await Promise.resolve();
309
- await Promise.resolve();
310
- });
311
-
312
- // hasErrors should be false when no API errors and no validation errors
313
- // Note: This might be true if validation finds errors, so we check the condition
314
- const hasErrors = screen.getByTestId('has-errors').textContent === 'true';
315
- const allIssuesCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
316
- // If there are no issues, hasErrors should be false
317
- if (allIssuesCount === 0) {
318
- expect(screen.getByTestId('has-errors')).toHaveTextContent('false');
319
- }
320
- });
321
- });
322
-
323
- describe('API Errors with isClean', () => {
324
- it('returns false when API errors exist', async () => {
325
- const apiValidationErrors = {
326
- liquidErrors: ['Liquid error'],
327
- standardErrors: [],
328
- };
329
-
330
- render(
331
- <TestComponent
332
- content="<p>Test</p>"
333
- options={{ apiValidationErrors }}
334
- />
335
- );
336
-
337
- await act(async () => {
338
- jest.advanceTimersByTime(500);
339
- await Promise.resolve();
340
- await Promise.resolve();
341
- await Promise.resolve();
342
- });
343
-
344
- // isClean should be false when API errors exist
345
- expect(screen.getByTestId('is-clean')).toHaveTextContent('false');
346
- });
347
-
348
- it('returns true when no API errors and no other issues', async () => {
349
- const apiValidationErrors = {
350
- liquidErrors: [],
351
- standardErrors: [],
352
- };
353
-
354
- render(
355
- <TestComponent
356
- content="<p>Test</p>"
357
- options={{ apiValidationErrors }}
358
- />
359
- );
360
-
361
- await act(async () => {
362
- jest.advanceTimersByTime(500);
363
- await Promise.resolve();
364
- await Promise.resolve();
365
- await Promise.resolve();
366
- });
367
-
368
- // isClean should be true when no API errors and no validation issues
369
- // Note: This might be false if validation finds issues, so we check the condition
370
- const allIssuesCount = parseInt(screen.getByTestId('all-issues-count').textContent, 10);
371
- if (allIssuesCount === 0) {
372
- expect(screen.getByTestId('is-clean')).toHaveTextContent('true');
373
- }
374
- });
375
- });
376
-
377
- describe('API Errors Edge Cases', () => {
378
- it('handles null apiValidationErrors', async () => {
379
- render(
380
- <TestComponent
381
- content="<p>Test</p>"
382
- options={{ apiValidationErrors: null }}
383
- />
384
- );
385
-
386
- await act(async () => {
387
- jest.advanceTimersByTime(500);
388
- await Promise.resolve();
389
- await Promise.resolve();
390
- await Promise.resolve();
391
- });
392
-
393
- // Should not include API errors when null
394
- const liquidCount = parseInt(screen.getByTestId('liquid-errors-count').textContent, 10);
395
- const standardCount = parseInt(screen.getByTestId('standard-errors-count').textContent, 10);
396
- expect(liquidCount).toBe(0);
397
- expect(standardCount).toBe(0);
398
- });
399
-
400
- it('handles undefined apiValidationErrors', async () => {
401
- render(
402
- <TestComponent
403
- content="<p>Test</p>"
404
- options={{ apiValidationErrors: undefined }}
405
- />
406
- );
407
-
408
- await act(async () => {
409
- jest.advanceTimersByTime(500);
410
- await Promise.resolve();
411
- await Promise.resolve();
412
- await Promise.resolve();
413
- });
414
-
415
- // Should not include API errors when undefined
416
- const liquidCount = parseInt(screen.getByTestId('liquid-errors-count').textContent, 10);
417
- const standardCount = parseInt(screen.getByTestId('standard-errors-count').textContent, 10);
418
- expect(liquidCount).toBe(0);
419
- expect(standardCount).toBe(0);
420
- });
421
-
422
- it('handles empty liquidErrors array', async () => {
423
- const apiValidationErrors = {
424
- liquidErrors: [],
425
- standardErrors: ['Standard error'],
426
- };
427
-
428
- render(
429
- <TestComponent
430
- content="<p>Test</p>"
431
- options={{ apiValidationErrors }}
432
- />
433
- );
434
-
435
- await act(async () => {
436
- jest.advanceTimersByTime(500);
437
- await Promise.resolve();
438
- await Promise.resolve();
439
- await Promise.resolve();
440
- });
441
-
442
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('0');
443
- expect(screen.getByTestId('standard-errors-count')).toHaveTextContent('1');
444
- });
445
-
446
- it('handles empty standardErrors array', async () => {
447
- const apiValidationErrors = {
448
- liquidErrors: ['Liquid error'],
449
- standardErrors: [],
450
- };
451
-
452
- render(
453
- <TestComponent
454
- content="<p>Test</p>"
455
- options={{ apiValidationErrors }}
456
- />
457
- );
458
-
459
- await act(async () => {
460
- jest.advanceTimersByTime(500);
461
- await Promise.resolve();
462
- await Promise.resolve();
463
- await Promise.resolve();
464
- });
465
-
466
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
467
- expect(screen.getByTestId('standard-errors-count')).toHaveTextContent('0');
468
- });
469
-
470
- it('handles missing liquidErrors property', async () => {
471
- const apiValidationErrors = {
472
- standardErrors: ['Standard error'],
473
- };
474
-
475
- render(
476
- <TestComponent
477
- content="<p>Test</p>"
478
- options={{ apiValidationErrors }}
479
- />
480
- );
481
-
482
- await act(async () => {
483
- jest.advanceTimersByTime(500);
484
- await Promise.resolve();
485
- await Promise.resolve();
486
- await Promise.resolve();
487
- });
488
-
489
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('0');
490
- expect(screen.getByTestId('standard-errors-count')).toHaveTextContent('1');
491
- });
492
-
493
- it('handles missing standardErrors property', async () => {
494
- const apiValidationErrors = {
495
- liquidErrors: ['Liquid error'],
496
- };
497
-
498
- render(
499
- <TestComponent
500
- content="<p>Test</p>"
501
- options={{ apiValidationErrors }}
502
- />
503
- );
504
-
505
- await act(async () => {
506
- jest.advanceTimersByTime(500);
507
- await Promise.resolve();
508
- await Promise.resolve();
509
- await Promise.resolve();
510
- });
511
-
512
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
513
- expect(screen.getByTestId('standard-errors-count')).toHaveTextContent('0');
514
- });
515
- });
516
-
517
- describe('Line Number Extraction', () => {
518
- it('extracts line number from error message with "Line X" pattern', async () => {
519
- const apiValidationErrors = {
520
- liquidErrors: ['Error message Line 15'],
521
- standardErrors: [],
522
- };
523
-
524
- render(
525
- <TestComponent
526
- content="<p>Test</p>"
527
- options={{ apiValidationErrors }}
528
- />
529
- );
530
-
531
- await act(async () => {
532
- jest.advanceTimersByTime(500);
533
- await Promise.resolve();
534
- await Promise.resolve();
535
- await Promise.resolve();
536
- });
537
-
538
- // Line number should be extracted
539
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
540
- });
541
-
542
- it('extracts line number from error message with "line X" pattern', async () => {
543
- const apiValidationErrors = {
544
- liquidErrors: ['Error message line 20'],
545
- standardErrors: [],
546
- };
547
-
548
- render(
549
- <TestComponent
550
- content="<p>Test</p>"
551
- options={{ apiValidationErrors }}
552
- />
553
- );
554
-
555
- await act(async () => {
556
- jest.advanceTimersByTime(500);
557
- await Promise.resolve();
558
- await Promise.resolve();
559
- await Promise.resolve();
560
- });
561
-
562
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
563
- });
564
-
565
- it('handles error messages without line numbers', async () => {
566
- const apiValidationErrors = {
567
- liquidErrors: ['General error message'],
568
- standardErrors: [],
569
- };
570
-
571
- render(
572
- <TestComponent
573
- content="<p>Test</p>"
574
- options={{ apiValidationErrors }}
575
- />
576
- );
577
-
578
- await act(async () => {
579
- jest.advanceTimersByTime(500);
580
- await Promise.resolve();
581
- await Promise.resolve();
582
- await Promise.resolve();
583
- });
584
-
585
- expect(screen.getByTestId('liquid-errors-count')).toHaveTextContent('1');
586
- });
587
- });
588
-
589
- describe('API Errors Sorting', () => {
590
- it('sorts API errors with other validation issues', async () => {
591
- const { validateHTML } = require('../../utils/htmlValidator');
592
- validateHTML.mockReturnValueOnce({
593
- isValid: false,
594
- errors: [{
595
- type: 'error',
596
- message: 'HTML error',
597
- line: 1,
598
- column: 1,
599
- rule: 'html-error',
600
- severity: 'error',
601
- source: 'htmlhint',
602
- }],
603
- warnings: [],
604
- info: [],
605
- });
606
-
607
- const apiValidationErrors = {
608
- liquidErrors: ['Liquid error'],
609
- standardErrors: [],
610
- };
611
-
612
- render(
613
- <TestComponent
614
- content="<p>error</p>"
615
- options={{ apiValidationErrors }}
616
- />
617
- );
618
-
619
- await act(async () => {
620
- jest.advanceTimersByTime(500);
621
- await Promise.resolve();
622
- await Promise.resolve();
623
- await Promise.resolve();
624
- });
625
-
626
- // Should have both HTML error and API error
627
- expect(screen.getByTestId('all-issues-count')).toHaveTextContent('2');
628
- });
629
- });
630
-
631
- describe('getLineNumberForApiError helper functions', () => {
632
- it('should extract line number from error message with "line X" pattern', () => {
633
- const content = '<p>Line 1</p>\n<p>Line 2</p>\n<p>Line 3</p>';
634
- const apiValidationErrors = {
635
- liquidErrors: ['Error at line 2'],
636
- standardErrors: [],
637
- };
638
-
639
- render(
640
- <TestComponent
641
- content={content}
642
- options={{ apiValidationErrors }}
643
- />
644
- );
645
-
646
- // The getLineNumberForApiError should extract line 2 from the error message
647
- // This is tested indirectly through the error processing
648
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
649
- });
650
-
651
- it('should extract line number from error message with "Line: X" pattern', () => {
652
- const content = '<p>Line 1</p>\n<p>Line 2</p>';
653
- const apiValidationErrors = {
654
- liquidErrors: ['Error at Line: 2'],
655
- standardErrors: [],
656
- };
657
-
658
- render(
659
- <TestComponent
660
- content={content}
661
- options={{ apiValidationErrors }}
662
- />
663
- );
664
-
665
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
666
- });
667
-
668
- it('should find tag in content using {{ tagName }} pattern', () => {
669
- const content = '<p>Line 1</p>\n<p>{{ customer.name }}</p>\n<p>Line 3</p>';
670
- const apiValidationErrors = {
671
- liquidErrors: ['Unsupported tags: customer.name'],
672
- standardErrors: [],
673
- };
674
-
675
- render(
676
- <TestComponent
677
- content={content}
678
- options={{ apiValidationErrors }}
679
- />
680
- );
681
-
682
- // Should find the tag and extract line number
683
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
684
- });
685
-
686
- it('should find tag in content using {% %} pattern', () => {
687
- const content = '<p>Line 1</p>\n{% assign x = customer.name %}\n<p>Line 3</p>';
688
- const apiValidationErrors = {
689
- liquidErrors: ['Unsupported tags: customer.name'],
690
- standardErrors: [],
691
- };
692
-
693
- render(
694
- <TestComponent
695
- content={content}
696
- options={{ apiValidationErrors }}
697
- />
698
- );
699
-
700
- // Should find the tag in liquid syntax
701
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
702
- });
703
-
704
- it('should handle tag name with special characters', () => {
705
- const content = '<p>{{ customer.name.first }}</p>';
706
- const apiValidationErrors = {
707
- liquidErrors: ['Unsupported tags: customer.name.first'],
708
- standardErrors: [],
709
- };
710
-
711
- render(
712
- <TestComponent
713
- content={content}
714
- options={{ apiValidationErrors }}
715
- />
716
- );
717
-
718
- // Should escape special characters in tag name
719
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
720
- });
721
-
722
- it('should return null when tag is not found in content', () => {
723
- const content = '<p>No tags here</p>';
724
- const apiValidationErrors = {
725
- liquidErrors: ['Unsupported tags: missing.tag'],
726
- standardErrors: [],
727
- };
728
-
729
- render(
730
- <TestComponent
731
- content={content}
732
- options={{ apiValidationErrors }}
733
- />
734
- );
735
-
736
- // Should still process the error even if tag is not found
737
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
738
- });
739
-
740
- it('should handle getLineNumberFromPosition edge cases', () => {
741
- // Test that helper functions handle edge cases gracefully
742
- // These are tested indirectly through error processing
743
- const content = '<p>Content</p>';
744
- const apiValidationErrors = {
745
- liquidErrors: ['Error message'],
746
- standardErrors: [],
747
- };
748
-
749
- render(
750
- <TestComponent
751
- content={content}
752
- options={{ apiValidationErrors }}
753
- />
754
- );
755
-
756
- // Component should render and process errors without crashing
757
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
758
- });
759
-
760
- it('should handle findLineNumberForTag with null content', () => {
761
- const apiValidationErrors = {
762
- liquidErrors: ['Unsupported tags: test.tag'],
763
- standardErrors: [],
764
- };
765
-
766
- render(
767
- <TestComponent
768
- content=""
769
- options={{ apiValidationErrors }}
770
- />
771
- );
772
-
773
- // Should handle gracefully when content is empty
774
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
775
- });
776
-
777
- it('should handle findLineNumberForTag with null tagName', () => {
778
- const content = '<p>Content</p>';
779
- const apiValidationErrors = {
780
- liquidErrors: ['Error without tag name'],
781
- standardErrors: [],
782
- };
783
-
784
- render(
785
- <TestComponent
786
- content={content}
787
- options={{ apiValidationErrors }}
788
- />
789
- );
790
-
791
- // Should handle gracefully when tag name cannot be extracted
792
- expect(screen.getByTestId('all-issues-count')).toBeInTheDocument();
793
- });
794
- });
795
- });