@capillarytech/creatives-library 8.0.271 → 8.0.272

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 (149) 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/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +17 -35
  9. package/tests/integration/TemplateCreation/api-response.js +31 -1
  10. package/tests/integration/TemplateCreation/msw-handler.js +2 -0
  11. package/utils/common.js +5 -0
  12. package/utils/commonUtils.js +28 -5
  13. package/utils/tests/commonUtil.test.js +224 -0
  14. package/utils/transformTemplateConfig.js +0 -10
  15. package/v2Components/CapDeviceContent/index.js +61 -56
  16. package/v2Components/CapTagList/index.js +6 -1
  17. package/v2Components/CapTagListWithInput/index.js +5 -1
  18. package/v2Components/CapTagListWithInput/messages.js +1 -1
  19. package/v2Components/CapWhatsappCTA/tests/index.test.js +5 -0
  20. package/v2Components/ErrorInfoNote/constants.js +1 -0
  21. package/v2Components/ErrorInfoNote/index.js +402 -72
  22. package/v2Components/ErrorInfoNote/messages.js +32 -6
  23. package/v2Components/ErrorInfoNote/style.scss +278 -6
  24. package/v2Components/FormBuilder/tests/index.test.js +13 -4
  25. package/v2Components/HtmlEditor/HTMLEditor.js +418 -99
  26. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +870 -0
  27. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1882 -133
  28. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +27 -16
  29. package/v2Components/HtmlEditor/_htmlEditor.scss +108 -45
  30. package/v2Components/HtmlEditor/_index.lazy.scss +0 -1
  31. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +23 -102
  32. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +148 -140
  33. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +2 -1
  34. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  35. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +9 -1
  36. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +31 -6
  37. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +22 -0
  38. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +4 -7
  39. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +35 -45
  40. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +1 -3
  41. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  42. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +7 -6
  43. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +7 -10
  44. package/v2Components/HtmlEditor/components/PreviewPane/index.js +22 -43
  45. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  46. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/_validationErrorDisplay.scss +18 -0
  47. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +36 -31
  48. package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +46 -34
  49. package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +6 -0
  50. package/v2Components/HtmlEditor/components/ValidationPanel/index.js +52 -46
  51. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +277 -0
  52. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +295 -0
  53. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +51 -0
  54. package/v2Components/HtmlEditor/constants.js +45 -20
  55. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +373 -16
  56. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +351 -16
  57. package/v2Components/HtmlEditor/hooks/useEditorContent.js +5 -2
  58. package/v2Components/HtmlEditor/hooks/useInAppContent.js +88 -146
  59. package/v2Components/HtmlEditor/hooks/useValidation.js +213 -56
  60. package/v2Components/HtmlEditor/index.js +1 -1
  61. package/v2Components/HtmlEditor/messages.js +102 -94
  62. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +214 -45
  63. package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +134 -0
  64. package/v2Components/HtmlEditor/utils/contentSanitizer.js +40 -41
  65. package/v2Components/HtmlEditor/utils/htmlValidator.js +71 -72
  66. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +158 -124
  67. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +23 -25
  68. package/v2Components/HtmlEditor/utils/validationAdapter.js +66 -41
  69. package/v2Components/HtmlEditor/utils/validationConstants.js +38 -0
  70. package/v2Components/MobilePushPreviewV2/constants.js +6 -0
  71. package/v2Components/MobilePushPreviewV2/index.js +33 -7
  72. package/v2Components/TemplatePreview/_templatePreview.scss +55 -24
  73. package/v2Components/TemplatePreview/index.js +47 -32
  74. package/v2Components/TemplatePreview/messages.js +4 -0
  75. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +1 -0
  76. package/v2Containers/BeeEditor/index.js +172 -90
  77. package/v2Containers/BeePopupEditor/_beePopupEditor.scss +14 -0
  78. package/v2Containers/BeePopupEditor/constants.js +10 -0
  79. package/v2Containers/BeePopupEditor/index.js +194 -0
  80. package/v2Containers/BeePopupEditor/tests/index.test.js +627 -0
  81. package/v2Containers/CreativesContainer/SlideBoxContent.js +127 -51
  82. package/v2Containers/CreativesContainer/SlideBoxFooter.js +156 -13
  83. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -1
  84. package/v2Containers/CreativesContainer/constants.js +1 -0
  85. package/v2Containers/CreativesContainer/index.js +251 -47
  86. package/v2Containers/CreativesContainer/messages.js +8 -0
  87. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +11 -2
  88. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +38 -50
  89. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +103 -0
  90. package/v2Containers/Email/actions.js +7 -0
  91. package/v2Containers/Email/constants.js +5 -1
  92. package/v2Containers/Email/index.js +234 -29
  93. package/v2Containers/Email/messages.js +32 -0
  94. package/v2Containers/Email/reducer.js +12 -1
  95. package/v2Containers/Email/sagas.js +61 -7
  96. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -0
  97. package/v2Containers/Email/tests/reducer.test.js +46 -0
  98. package/v2Containers/Email/tests/sagas.test.js +320 -29
  99. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +1246 -0
  100. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +212 -21
  101. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +40 -74
  102. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +2472 -0
  103. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +520 -0
  104. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +2 -67
  105. package/v2Containers/EmailWrapper/constants.js +2 -0
  106. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +627 -79
  107. package/v2Containers/EmailWrapper/index.js +103 -23
  108. package/v2Containers/EmailWrapper/messages.js +65 -1
  109. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +955 -0
  110. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +596 -82
  111. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +376 -0
  112. package/v2Containers/InApp/__tests__/sagas.test.js +363 -0
  113. package/v2Containers/InApp/actions.js +7 -0
  114. package/v2Containers/InApp/constants.js +20 -4
  115. package/v2Containers/InApp/index.js +802 -360
  116. package/v2Containers/InApp/index.scss +4 -3
  117. package/v2Containers/InApp/messages.js +7 -3
  118. package/v2Containers/InApp/reducer.js +21 -3
  119. package/v2Containers/InApp/sagas.js +29 -9
  120. package/v2Containers/InApp/selectors.js +25 -5
  121. package/v2Containers/InApp/tests/index.test.js +154 -50
  122. package/v2Containers/InApp/tests/reducer.test.js +34 -0
  123. package/v2Containers/InApp/tests/sagas.test.js +61 -9
  124. package/v2Containers/InApp/tests/selectors.test.js +612 -0
  125. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +151 -0
  126. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +267 -0
  127. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +23 -0
  128. package/v2Containers/InAppWrapper/constants.js +16 -0
  129. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +473 -0
  130. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +198 -0
  131. package/v2Containers/InAppWrapper/index.js +148 -0
  132. package/v2Containers/InAppWrapper/messages.js +49 -0
  133. package/v2Containers/InappAdvance/index.js +1099 -0
  134. package/v2Containers/InappAdvance/index.scss +10 -0
  135. package/v2Containers/InappAdvance/tests/index.test.js +448 -0
  136. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  137. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  138. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
  139. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
  140. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -0
  141. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
  142. package/v2Containers/TagList/index.js +62 -19
  143. package/v2Containers/Templates/_templates.scss +60 -1
  144. package/v2Containers/Templates/index.js +89 -4
  145. package/v2Containers/Templates/messages.js +4 -0
  146. package/v2Containers/TemplatesV2/TemplatesV2.style.js +4 -2
  147. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -0
  148. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +0 -152
  149. 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],
@@ -23689,6 +23690,7 @@ new message content.",
23689
23690
  "email": [Function],
23690
23691
  "facebookPreview": [Function],
23691
23692
  "gallery": [Function],
23693
+ "inApp": [Function],
23692
23694
  "language": [Function],
23693
23695
  "navigationConfig": [Function],
23694
23696
  "previewAndTest": [Function],
@@ -47213,6 +47215,7 @@ new message content.",
47213
47215
  "email": [Function],
47214
47216
  "facebookPreview": [Function],
47215
47217
  "gallery": [Function],
47218
+ "inApp": [Function],
47216
47219
  "language": [Function],
47217
47220
  "navigationConfig": [Function],
47218
47221
  "previewAndTest": [Function],
@@ -71725,6 +71728,7 @@ new message content.",
71725
71728
  "email": [Function],
71726
71729
  "facebookPreview": [Function],
71727
71730
  "gallery": [Function],
71731
+ "inApp": [Function],
71728
71732
  "language": [Function],
71729
71733
  "navigationConfig": [Function],
71730
71734
  "previewAndTest": [Function],
@@ -98534,6 +98538,7 @@ new message content.",
98534
98538
  "email": [Function],
98535
98539
  "facebookPreview": [Function],
98536
98540
  "gallery": [Function],
98541
+ "inApp": [Function],
98537
98542
  "language": [Function],
98538
98543
  "navigationConfig": [Function],
98539
98544
  "previewAndTest": [Function],
@@ -119972,6 +119977,7 @@ new message content.",
119972
119977
  "email": [Function],
119973
119978
  "facebookPreview": [Function],
119974
119979
  "gallery": [Function],
119980
+ "inApp": [Function],
119975
119981
  "language": [Function],
119976
119982
  "navigationConfig": [Function],
119977
119983
  "previewAndTest": [Function],
@@ -141380,6 +141386,7 @@ new message content.",
141380
141386
  "email": [Function],
141381
141387
  "facebookPreview": [Function],
141382
141388
  "gallery": [Function],
141389
+ "inApp": [Function],
141383
141390
  "language": [Function],
141384
141391
  "navigationConfig": [Function],
141385
141392
  "previewAndTest": [Function],
@@ -166800,6 +166807,7 @@ new message content.",
166800
166807
  "email": [Function],
166801
166808
  "facebookPreview": [Function],
166802
166809
  "gallery": [Function],
166810
+ "inApp": [Function],
166803
166811
  "language": [Function],
166804
166812
  "navigationConfig": [Function],
166805
166813
  "previewAndTest": [Function],
@@ -193208,6 +193216,7 @@ new message content.",
193208
193216
  "email": [Function],
193209
193217
  "facebookPreview": [Function],
193210
193218
  "gallery": [Function],
193219
+ "inApp": [Function],
193211
193220
  "language": [Function],
193212
193221
  "navigationConfig": [Function],
193213
193222
  "previewAndTest": [Function],
@@ -221913,6 +221922,7 @@ new message content.",
221913
221922
  "email": [Function],
221914
221923
  "facebookPreview": [Function],
221915
221924
  "gallery": [Function],
221925
+ "inApp": [Function],
221916
221926
  "language": [Function],
221917
221927
  "navigationConfig": [Function],
221918
221928
  "previewAndTest": [Function],
@@ -251600,6 +251610,7 @@ new message content.",
251600
251610
  "email": [Function],
251601
251611
  "facebookPreview": [Function],
251602
251612
  "gallery": [Function],
251613
+ "inApp": [Function],
251603
251614
  "language": [Function],
251604
251615
  "navigationConfig": [Function],
251605
251616
  "previewAndTest": [Function],
@@ -267353,6 +267364,7 @@ new message content.",
267353
267364
  "email": [Function],
267354
267365
  "facebookPreview": [Function],
267355
267366
  "gallery": [Function],
267367
+ "inApp": [Function],
267356
267368
  "language": [Function],
267357
267369
  "navigationConfig": [Function],
267358
267370
  "previewAndTest": [Function],
@@ -281957,6 +281969,7 @@ new message content.",
281957
281969
  "email": [Function],
281958
281970
  "facebookPreview": [Function],
281959
281971
  "gallery": [Function],
281972
+ "inApp": [Function],
281960
281973
  "language": [Function],
281961
281974
  "navigationConfig": [Function],
281962
281975
  "previewAndTest": [Function],
@@ -298668,6 +298681,7 @@ new message content.",
298668
298681
  "email": [Function],
298669
298682
  "facebookPreview": [Function],
298670
298683
  "gallery": [Function],
298684
+ "inApp": [Function],
298671
298685
  "language": [Function],
298672
298686
  "navigationConfig": [Function],
298673
298687
  "previewAndTest": [Function],
@@ -322716,6 +322730,7 @@ new message content.",
322716
322730
  "email": [Function],
322717
322731
  "facebookPreview": [Function],
322718
322732
  "gallery": [Function],
322733
+ "inApp": [Function],
322719
322734
  "language": [Function],
322720
322735
  "navigationConfig": [Function],
322721
322736
  "previewAndTest": [Function],
@@ -350354,6 +350369,7 @@ new message content.",
350354
350369
  "email": [Function],
350355
350370
  "facebookPreview": [Function],
350356
350371
  "gallery": [Function],
350372
+ "inApp": [Function],
350357
350373
  "language": [Function],
350358
350374
  "navigationConfig": [Function],
350359
350375
  "previewAndTest": [Function],
@@ -366678,6 +366694,7 @@ new message content.",
366678
366694
  "email": [Function],
366679
366695
  "facebookPreview": [Function],
366680
366696
  "gallery": [Function],
366697
+ "inApp": [Function],
366681
366698
  "language": [Function],
366682
366699
  "navigationConfig": [Function],
366683
366700
  "previewAndTest": [Function],
@@ -388086,6 +388103,7 @@ new message content.",
388086
388103
  "email": [Function],
388087
388104
  "facebookPreview": [Function],
388088
388105
  "gallery": [Function],
388106
+ "inApp": [Function],
388089
388107
  "language": [Function],
388090
388108
  "navigationConfig": [Function],
388091
388109
  "previewAndTest": [Function],
@@ -413506,6 +413524,7 @@ new message content.",
413506
413524
  "email": [Function],
413507
413525
  "facebookPreview": [Function],
413508
413526
  "gallery": [Function],
413527
+ "inApp": [Function],
413509
413528
  "language": [Function],
413510
413529
  "navigationConfig": [Function],
413511
413530
  "previewAndTest": [Function],
@@ -434914,6 +434933,7 @@ new message content.",
434914
434933
  "email": [Function],
434915
434934
  "facebookPreview": [Function],
434916
434935
  "gallery": [Function],
434936
+ "inApp": [Function],
434917
434937
  "language": [Function],
434918
434938
  "navigationConfig": [Function],
434919
434939
  "previewAndTest": [Function],
@@ -457142,6 +457162,7 @@ new message content.",
457142
457162
  "email": [Function],
457143
457163
  "facebookPreview": [Function],
457144
457164
  "gallery": [Function],
457165
+ "inApp": [Function],
457145
457166
  "language": [Function],
457146
457167
  "navigationConfig": [Function],
457147
457168
  "previewAndTest": [Function],
@@ -480193,6 +480214,7 @@ new message content.",
480193
480214
  "email": [Function],
480194
480215
  "facebookPreview": [Function],
480195
480216
  "gallery": [Function],
480217
+ "inApp": [Function],
480196
480218
  "language": [Function],
480197
480219
  "navigationConfig": [Function],
480198
480220
  "previewAndTest": [Function],
@@ -504064,6 +504086,7 @@ new message content.",
504064
504086
  "email": [Function],
504065
504087
  "facebookPreview": [Function],
504066
504088
  "gallery": [Function],
504089
+ "inApp": [Function],
504067
504090
  "language": [Function],
504068
504091
  "navigationConfig": [Function],
504069
504092
  "previewAndTest": [Function],
@@ -528778,6 +528801,7 @@ new message content.",
528778
528801
  "email": [Function],
528779
528802
  "facebookPreview": [Function],
528780
528803
  "gallery": [Function],
528804
+ "inApp": [Function],
528781
528805
  "language": [Function],
528782
528806
  "navigationConfig": [Function],
528783
528807
  "previewAndTest": [Function],
@@ -554332,6 +554356,7 @@ new message content.",
554332
554356
  "email": [Function],
554333
554357
  "facebookPreview": [Function],
554334
554358
  "gallery": [Function],
554359
+ "inApp": [Function],
554335
554360
  "language": [Function],
554336
554361
  "navigationConfig": [Function],
554337
554362
  "previewAndTest": [Function],
@@ -580717,6 +580742,7 @@ new message content.",
580717
580742
  "email": [Function],
580718
580743
  "facebookPreview": [Function],
580719
580744
  "gallery": [Function],
580745
+ "inApp": [Function],
580720
580746
  "language": [Function],
580721
580747
  "navigationConfig": [Function],
580722
580748
  "previewAndTest": [Function],
@@ -607933,6 +607959,7 @@ new message content.",
607933
607959
  "email": [Function],
607934
607960
  "facebookPreview": [Function],
607935
607961
  "gallery": [Function],
607962
+ "inApp": [Function],
607936
607963
  "language": [Function],
607937
607964
  "navigationConfig": [Function],
607938
607965
  "previewAndTest": [Function],
@@ -635961,6 +635988,7 @@ new message content.",
635961
635988
  "email": [Function],
635962
635989
  "facebookPreview": [Function],
635963
635990
  "gallery": [Function],
635991
+ "inApp": [Function],
635964
635992
  "language": [Function],
635965
635993
  "navigationConfig": [Function],
635966
635994
  "previewAndTest": [Function],
@@ -658230,6 +658258,7 @@ new message content.",
658230
658258
  "email": [Function],
658231
658259
  "facebookPreview": [Function],
658232
658260
  "gallery": [Function],
658261
+ "inApp": [Function],
658233
658262
  "language": [Function],
658234
658263
  "navigationConfig": [Function],
658235
658264
  "previewAndTest": [Function],
@@ -681326,6 +681355,7 @@ new message content.",
681326
681355
  "email": [Function],
681327
681356
  "facebookPreview": [Function],
681328
681357
  "gallery": [Function],
681358
+ "inApp": [Function],
681329
681359
  "language": [Function],
681330
681360
  "navigationConfig": [Function],
681331
681361
  "previewAndTest": [Function],
@@ -705313,6 +705343,7 @@ new message content.",
705313
705343
  "email": [Function],
705314
705344
  "facebookPreview": [Function],
705315
705345
  "gallery": [Function],
705346
+ "inApp": [Function],
705316
705347
  "language": [Function],
705317
705348
  "navigationConfig": [Function],
705318
705349
  "previewAndTest": [Function],
@@ -726721,6 +726752,7 @@ new message content.",
726721
726752
  "email": [Function],
726722
726753
  "facebookPreview": [Function],
726723
726754
  "gallery": [Function],
726755
+ "inApp": [Function],
726724
726756
  "language": [Function],
726725
726757
  "navigationConfig": [Function],
726726
726758
  "previewAndTest": [Function],
@@ -751456,6 +751488,7 @@ new message content.",
751456
751488
  "email": [Function],
751457
751489
  "facebookPreview": [Function],
751458
751490
  "gallery": [Function],
751491
+ "inApp": [Function],
751459
751492
  "language": [Function],
751460
751493
  "navigationConfig": [Function],
751461
751494
  "previewAndTest": [Function],
@@ -776299,6 +776332,7 @@ new message content.",
776299
776332
  "email": [Function],
776300
776333
  "facebookPreview": [Function],
776301
776334
  "gallery": [Function],
776335
+ "inApp": [Function],
776302
776336
  "language": [Function],
776303
776337
  "navigationConfig": [Function],
776304
776338
  "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
- });