@capillarytech/creatives-library 8.0.254 → 8.0.255-alpha.0

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 (143) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +2 -1
  4. package/initialReducer.js +2 -0
  5. package/package.json +1 -1
  6. package/services/api.js +10 -0
  7. package/services/tests/api.test.js +34 -0
  8. package/utils/common.js +5 -0
  9. package/utils/commonUtils.js +28 -5
  10. package/utils/tests/commonUtil.test.js +224 -0
  11. package/utils/transformTemplateConfig.js +0 -10
  12. package/v2Components/CapDeviceContent/index.js +61 -56
  13. package/v2Components/CapTagList/index.js +6 -1
  14. package/v2Components/CapTagListWithInput/index.js +5 -1
  15. package/v2Components/CapTagListWithInput/messages.js +1 -1
  16. package/v2Components/CapWhatsappCTA/tests/index.test.js +5 -0
  17. package/v2Components/ErrorInfoNote/constants.js +1 -0
  18. package/v2Components/ErrorInfoNote/index.js +457 -72
  19. package/v2Components/ErrorInfoNote/messages.js +36 -6
  20. package/v2Components/ErrorInfoNote/style.scss +282 -6
  21. package/v2Components/FormBuilder/tests/index.test.js +13 -4
  22. package/v2Components/HtmlEditor/HTMLEditor.js +547 -94
  23. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +874 -0
  24. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1358 -133
  25. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +27 -16
  26. package/v2Components/HtmlEditor/_htmlEditor.scss +108 -45
  27. package/v2Components/HtmlEditor/_index.lazy.scss +0 -1
  28. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +22 -101
  29. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +149 -140
  30. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +2 -1
  31. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  32. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +9 -0
  33. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
  34. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +22 -0
  35. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +4 -7
  36. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +35 -45
  37. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +1 -3
  38. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  39. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +7 -6
  40. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +3 -6
  41. package/v2Components/HtmlEditor/components/PreviewPane/index.js +24 -34
  42. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  43. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +49 -31
  44. package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +50 -34
  45. package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +6 -0
  46. package/v2Components/HtmlEditor/components/ValidationPanel/index.js +70 -41
  47. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +254 -0
  48. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +364 -0
  49. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +51 -0
  50. package/v2Components/HtmlEditor/constants.js +42 -20
  51. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +373 -16
  52. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.apiErrors.test.js +794 -0
  53. package/v2Components/HtmlEditor/hooks/useEditorContent.js +5 -2
  54. package/v2Components/HtmlEditor/hooks/useInAppContent.js +88 -146
  55. package/v2Components/HtmlEditor/hooks/useValidation.js +189 -53
  56. package/v2Components/HtmlEditor/index.js +1 -1
  57. package/v2Components/HtmlEditor/messages.js +95 -85
  58. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +94 -45
  59. package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +134 -0
  60. package/v2Components/HtmlEditor/utils/contentSanitizer.js +40 -41
  61. package/v2Components/HtmlEditor/utils/htmlValidator.js +71 -72
  62. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +134 -102
  63. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +23 -25
  64. package/v2Components/HtmlEditor/utils/validationAdapter.js +66 -41
  65. package/v2Components/HtmlEditor/utils/validationConstants.js +40 -0
  66. package/v2Components/MobilePushPreviewV2/index.js +32 -7
  67. package/v2Components/TemplatePreview/_templatePreview.scss +55 -24
  68. package/v2Components/TemplatePreview/index.js +47 -32
  69. package/v2Components/TemplatePreview/messages.js +4 -0
  70. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +1 -0
  71. package/v2Containers/BeeEditor/index.js +172 -90
  72. package/v2Containers/BeePopupEditor/_beePopupEditor.scss +14 -0
  73. package/v2Containers/BeePopupEditor/constants.js +10 -0
  74. package/v2Containers/BeePopupEditor/index.js +194 -0
  75. package/v2Containers/BeePopupEditor/tests/index.test.js +627 -0
  76. package/v2Containers/CreativesContainer/SlideBoxContent.js +128 -51
  77. package/v2Containers/CreativesContainer/SlideBoxFooter.js +163 -13
  78. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -1
  79. package/v2Containers/CreativesContainer/constants.js +1 -0
  80. package/v2Containers/CreativesContainer/index.js +239 -46
  81. package/v2Containers/CreativesContainer/messages.js +8 -0
  82. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +11 -2
  83. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +38 -50
  84. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +106 -0
  85. package/v2Containers/Email/actions.js +7 -0
  86. package/v2Containers/Email/constants.js +5 -1
  87. package/v2Containers/Email/index.js +234 -29
  88. package/v2Containers/Email/messages.js +32 -0
  89. package/v2Containers/Email/reducer.js +12 -1
  90. package/v2Containers/Email/sagas.js +61 -7
  91. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -0
  92. package/v2Containers/Email/tests/reducer.test.js +46 -0
  93. package/v2Containers/Email/tests/sagas.test.js +320 -29
  94. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +1285 -0
  95. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +207 -19
  96. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +40 -74
  97. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +1870 -0
  98. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +520 -0
  99. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +2 -67
  100. package/v2Containers/EmailWrapper/constants.js +2 -0
  101. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +629 -77
  102. package/v2Containers/EmailWrapper/index.js +103 -23
  103. package/v2Containers/EmailWrapper/messages.js +61 -1
  104. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +643 -0
  105. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +594 -77
  106. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +376 -0
  107. package/v2Containers/InApp/__tests__/sagas.test.js +363 -0
  108. package/v2Containers/InApp/actions.js +7 -0
  109. package/v2Containers/InApp/constants.js +20 -4
  110. package/v2Containers/InApp/index.js +802 -359
  111. package/v2Containers/InApp/index.scss +4 -3
  112. package/v2Containers/InApp/messages.js +7 -3
  113. package/v2Containers/InApp/reducer.js +21 -3
  114. package/v2Containers/InApp/sagas.js +29 -9
  115. package/v2Containers/InApp/selectors.js +25 -5
  116. package/v2Containers/InApp/tests/index.test.js +154 -50
  117. package/v2Containers/InApp/tests/reducer.test.js +34 -0
  118. package/v2Containers/InApp/tests/sagas.test.js +61 -9
  119. package/v2Containers/InApp/tests/selectors.test.js +612 -0
  120. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +151 -0
  121. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +267 -0
  122. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +23 -0
  123. package/v2Containers/InAppWrapper/constants.js +16 -0
  124. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +473 -0
  125. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +198 -0
  126. package/v2Containers/InAppWrapper/index.js +148 -0
  127. package/v2Containers/InAppWrapper/messages.js +49 -0
  128. package/v2Containers/InappAdvance/index.js +1099 -0
  129. package/v2Containers/InappAdvance/index.scss +10 -0
  130. package/v2Containers/InappAdvance/tests/index.test.js +448 -0
  131. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  132. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  133. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
  134. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
  135. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -0
  136. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
  137. package/v2Containers/TagList/index.js +62 -19
  138. package/v2Containers/Templates/_templates.scss +60 -1
  139. package/v2Containers/Templates/index.js +89 -4
  140. package/v2Containers/Templates/messages.js +4 -0
  141. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -0
  142. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +0 -152
  143. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +0 -214
@@ -2281,6 +2281,7 @@ new message content.",
2281
2281
  "email": [Function],
2282
2282
  "facebookPreview": [Function],
2283
2283
  "gallery": [Function],
2284
+ "inApp": [Function],
2284
2285
  "language": [Function],
2285
2286
  "navigationConfig": [Function],
2286
2287
  "previewAndTest": [Function],
@@ -23690,6 +23691,7 @@ new message content.",
23690
23691
  "email": [Function],
23691
23692
  "facebookPreview": [Function],
23692
23693
  "gallery": [Function],
23694
+ "inApp": [Function],
23693
23695
  "language": [Function],
23694
23696
  "navigationConfig": [Function],
23695
23697
  "previewAndTest": [Function],
@@ -47215,6 +47217,7 @@ new message content.",
47215
47217
  "email": [Function],
47216
47218
  "facebookPreview": [Function],
47217
47219
  "gallery": [Function],
47220
+ "inApp": [Function],
47218
47221
  "language": [Function],
47219
47222
  "navigationConfig": [Function],
47220
47223
  "previewAndTest": [Function],
@@ -71728,6 +71731,7 @@ new message content.",
71728
71731
  "email": [Function],
71729
71732
  "facebookPreview": [Function],
71730
71733
  "gallery": [Function],
71734
+ "inApp": [Function],
71731
71735
  "language": [Function],
71732
71736
  "navigationConfig": [Function],
71733
71737
  "previewAndTest": [Function],
@@ -98538,6 +98542,7 @@ new message content.",
98538
98542
  "email": [Function],
98539
98543
  "facebookPreview": [Function],
98540
98544
  "gallery": [Function],
98545
+ "inApp": [Function],
98541
98546
  "language": [Function],
98542
98547
  "navigationConfig": [Function],
98543
98548
  "previewAndTest": [Function],
@@ -119977,6 +119982,7 @@ new message content.",
119977
119982
  "email": [Function],
119978
119983
  "facebookPreview": [Function],
119979
119984
  "gallery": [Function],
119985
+ "inApp": [Function],
119980
119986
  "language": [Function],
119981
119987
  "navigationConfig": [Function],
119982
119988
  "previewAndTest": [Function],
@@ -141386,6 +141392,7 @@ new message content.",
141386
141392
  "email": [Function],
141387
141393
  "facebookPreview": [Function],
141388
141394
  "gallery": [Function],
141395
+ "inApp": [Function],
141389
141396
  "language": [Function],
141390
141397
  "navigationConfig": [Function],
141391
141398
  "previewAndTest": [Function],
@@ -166807,6 +166814,7 @@ new message content.",
166807
166814
  "email": [Function],
166808
166815
  "facebookPreview": [Function],
166809
166816
  "gallery": [Function],
166817
+ "inApp": [Function],
166810
166818
  "language": [Function],
166811
166819
  "navigationConfig": [Function],
166812
166820
  "previewAndTest": [Function],
@@ -193216,6 +193224,7 @@ new message content.",
193216
193224
  "email": [Function],
193217
193225
  "facebookPreview": [Function],
193218
193226
  "gallery": [Function],
193227
+ "inApp": [Function],
193219
193228
  "language": [Function],
193220
193229
  "navigationConfig": [Function],
193221
193230
  "previewAndTest": [Function],
@@ -221922,6 +221931,7 @@ new message content.",
221922
221931
  "email": [Function],
221923
221932
  "facebookPreview": [Function],
221924
221933
  "gallery": [Function],
221934
+ "inApp": [Function],
221925
221935
  "language": [Function],
221926
221936
  "navigationConfig": [Function],
221927
221937
  "previewAndTest": [Function],
@@ -251610,6 +251620,7 @@ new message content.",
251610
251620
  "email": [Function],
251611
251621
  "facebookPreview": [Function],
251612
251622
  "gallery": [Function],
251623
+ "inApp": [Function],
251613
251624
  "language": [Function],
251614
251625
  "navigationConfig": [Function],
251615
251626
  "previewAndTest": [Function],
@@ -267364,6 +267375,7 @@ new message content.",
267364
267375
  "email": [Function],
267365
267376
  "facebookPreview": [Function],
267366
267377
  "gallery": [Function],
267378
+ "inApp": [Function],
267367
267379
  "language": [Function],
267368
267380
  "navigationConfig": [Function],
267369
267381
  "previewAndTest": [Function],
@@ -281969,6 +281981,7 @@ new message content.",
281969
281981
  "email": [Function],
281970
281982
  "facebookPreview": [Function],
281971
281983
  "gallery": [Function],
281984
+ "inApp": [Function],
281972
281985
  "language": [Function],
281973
281986
  "navigationConfig": [Function],
281974
281987
  "previewAndTest": [Function],
@@ -298681,6 +298694,7 @@ new message content.",
298681
298694
  "email": [Function],
298682
298695
  "facebookPreview": [Function],
298683
298696
  "gallery": [Function],
298697
+ "inApp": [Function],
298684
298698
  "language": [Function],
298685
298699
  "navigationConfig": [Function],
298686
298700
  "previewAndTest": [Function],
@@ -322730,6 +322744,7 @@ new message content.",
322730
322744
  "email": [Function],
322731
322745
  "facebookPreview": [Function],
322732
322746
  "gallery": [Function],
322747
+ "inApp": [Function],
322733
322748
  "language": [Function],
322734
322749
  "navigationConfig": [Function],
322735
322750
  "previewAndTest": [Function],
@@ -350369,6 +350384,7 @@ new message content.",
350369
350384
  "email": [Function],
350370
350385
  "facebookPreview": [Function],
350371
350386
  "gallery": [Function],
350387
+ "inApp": [Function],
350372
350388
  "language": [Function],
350373
350389
  "navigationConfig": [Function],
350374
350390
  "previewAndTest": [Function],
@@ -366694,6 +366710,7 @@ new message content.",
366694
366710
  "email": [Function],
366695
366711
  "facebookPreview": [Function],
366696
366712
  "gallery": [Function],
366713
+ "inApp": [Function],
366697
366714
  "language": [Function],
366698
366715
  "navigationConfig": [Function],
366699
366716
  "previewAndTest": [Function],
@@ -388103,6 +388120,7 @@ new message content.",
388103
388120
  "email": [Function],
388104
388121
  "facebookPreview": [Function],
388105
388122
  "gallery": [Function],
388123
+ "inApp": [Function],
388106
388124
  "language": [Function],
388107
388125
  "navigationConfig": [Function],
388108
388126
  "previewAndTest": [Function],
@@ -413524,6 +413542,7 @@ new message content.",
413524
413542
  "email": [Function],
413525
413543
  "facebookPreview": [Function],
413526
413544
  "gallery": [Function],
413545
+ "inApp": [Function],
413527
413546
  "language": [Function],
413528
413547
  "navigationConfig": [Function],
413529
413548
  "previewAndTest": [Function],
@@ -434933,6 +434952,7 @@ new message content.",
434933
434952
  "email": [Function],
434934
434953
  "facebookPreview": [Function],
434935
434954
  "gallery": [Function],
434955
+ "inApp": [Function],
434936
434956
  "language": [Function],
434937
434957
  "navigationConfig": [Function],
434938
434958
  "previewAndTest": [Function],
@@ -457162,6 +457182,7 @@ new message content.",
457162
457182
  "email": [Function],
457163
457183
  "facebookPreview": [Function],
457164
457184
  "gallery": [Function],
457185
+ "inApp": [Function],
457165
457186
  "language": [Function],
457166
457187
  "navigationConfig": [Function],
457167
457188
  "previewAndTest": [Function],
@@ -480214,6 +480235,7 @@ new message content.",
480214
480235
  "email": [Function],
480215
480236
  "facebookPreview": [Function],
480216
480237
  "gallery": [Function],
480238
+ "inApp": [Function],
480217
480239
  "language": [Function],
480218
480240
  "navigationConfig": [Function],
480219
480241
  "previewAndTest": [Function],
@@ -504086,6 +504108,7 @@ new message content.",
504086
504108
  "email": [Function],
504087
504109
  "facebookPreview": [Function],
504088
504110
  "gallery": [Function],
504111
+ "inApp": [Function],
504089
504112
  "language": [Function],
504090
504113
  "navigationConfig": [Function],
504091
504114
  "previewAndTest": [Function],
@@ -528801,6 +528824,7 @@ new message content.",
528801
528824
  "email": [Function],
528802
528825
  "facebookPreview": [Function],
528803
528826
  "gallery": [Function],
528827
+ "inApp": [Function],
528804
528828
  "language": [Function],
528805
528829
  "navigationConfig": [Function],
528806
528830
  "previewAndTest": [Function],
@@ -554356,6 +554380,7 @@ new message content.",
554356
554380
  "email": [Function],
554357
554381
  "facebookPreview": [Function],
554358
554382
  "gallery": [Function],
554383
+ "inApp": [Function],
554359
554384
  "language": [Function],
554360
554385
  "navigationConfig": [Function],
554361
554386
  "previewAndTest": [Function],
@@ -580742,6 +580767,7 @@ new message content.",
580742
580767
  "email": [Function],
580743
580768
  "facebookPreview": [Function],
580744
580769
  "gallery": [Function],
580770
+ "inApp": [Function],
580745
580771
  "language": [Function],
580746
580772
  "navigationConfig": [Function],
580747
580773
  "previewAndTest": [Function],
@@ -607959,6 +607985,7 @@ new message content.",
607959
607985
  "email": [Function],
607960
607986
  "facebookPreview": [Function],
607961
607987
  "gallery": [Function],
607988
+ "inApp": [Function],
607962
607989
  "language": [Function],
607963
607990
  "navigationConfig": [Function],
607964
607991
  "previewAndTest": [Function],
@@ -635988,6 +636015,7 @@ new message content.",
635988
636015
  "email": [Function],
635989
636016
  "facebookPreview": [Function],
635990
636017
  "gallery": [Function],
636018
+ "inApp": [Function],
635991
636019
  "language": [Function],
635992
636020
  "navigationConfig": [Function],
635993
636021
  "previewAndTest": [Function],
@@ -658258,6 +658286,7 @@ new message content.",
658258
658286
  "email": [Function],
658259
658287
  "facebookPreview": [Function],
658260
658288
  "gallery": [Function],
658289
+ "inApp": [Function],
658261
658290
  "language": [Function],
658262
658291
  "navigationConfig": [Function],
658263
658292
  "previewAndTest": [Function],
@@ -681355,6 +681384,7 @@ new message content.",
681355
681384
  "email": [Function],
681356
681385
  "facebookPreview": [Function],
681357
681386
  "gallery": [Function],
681387
+ "inApp": [Function],
681358
681388
  "language": [Function],
681359
681389
  "navigationConfig": [Function],
681360
681390
  "previewAndTest": [Function],
@@ -705343,6 +705373,7 @@ new message content.",
705343
705373
  "email": [Function],
705344
705374
  "facebookPreview": [Function],
705345
705375
  "gallery": [Function],
705376
+ "inApp": [Function],
705346
705377
  "language": [Function],
705347
705378
  "navigationConfig": [Function],
705348
705379
  "previewAndTest": [Function],
@@ -726752,6 +726783,7 @@ new message content.",
726752
726783
  "email": [Function],
726753
726784
  "facebookPreview": [Function],
726754
726785
  "gallery": [Function],
726786
+ "inApp": [Function],
726755
726787
  "language": [Function],
726756
726788
  "navigationConfig": [Function],
726757
726789
  "previewAndTest": [Function],
@@ -751488,6 +751520,7 @@ new message content.",
751488
751520
  "email": [Function],
751489
751521
  "facebookPreview": [Function],
751490
751522
  "gallery": [Function],
751523
+ "inApp": [Function],
751491
751524
  "language": [Function],
751492
751525
  "navigationConfig": [Function],
751493
751526
  "previewAndTest": [Function],
@@ -776332,6 +776365,7 @@ new message content.",
776332
776365
  "email": [Function],
776333
776366
  "facebookPreview": [Function],
776334
776367
  "gallery": [Function],
776368
+ "inApp": [Function],
776335
776369
  "language": [Function],
776336
776370
  "navigationConfig": [Function],
776337
776371
  "previewAndTest": [Function],
@@ -1,152 +0,0 @@
1
- /**
2
- * ValidationErrorDisplay Component Tests
3
- *
4
- * Tests for the ValidationErrorDisplay component that integrates with ErrorInfoNote.
5
- */
6
-
7
- import React from 'react';
8
- import { render, screen } from '@testing-library/react';
9
- import '@testing-library/jest-dom';
10
- import ValidationErrorDisplay from '../index';
11
-
12
- // Mock ErrorInfoNote component
13
- jest.mock('../../../../ErrorInfoNote', () => {
14
- return function MockErrorInfoNote({ errorMessages }) {
15
- const liquidErrors = errorMessages?.LIQUID_ERROR_MSG || [];
16
- const standardErrors = errorMessages?.STANDARD_ERROR_MSG || [];
17
- const hasErrors = liquidErrors.length > 0 || standardErrors.length > 0;
18
-
19
- if (!hasErrors) return null;
20
-
21
- return (
22
- <div data-testid="error-info-note">
23
- {liquidErrors.map((msg, index) => (
24
- <div key={`liquid-${index}`} data-testid="error-message">
25
- {msg}
26
- </div>
27
- ))}
28
- {standardErrors.map((msg, index) => (
29
- <div key={`standard-${index}`} data-testid="error-message">
30
- {msg}
31
- </div>
32
- ))}
33
- </div>
34
- );
35
- };
36
- });
37
-
38
- describe('ValidationErrorDisplay', () => {
39
- it('renders standard errors when validation has issues', () => {
40
- const mockValidation = {
41
- getAllIssues: () => [
42
- { message: 'Missing closing tag', severity: 'error', line: 5, column: 10 },
43
- { message: 'Invalid attribute', severity: 'error', line: 7 }
44
- ],
45
- isClean: () => false,
46
- isValidating: false
47
- };
48
-
49
- render(<ValidationErrorDisplay validation={mockValidation} />);
50
-
51
- expect(screen.getByTestId('error-info-note')).toBeInTheDocument();
52
- const errorMessages = screen.getAllByTestId('error-message');
53
- expect(errorMessages).toHaveLength(2);
54
- expect(errorMessages[0]).toHaveTextContent('Missing closing tag Line 5, Char 10.');
55
- expect(errorMessages[1]).toHaveTextContent('Invalid attribute Line 7.');
56
- });
57
-
58
- it('renders liquid errors separately', () => {
59
- const mockValidation = {
60
- getAllIssues: () => [
61
- { message: 'Invalid liquid syntax', severity: 'error', source: 'liquid-validator', line: 3 },
62
- { message: 'HTML error', severity: 'error', source: 'htmlhint', line: 10 }
63
- ],
64
- isClean: () => false,
65
- isValidating: false
66
- };
67
-
68
- render(<ValidationErrorDisplay validation={mockValidation} />);
69
-
70
- expect(screen.getByTestId('error-info-note')).toBeInTheDocument();
71
- const errorMessages = screen.getAllByTestId('error-message');
72
- expect(errorMessages).toHaveLength(2);
73
- // First should be liquid error, second should be standard error
74
- expect(errorMessages[0]).toHaveTextContent('Invalid liquid syntax Line 3.');
75
- expect(errorMessages[1]).toHaveTextContent('HTML error Line 10.');
76
- });
77
-
78
- it('does not render when validation has no errors', () => {
79
- const mockValidation = {
80
- getAllIssues: () => [],
81
- isClean: () => true,
82
- isValidating: false
83
- };
84
-
85
- const { container } = render(<ValidationErrorDisplay validation={mockValidation} />);
86
-
87
- expect(screen.queryByTestId('error-info-note')).not.toBeInTheDocument();
88
- expect(container.firstChild).toBeNull();
89
- });
90
-
91
- it('does not render when validation is null', () => {
92
- const { container } = render(<ValidationErrorDisplay validation={null} />);
93
-
94
- expect(screen.queryByTestId('error-info-note')).not.toBeInTheDocument();
95
- expect(container.firstChild).toBeNull();
96
- });
97
-
98
- it('does not render when validation is in progress', () => {
99
- const mockValidation = {
100
- getAllIssues: () => [],
101
- isClean: () => false,
102
- isValidating: true
103
- };
104
-
105
- const { container } = render(<ValidationErrorDisplay validation={mockValidation} />);
106
-
107
- expect(screen.queryByTestId('error-info-note')).not.toBeInTheDocument();
108
- expect(container.firstChild).toBeNull();
109
- });
110
-
111
- it('applies custom className', () => {
112
- const mockValidation = {
113
- getAllIssues: () => [{ message: 'Error', severity: 'error' }],
114
- isClean: () => false,
115
- isValidating: false
116
- };
117
-
118
- const { container } = render(
119
- <ValidationErrorDisplay validation={mockValidation} className="custom-class" />
120
- );
121
-
122
- const wrapper = container.querySelector('.validation-error-display');
123
- expect(wrapper).toHaveClass('custom-class');
124
- });
125
-
126
- it('handles inapp variant correctly', () => {
127
- const mockValidation = {
128
- getAllIssues: () => [{ message: 'Mobile error', severity: 'error' }],
129
- isClean: () => false,
130
- isValidating: false
131
- };
132
-
133
- render(<ValidationErrorDisplay validation={mockValidation} variant="inapp" />);
134
-
135
- expect(screen.getByTestId('error-info-note')).toBeInTheDocument();
136
- expect(screen.getByTestId('error-message')).toHaveTextContent('Mobile error');
137
- });
138
-
139
- it('includes rule information in error messages when available', () => {
140
- const mockValidation = {
141
- getAllIssues: () => [
142
- { message: 'Alt attribute required', severity: 'error', rule: 'alt-require', line: 5 }
143
- ],
144
- isClean: () => false,
145
- isValidating: false
146
- };
147
-
148
- render(<ValidationErrorDisplay validation={mockValidation} />);
149
-
150
- expect(screen.getByTestId('error-message')).toHaveTextContent('Alt attribute required Line 5. • alt-require');
151
- });
152
- });
@@ -1,214 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent, within, screen } from '@testing-library/react';
3
- import '@testing-library/jest-dom';
4
- import { IntlProvider } from 'react-intl';
5
- import { Provider } from 'react-redux';
6
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils'
7
- import { initialReducer } from '../../../initialReducer';
8
- import EmailWrapperView from '../components/EmailWrapperView';
9
- import { EmailWrapperViewMockProps } from '../mockdata/mockdata';
10
- import { EMAIL_CREATE_MODES } from '../constants';
11
- import history from '../../../utils/history';
12
-
13
- // This mock needs to be before any imports
14
- jest.mock('../../../v2Containers/Email', () => ({
15
- __esModule: true,
16
- default: () => <div data-testid="email-create-container" />,
17
- }));
18
-
19
- // Mock react-router
20
- jest.mock('react-router-dom', () => ({
21
- ...jest.requireActual('react-router-dom'),
22
- useHistory: () => ({
23
- push: jest.fn(),
24
- replace: jest.fn(),
25
- go: jest.fn(),
26
- goBack: jest.fn(),
27
- goForward: jest.fn(),
28
- location: { search: '' }
29
- }),
30
- }));
31
-
32
- // Mock redux-auth-wrapper
33
- jest.mock('redux-auth-wrapper/history4/redirect', () => ({
34
- connectedRouterRedirect: () => (Component) => Component,
35
- }));
36
-
37
- // Mock react-router
38
- jest.mock('connected-react-router', () => ({
39
- push: jest.fn(),
40
- replace: jest.fn(),
41
- go: jest.fn(),
42
- goBack: jest.fn(),
43
- goForward: jest.fn(),
44
- }));
45
-
46
- // Mock the saga injector
47
- jest.mock('@capillarytech/vulcan-react-sdk/utils/injectSaga', () => ({
48
- __esModule: true,
49
- default: () => (Component) => Component,
50
- }));
51
-
52
-
53
- const initialState = {
54
- cap: { loading: false, error: null },
55
- router: { location: { pathname: '/' } }
56
- };
57
-
58
- describe('EmailWrapperView', () => {
59
- let store;
60
-
61
- beforeAll(() => {
62
- store = configureStore(initialState, initialReducer, history);
63
- });
64
-
65
- const renderWithProviders = (component) => {
66
- return render(
67
- <Provider store={store}>
68
- <IntlProvider locale="en" messages={{}}>
69
- {component}
70
- </IntlProvider>
71
- </Provider>
72
- );
73
- };
74
-
75
- it('renders mode selection UI when step is modeSelection', () => {
76
- const props = {
77
- ...EmailWrapperViewMockProps,
78
- step: 'modeSelection',
79
- };
80
-
81
- const { getByText } = renderWithProviders(<EmailWrapperView {...props} />);
82
- expect(getByText('Create using editor')).toBeInTheDocument();
83
- expect(getByText('Upload zip file')).toBeInTheDocument();
84
- });
85
-
86
- it('shows template name input in full mode', () => {
87
- const props = {
88
- ...EmailWrapperViewMockProps,
89
- isFullMode: true,
90
- step: 'modeSelection',
91
- };
92
-
93
- const { container } = renderWithProviders(<EmailWrapperView {...props} />);
94
- const input = container.querySelector('.ant-input');
95
- expect(input).toBeInTheDocument();
96
- expect(input.value).toBe(props.templateName);
97
- });
98
-
99
- it('handles template name changes', () => {
100
- const props = {
101
- ...EmailWrapperViewMockProps,
102
- isFullMode: true,
103
- step: 'modeSelection',
104
- onTemplateNameChange: jest.fn(),
105
- };
106
-
107
- const { container } = renderWithProviders(<EmailWrapperView {...props} />);
108
- const input = container.querySelector('.ant-input');
109
- expect(input).toBeInTheDocument();
110
-
111
- // Create a change event and fire it
112
- fireEvent.change(input, { target: { value: 'New Template Name' } });
113
-
114
- // Just verify that the function was called
115
- expect(props.onTemplateNameChange).toHaveBeenCalled();
116
- });
117
-
118
- it('shows upload button when in upload mode', () => {
119
- const props = {
120
- ...EmailWrapperViewMockProps,
121
- step: 'modeSelection',
122
- emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
123
- uploadButtonLabel: 'Upload',
124
- };
125
-
126
- const { getByText, container } = renderWithProviders(<EmailWrapperView {...props} />);
127
-
128
- // Find the "Upload zip file" section
129
- const modeSelectionSection = getByText('Upload zip file').closest('div');
130
-
131
- // Find any button in the upload section
132
- const uploadButton = container.querySelector('.ant-btn');
133
-
134
- // Verify that we found an upload button
135
- expect(uploadButton).toBeInTheDocument();
136
- expect(uploadButton.textContent).toContain('Upload');
137
- });
138
-
139
- it('shows loading spinner when uploading', () => {
140
- const props = {
141
- ...EmailWrapperViewMockProps,
142
- isUploading: true,
143
- emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
144
- step: 'modeSelection',
145
- };
146
-
147
- const { container } = renderWithProviders(<EmailWrapperView {...props} />);
148
- const spinner = container.querySelector('.ant-spin');
149
- expect(spinner).toBeInTheDocument();
150
- });
151
-
152
- it('shows content creation UI when not in mode selection', () => {
153
- const props = {
154
- ...EmailWrapperViewMockProps,
155
- step: 'contentCreation',
156
- isShowEmailCreate: true,
157
- };
158
-
159
- const { getByTestId } = renderWithProviders(<EmailWrapperView {...props} />);
160
- expect(getByTestId('email-create-container')).toBeInTheDocument();
161
- });
162
-
163
- it('disables upload button when template name is empty in full mode', () => {
164
- const props = {
165
- ...EmailWrapperViewMockProps,
166
- isFullMode: true,
167
- step: 'modeSelection',
168
- emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
169
- templateName: '',
170
- isTemplateNameEmpty: true,
171
- uploadButtonLabel: 'Upload',
172
- };
173
-
174
- const { getByText, container } = renderWithProviders(<EmailWrapperView {...props} />);
175
-
176
- // Find the Upload section
177
- getByText('Upload zip file');
178
-
179
- // Find button in the container
180
- const uploadButton = container.querySelector('.ant-btn');
181
-
182
- // Check if the button is disabled
183
- expect(uploadButton).toBeDisabled();
184
- });
185
-
186
- it('shows error message when template name is empty during upload', () => {
187
- const props = {
188
- ...EmailWrapperViewMockProps,
189
- isFullMode: true,
190
- step: 'modeSelection',
191
- emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
192
- templateName: '',
193
- isTemplateNameEmpty: true,
194
- // Add errorMessage directly to the props
195
- errorMessage: 'Please enter template name',
196
- intl: {
197
- formatMessage: () => 'Please enter template name',
198
- },
199
- };
200
-
201
- const { container } = renderWithProviders(<EmailWrapperView {...props} />);
202
-
203
- // Look for error feedback in the Ant Design form
204
- const errorElement = container.querySelector('.ant-form-item-explain');
205
-
206
- if (errorElement) {
207
- expect(errorElement.textContent).toContain('Please enter template name');
208
- } else {
209
- // If the standard error element is not found, look for any element containing the error text
210
- const allText = container.textContent;
211
- expect(allText).toContain('Please enter template name');
212
- }
213
- });
214
- });