@capillarytech/creatives-library 8.0.246-alpha.0 → 8.0.246

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 (133) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +1 -2
  4. package/initialReducer.js +0 -2
  5. package/package.json +1 -1
  6. package/services/api.js +0 -10
  7. package/services/tests/api.test.js +0 -18
  8. package/utils/common.js +0 -5
  9. package/utils/commonUtils.js +5 -28
  10. package/utils/tests/commonUtil.test.js +0 -224
  11. package/utils/transformTemplateConfig.js +10 -0
  12. package/v2Components/CapDeviceContent/index.js +56 -61
  13. package/v2Components/CapTagList/index.js +1 -6
  14. package/v2Components/CapTagListWithInput/index.js +1 -5
  15. package/v2Components/CapTagListWithInput/messages.js +1 -1
  16. package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
  17. package/v2Components/ErrorInfoNote/index.js +72 -447
  18. package/v2Components/ErrorInfoNote/messages.js +0 -22
  19. package/v2Components/ErrorInfoNote/style.scss +4 -280
  20. package/v2Components/FormBuilder/tests/index.test.js +4 -13
  21. package/v2Components/HtmlEditor/HTMLEditor.js +94 -642
  22. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1135
  23. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +16 -27
  24. package/v2Components/HtmlEditor/_htmlEditor.scss +45 -108
  25. package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
  26. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +101 -13
  27. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +139 -148
  28. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
  29. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  30. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +0 -9
  31. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
  32. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
  33. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
  34. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
  35. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
  36. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  37. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
  38. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +6 -3
  39. package/v2Components/HtmlEditor/components/PreviewPane/index.js +13 -11
  40. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  41. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
  42. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -49
  43. package/v2Components/HtmlEditor/constants.js +20 -29
  44. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
  45. package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
  46. package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
  47. package/v2Components/HtmlEditor/hooks/useValidation.js +45 -150
  48. package/v2Components/HtmlEditor/index.js +1 -1
  49. package/v2Components/HtmlEditor/messages.js +85 -95
  50. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +102 -134
  51. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
  52. package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -66
  53. package/v2Components/MobilePushPreviewV2/index.js +7 -32
  54. package/v2Components/TemplatePreview/_templatePreview.scss +24 -44
  55. package/v2Components/TemplatePreview/index.js +32 -47
  56. package/v2Components/TemplatePreview/messages.js +0 -4
  57. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +0 -1
  58. package/v2Components/TestAndPreviewSlidebox/index.js +25 -31
  59. package/v2Containers/BeeEditor/index.js +90 -172
  60. package/v2Containers/CreativesContainer/SlideBoxContent.js +51 -128
  61. package/v2Containers/CreativesContainer/SlideBoxFooter.js +12 -113
  62. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -2
  63. package/v2Containers/CreativesContainer/constants.js +0 -1
  64. package/v2Containers/CreativesContainer/index.js +46 -238
  65. package/v2Containers/CreativesContainer/messages.js +0 -8
  66. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +2 -11
  67. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +50 -38
  68. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -91
  69. package/v2Containers/Email/actions.js +0 -7
  70. package/v2Containers/Email/constants.js +1 -5
  71. package/v2Containers/Email/index.js +30 -229
  72. package/v2Containers/Email/messages.js +0 -32
  73. package/v2Containers/Email/reducer.js +1 -12
  74. package/v2Containers/Email/sagas.js +7 -61
  75. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
  76. package/v2Containers/Email/tests/sagas.test.js +1 -1
  77. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +15 -210
  78. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
  79. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
  80. package/v2Containers/EmailWrapper/constants.js +0 -2
  81. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +77 -629
  82. package/v2Containers/EmailWrapper/index.js +23 -103
  83. package/v2Containers/EmailWrapper/messages.js +1 -61
  84. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
  85. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -509
  86. package/v2Containers/InApp/actions.js +0 -7
  87. package/v2Containers/InApp/constants.js +4 -20
  88. package/v2Containers/InApp/index.js +357 -801
  89. package/v2Containers/InApp/index.scss +3 -4
  90. package/v2Containers/InApp/messages.js +3 -7
  91. package/v2Containers/InApp/reducer.js +3 -21
  92. package/v2Containers/InApp/sagas.js +9 -29
  93. package/v2Containers/InApp/selectors.js +5 -25
  94. package/v2Containers/InApp/tests/index.test.js +50 -154
  95. package/v2Containers/InApp/tests/reducer.test.js +0 -34
  96. package/v2Containers/InApp/tests/sagas.test.js +9 -61
  97. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
  98. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
  99. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -2
  100. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -9
  101. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -12
  102. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -4
  103. package/v2Containers/TagList/index.js +19 -62
  104. package/v2Containers/Templates/_templates.scss +1 -60
  105. package/v2Containers/Templates/index.js +4 -89
  106. package/v2Containers/Templates/messages.js +0 -4
  107. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -35
  108. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -874
  109. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -254
  110. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -363
  111. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
  112. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.apiErrors.test.js +0 -630
  113. package/v2Containers/BeePopupEditor/constants.js +0 -10
  114. package/v2Containers/BeePopupEditor/index.js +0 -193
  115. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
  116. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1317
  117. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +0 -1605
  118. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +0 -520
  119. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +0 -643
  120. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
  121. package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
  122. package/v2Containers/InApp/tests/selectors.test.js +0 -612
  123. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -162
  124. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
  125. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -9
  126. package/v2Containers/InAppWrapper/constants.js +0 -16
  127. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
  128. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
  129. package/v2Containers/InAppWrapper/index.js +0 -148
  130. package/v2Containers/InAppWrapper/messages.js +0 -49
  131. package/v2Containers/InappAdvance/index.js +0 -1099
  132. package/v2Containers/InappAdvance/index.scss +0 -10
  133. package/v2Containers/InappAdvance/tests/index.test.js +0 -448
@@ -1,630 +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
- });
@@ -1,10 +0,0 @@
1
- export const BEE_LAYOUT_OPTIONS = {
2
- POPUP: "classic-center",
3
- HEADER: "bar-top",
4
- FOOTER: "bar-bottom",
5
- FULLSCREEN: "classic-center",
6
- };
7
- export const MOBILE = "mobile";
8
- export const UNSUBSCRIBE = 'unsubscribe';
9
- export const ANDROID = 'ANDROID';
10
- export const IOS = 'IOS';