@capillarytech/creatives-library 8.0.292-alpha.0 → 8.0.293

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 (80) hide show
  1. package/constants/unified.js +1 -3
  2. package/initialState.js +2 -0
  3. package/package.json +1 -1
  4. package/utils/common.js +8 -5
  5. package/utils/commonUtils.js +85 -4
  6. package/utils/tagValidations.js +223 -83
  7. package/utils/tests/commonUtil.test.js +124 -147
  8. package/utils/tests/tagValidations.test.js +358 -441
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +33 -0
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +422 -0
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +35 -0
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +725 -0
  13. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +92 -0
  14. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +251 -0
  15. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +111 -0
  16. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +91 -0
  17. package/v2Components/CommonTestAndPreview/SendTestMessage.js +51 -1
  18. package/v2Components/CommonTestAndPreview/actions.js +20 -0
  19. package/v2Components/CommonTestAndPreview/constants.js +10 -0
  20. package/v2Components/CommonTestAndPreview/index.js +148 -15
  21. package/v2Components/CommonTestAndPreview/reducer.js +47 -0
  22. package/v2Components/CommonTestAndPreview/sagas.js +60 -0
  23. package/v2Components/CommonTestAndPreview/selectors.js +51 -0
  24. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +889 -0
  25. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +222 -0
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +235 -0
  27. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +135 -0
  28. package/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
  29. package/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -0
  30. package/v2Components/CommonTestAndPreview/tests/index.test.js +342 -1
  31. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
  32. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +145 -0
  33. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
  34. package/v2Components/ErrorInfoNote/index.js +5 -2
  35. package/v2Components/FormBuilder/index.js +203 -137
  36. package/v2Components/FormBuilder/messages.js +8 -0
  37. package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
  38. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
  39. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
  40. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
  41. package/v2Components/TestAndPreviewSlidebox/index.js +14 -0
  42. package/v2Containers/Cap/mockData.js +14 -0
  43. package/v2Containers/Cap/reducer.js +55 -3
  44. package/v2Containers/Cap/tests/reducer.test.js +102 -0
  45. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
  46. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
  47. package/v2Containers/CreativesContainer/index.js +7 -30
  48. package/v2Containers/Email/index.js +5 -1
  49. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
  50. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +137 -29
  51. package/v2Containers/FTP/index.js +51 -2
  52. package/v2Containers/FTP/messages.js +4 -0
  53. package/v2Containers/InApp/index.js +104 -4
  54. package/v2Containers/InApp/tests/index.test.js +6 -17
  55. package/v2Containers/InappAdvance/index.js +108 -4
  56. package/v2Containers/InappAdvance/tests/index.test.js +0 -2
  57. package/v2Containers/Line/Container/Text/index.js +1 -0
  58. package/v2Containers/MobilePush/Create/index.js +19 -42
  59. package/v2Containers/MobilePush/Edit/index.js +19 -42
  60. package/v2Containers/MobilePushNew/index.js +32 -12
  61. package/v2Containers/MobilepushWrapper/index.js +1 -3
  62. package/v2Containers/Rcs/index.js +37 -12
  63. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +697 -12
  64. package/v2Containers/Sms/Create/index.js +3 -39
  65. package/v2Containers/Sms/Create/messages.js +0 -4
  66. package/v2Containers/Sms/Edit/index.js +3 -35
  67. package/v2Containers/Sms/commonMethods.js +6 -3
  68. package/v2Containers/SmsTrai/Edit/index.js +52 -12
  69. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +207 -6
  70. package/v2Containers/SmsWrapper/index.js +0 -2
  71. package/v2Containers/Viber/index.js +1 -0
  72. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
  73. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
  74. package/v2Containers/WebPush/Create/index.js +2 -2
  75. package/v2Containers/WebPush/Create/utils/validation.js +2 -17
  76. package/v2Containers/WebPush/Create/utils/validation.test.js +24 -59
  77. package/v2Containers/Whatsapp/index.js +18 -10
  78. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26242 -4225
  79. package/v2Containers/Zalo/index.js +11 -3
  80. package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
@@ -22,17 +22,13 @@ describe("validateLiquidTemplateContent", () => {
22
22
  somethingWentWrong: { id: "wrong" },
23
23
  unsupportedTagsValidationError: { id: "unsupported" }
24
24
  };
25
+ const tagLookupMap = { foo: true };
25
26
  const eventContextTags = [{ tagName: "bar" }];
26
27
  const onError = jest.fn();
27
28
  const onSuccess = jest.fn();
28
29
 
29
30
  beforeEach(() => {
30
31
  jest.clearAllMocks();
31
- formatMessage.mockImplementation((msg, vars) =>
32
- vars && vars.unsupportedTags != null
33
- ? `${msg?.id}:${vars.unsupportedTags}`
34
- : (msg?.id ?? "unsupported")
35
- );
36
32
  });
37
33
 
38
34
  it("calls onError for empty content", async () => {
@@ -45,10 +41,11 @@ describe("validateLiquidTemplateContent", () => {
45
41
  messages,
46
42
  onError,
47
43
  onSuccess,
44
+ tagLookupMap,
48
45
  eventContextTags
49
46
  });
50
47
  expect(onError).toHaveBeenCalledWith({
51
- standardErrors: ["empty"],
48
+ standardErrors: [undefined],
52
49
  liquidErrors: [],
53
50
  tabType: undefined
54
51
  });
@@ -63,6 +60,7 @@ describe("validateLiquidTemplateContent", () => {
63
60
  getLiquidTags,
64
61
  formatMessage,
65
62
  messages,
63
+ tagLookupMap,
66
64
  eventContextTags
67
65
  });
68
66
  expect(onError).not.toHaveBeenCalled();
@@ -79,6 +77,7 @@ describe("validateLiquidTemplateContent", () => {
79
77
  messages,
80
78
  onError,
81
79
  onSuccess,
80
+ tagLookupMap,
82
81
  eventContextTags
83
82
  });
84
83
  expect(onError).toHaveBeenCalledWith({
@@ -102,6 +101,7 @@ describe("validateLiquidTemplateContent", () => {
102
101
  messages,
103
102
  onError,
104
103
  onSuccess,
104
+ tagLookupMap,
105
105
  eventContextTags
106
106
  });
107
107
  expect(onError).toHaveBeenCalledWith({
@@ -124,6 +124,7 @@ describe("validateLiquidTemplateContent", () => {
124
124
  messages,
125
125
  onError,
126
126
  onSuccess,
127
+ tagLookupMap,
127
128
  eventContextTags
128
129
  });
129
130
  expect(onError).toHaveBeenCalledWith({
@@ -144,6 +145,7 @@ describe("validateLiquidTemplateContent", () => {
144
145
  messages,
145
146
  onError,
146
147
  onSuccess,
148
+ tagLookupMap,
147
149
  eventContextTags
148
150
  });
149
151
  expect(onError).toHaveBeenCalledWith({
@@ -164,6 +166,7 @@ describe("validateLiquidTemplateContent", () => {
164
166
  messages,
165
167
  onError,
166
168
  onSuccess,
169
+ tagLookupMap,
167
170
  eventContextTags
168
171
  });
169
172
  expect(onError).toHaveBeenCalledWith({
@@ -194,6 +197,7 @@ describe("validateLiquidTemplateContent", () => {
194
197
  messages,
195
198
  onError,
196
199
  onSuccess,
200
+ tagLookupMap,
197
201
  eventContextTags
198
202
  });
199
203
  expect(onError).toHaveBeenCalledWith({
@@ -214,6 +218,7 @@ describe("validateLiquidTemplateContent", () => {
214
218
  messages,
215
219
  onError,
216
220
  onSuccess,
221
+ tagLookupMap,
217
222
  eventContextTags
218
223
  });
219
224
  expect(onError).toHaveBeenCalledWith({
@@ -223,15 +228,9 @@ describe("validateLiquidTemplateContent", () => {
223
228
  });
224
229
  });
225
230
 
226
- it("calls onError when API returns success but response.errors has validation errors (e.g. unsupported tag)", async () => {
231
+ it("calls onError for unsupported tags", async () => {
227
232
  const getLiquidTags = jest.fn((content, cb) =>
228
- cb({
229
- askAiraResponse: {
230
- errors: [{ message: "Unsupported tag: custom_tag" }],
231
- data: []
232
- },
233
- isError: false
234
- })
233
+ cb({ askAiraResponse: { errors: [], data: [{ name: "baz" }] }, isError: false })
235
234
  );
236
235
  await validateLiquidTemplateContent("foo", {
237
236
  getLiquidTags,
@@ -239,33 +238,18 @@ describe("validateLiquidTemplateContent", () => {
239
238
  messages,
240
239
  onError,
241
240
  onSuccess,
241
+ tagLookupMap,
242
242
  eventContextTags
243
243
  });
244
244
  expect(onError).toHaveBeenCalledWith({
245
245
  standardErrors: [],
246
- liquidErrors: ["Unsupported tag: custom_tag"],
246
+ liquidErrors: [undefined],
247
247
  tabType: undefined
248
248
  });
249
249
  expect(onSuccess).not.toHaveBeenCalled();
250
250
  });
251
251
 
252
- it("calls onSuccess when API returns no errors and a single extracted tag (extracted tags are not validated)", async () => {
253
- const getLiquidTags = jest.fn((content, cb) =>
254
- cb({ askAiraResponse: { errors: [], data: [{ name: "foo" }] }, isError: false })
255
- );
256
- await validateLiquidTemplateContent("foo", {
257
- getLiquidTags,
258
- formatMessage,
259
- messages,
260
- onError,
261
- onSuccess,
262
- eventContextTags
263
- });
264
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
265
- expect(onError).not.toHaveBeenCalled();
266
- });
267
-
268
- it("calls onSuccess for valid content when API returns multiple extracted tags but no errors", async () => {
252
+ it("calls onSuccess for valid content", async () => {
269
253
  const getLiquidTags = jest.fn((content, cb) =>
270
254
  cb({ askAiraResponse: { errors: [], data: [{ name: "foo" }, { name: "bar" }] }, isError: false })
271
255
  );
@@ -275,6 +259,7 @@ describe("validateLiquidTemplateContent", () => {
275
259
  messages,
276
260
  onError,
277
261
  onSuccess,
262
+ tagLookupMap,
278
263
  eventContextTags
279
264
  });
280
265
  expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
@@ -290,6 +275,7 @@ describe("validateLiquidTemplateContent", () => {
290
275
  messages,
291
276
  onError,
292
277
  onSuccess,
278
+ tagLookupMap,
293
279
  eventContextTags,
294
280
  skipTags
295
281
  });
@@ -307,6 +293,7 @@ describe("validateLiquidTemplateContent", () => {
307
293
  messages,
308
294
  onError,
309
295
  onSuccess,
296
+ tagLookupMap,
310
297
  eventContextTags,
311
298
  skipTags
312
299
  });
@@ -324,6 +311,7 @@ describe("validateLiquidTemplateContent", () => {
324
311
  messages,
325
312
  onError,
326
313
  onSuccess,
314
+ tagLookupMap,
327
315
  eventContextTags,
328
316
  skipTags
329
317
  });
@@ -341,6 +329,7 @@ describe("validateLiquidTemplateContent", () => {
341
329
  messages,
342
330
  onError,
343
331
  onSuccess,
332
+ tagLookupMap,
344
333
  eventContextTags,
345
334
  skipTags
346
335
  });
@@ -358,6 +347,7 @@ describe("validateLiquidTemplateContent", () => {
358
347
  messages,
359
348
  onError,
360
349
  onSuccess,
350
+ tagLookupMap,
361
351
  eventContextTags,
362
352
  skipTags
363
353
  });
@@ -375,6 +365,7 @@ describe("validateLiquidTemplateContent", () => {
375
365
  messages,
376
366
  onError,
377
367
  onSuccess,
368
+ tagLookupMap,
378
369
  eventContextTags,
379
370
  skipTags
380
371
  });
@@ -392,6 +383,7 @@ describe("validateLiquidTemplateContent", () => {
392
383
  messages,
393
384
  onError,
394
385
  onSuccess,
386
+ tagLookupMap,
395
387
  eventContextTags,
396
388
  skipTags
397
389
  });
@@ -409,6 +401,7 @@ describe("validateLiquidTemplateContent", () => {
409
401
  messages,
410
402
  onError,
411
403
  onSuccess,
404
+ tagLookupMap,
412
405
  eventContextTags,
413
406
  skipTags
414
407
  });
@@ -426,6 +419,7 @@ describe("validateLiquidTemplateContent", () => {
426
419
  };
427
420
  const onError = jest.fn();
428
421
  const onSuccess = jest.fn();
422
+ const tagLookupMap = {};
429
423
  const eventContextTags = [];
430
424
  await validateLiquidTemplateContent('', {
431
425
  getLiquidTags,
@@ -433,6 +427,7 @@ describe("validateLiquidTemplateContent", () => {
433
427
  messages,
434
428
  onError,
435
429
  onSuccess,
430
+ tagLookupMap,
436
431
  eventContextTags,
437
432
  });
438
433
  expect(formatMessage).toHaveBeenCalledWith(messages.emailBodyEmptyError);
@@ -444,7 +439,7 @@ describe("validateLiquidTemplateContent", () => {
444
439
  expect(onSuccess).not.toHaveBeenCalled();
445
440
  });
446
441
 
447
- it("calls onSuccess when API returns extracted tags from {% for %} template but no errors (extracted tags are not validated)", async () => {
442
+ it("should skip tags that appear in {% %} syntax (like order.items in for loop)", async () => {
448
443
  const content = '{% for item in order.items %} Hello {% endfor %}';
449
444
  const getLiquidTags = jest.fn((content, cb) =>
450
445
  cb({ askAiraResponse: { errors: [], data: [{ name: "order.items" }] }, isError: false })
@@ -455,13 +450,15 @@ describe("validateLiquidTemplateContent", () => {
455
450
  messages,
456
451
  onError,
457
452
  onSuccess,
453
+ tagLookupMap,
458
454
  eventContextTags
459
455
  });
456
+ // order.items appears in {% %} syntax, so it should be skipped and validation should pass
460
457
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
461
458
  expect(onError).not.toHaveBeenCalled();
462
459
  });
463
460
 
464
- it("calls onSuccess when API returns extracted tags in {% %} blocks but no errors", async () => {
461
+ it("should skip tags that appear only inside {% %} blocks (like item.name in for loop)", async () => {
465
462
  const content = '{% for item in order.items %} {{ item.name }} - {{ item.quantity }} {% endfor %}';
466
463
  const getLiquidTags = jest.fn((content, cb) =>
467
464
  cb({ askAiraResponse: { errors: [], data: [{ name: "item.name" }, { name: "item.quantity" }] }, isError: false })
@@ -472,13 +469,15 @@ describe("validateLiquidTemplateContent", () => {
472
469
  messages,
473
470
  onError,
474
471
  onSuccess,
472
+ tagLookupMap,
475
473
  eventContextTags
476
474
  });
475
+ // item.name and item.quantity appear inside {% for %} block, so they should be skipped
477
476
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
478
477
  expect(onError).not.toHaveBeenCalled();
479
478
  });
480
479
 
481
- it("calls onSuccess when API returns extracted tags not in content but no errors", async () => {
480
+ it("should validate tags that don't appear in content but are extracted by API", async () => {
482
481
  const content = 'Some content without the tag';
483
482
  const getLiquidTags = jest.fn((content, cb) =>
484
483
  cb({ askAiraResponse: { errors: [], data: [{ name: "extractedTag" }] }, isError: false })
@@ -489,13 +488,19 @@ describe("validateLiquidTemplateContent", () => {
489
488
  messages,
490
489
  onError,
491
490
  onSuccess,
491
+ tagLookupMap,
492
492
  eventContextTags
493
493
  });
494
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
495
- expect(onError).not.toHaveBeenCalled();
494
+ // extractedTag doesn't appear in content but was extracted by API, should be validated
495
+ expect(onError).toHaveBeenCalledWith({
496
+ standardErrors: [],
497
+ liquidErrors: [undefined],
498
+ tabType: undefined
499
+ });
500
+ expect(onSuccess).not.toHaveBeenCalled();
496
501
  });
497
502
 
498
- it("calls onSuccess when API returns tags outside {% %} but no errors", async () => {
503
+ it("should validate tags that appear outside {% %} blocks", async () => {
499
504
  const content = '{{ outsideTag }} {% for item in order.items %} {{ item.name }} {% endfor %}';
500
505
  const getLiquidTags = jest.fn((content, cb) =>
501
506
  cb({ askAiraResponse: { errors: [], data: [{ name: "outsideTag" }, { name: "item.name" }] }, isError: false })
@@ -506,70 +511,20 @@ describe("validateLiquidTemplateContent", () => {
506
511
  messages,
507
512
  onError,
508
513
  onSuccess,
514
+ tagLookupMap,
509
515
  eventContextTags
510
516
  });
511
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
512
- expect(onError).not.toHaveBeenCalled();
513
- });
514
-
515
- it("calls onSuccess when API returns tag in {{ }} and no errors", async () => {
516
- const content = 'Hello {{ unsupportedTag }} world';
517
- const getLiquidTags = jest.fn((content, cb) =>
518
- cb({ askAiraResponse: { errors: [], data: [{ name: "unsupportedTag" }] }, isError: false })
519
- );
520
- await validateLiquidTemplateContent(content, {
521
- getLiquidTags,
522
- formatMessage,
523
- messages,
524
- onError,
525
- onSuccess,
526
- eventContextTags
527
- });
528
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
529
- expect(onError).not.toHaveBeenCalled();
530
- });
531
-
532
- it("calls onSuccess when API returns tag with spacing variants and no errors", async () => {
533
- const content = '{{ tag}} and {{tag }} and {{ tag }}';
534
- const getLiquidTags = jest.fn((content, cb) =>
535
- cb({
536
- askAiraResponse: {
537
- errors: [],
538
- data: [{ name: "tag" }]
539
- },
540
- isError: false
541
- })
542
- );
543
- await validateLiquidTemplateContent(content, {
544
- getLiquidTags,
545
- formatMessage,
546
- messages,
547
- onError,
548
- onSuccess,
549
- eventContextTags
550
- });
551
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
552
- expect(onError).not.toHaveBeenCalled();
553
- });
554
-
555
- it("calls onSuccess when API returns tag inside {% %} blocks but no errors", async () => {
556
- const content = '{% for x in some.unsupported %} {{ x }} {% endfor %}';
557
- const getLiquidTags = jest.fn((content, cb) =>
558
- cb({ askAiraResponse: { errors: [], data: [{ name: "some.unsupported" }] }, isError: false })
559
- );
560
- await validateLiquidTemplateContent(content, {
561
- getLiquidTags,
562
- formatMessage,
563
- messages,
564
- onError,
565
- onSuccess,
566
- eventContextTags
517
+ // outsideTag appears outside {% %} block, so it should be validated
518
+ // item.name appears inside block, so it should be skipped
519
+ expect(onError).toHaveBeenCalledWith({
520
+ standardErrors: [],
521
+ liquidErrors: [undefined],
522
+ tabType: undefined
567
523
  });
568
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
569
- expect(onError).not.toHaveBeenCalled();
524
+ expect(onSuccess).not.toHaveBeenCalled();
570
525
  });
571
526
 
572
- it("calls onSuccess when API returns tags with dots in {% %} syntax but no errors", async () => {
527
+ it("should skip tags with dots that appear in {% %} syntax", async () => {
573
528
  const content = '{% assign myVar = order.items %} Some text';
574
529
  const getLiquidTags = jest.fn((content, cb) =>
575
530
  cb({ askAiraResponse: { errors: [], data: [{ name: "order.items" }] }, isError: false })
@@ -580,8 +535,10 @@ describe("validateLiquidTemplateContent", () => {
580
535
  messages,
581
536
  onError,
582
537
  onSuccess,
538
+ tagLookupMap,
583
539
  eventContextTags
584
540
  });
541
+ // order.items appears in {% %} syntax, so it should be skipped
585
542
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
586
543
  expect(onError).not.toHaveBeenCalled();
587
544
  });
@@ -636,6 +593,7 @@ describe("validateMobilePushContent", () => {
636
593
  somethingWentWrong: { id: "wrong" },
637
594
  unsupportedTagsValidationError: { id: "unsupported" }
638
595
  };
596
+ const tagLookupMap = { foo: true };
639
597
  const eventContextTags = [{ tagName: "foo" }];
640
598
  const onError = jest.fn();
641
599
  const onSuccess = jest.fn();
@@ -644,7 +602,7 @@ describe("validateMobilePushContent", () => {
644
602
  jest.clearAllMocks();
645
603
  });
646
604
 
647
- it("calls onError for empty formData (validateMobilePushContent)", async () => {
605
+ it("calls onError for empty formData", async () => {
648
606
  const getLiquidTags = jest.fn((content, cb) =>
649
607
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
650
608
  );
@@ -653,17 +611,18 @@ describe("validateMobilePushContent", () => {
653
611
  {
654
612
  getLiquidTags,
655
613
  formatMessage,
656
- messages,
657
- onError,
658
- onSuccess,
659
- eventContextTags,
614
+ messages,
615
+ onError,
616
+ onSuccess,
617
+ tagLookupMap,
618
+ eventContextTags,
660
619
  currentTab: 1
661
620
  }
662
621
  );
663
622
  expect(onError).toHaveBeenCalled();
664
623
  });
665
624
 
666
- it("calls onSuccess for valid android and ios content (validateMobilePushContent)", async () => {
625
+ it("calls onSuccess for valid android and ios content", async () => {
667
626
  const getLiquidTags = jest.fn((content, cb) =>
668
627
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
669
628
  );
@@ -674,6 +633,7 @@ describe("validateMobilePushContent", () => {
674
633
  messages,
675
634
  onError,
676
635
  onSuccess,
636
+ tagLookupMap,
677
637
  eventContextTags,
678
638
  currentTab: 1
679
639
  });
@@ -691,6 +651,7 @@ describe("validateMobilePushContent", () => {
691
651
  messages,
692
652
  onError,
693
653
  onSuccess,
654
+ tagLookupMap,
694
655
  eventContextTags,
695
656
  currentTab: 1
696
657
  });
@@ -708,6 +669,7 @@ describe("validateMobilePushContent", () => {
708
669
  messages,
709
670
  onError,
710
671
  onSuccess,
672
+ tagLookupMap,
711
673
  eventContextTags,
712
674
  currentTab: 2
713
675
  });
@@ -725,6 +687,7 @@ describe("validateMobilePushContent", () => {
725
687
  messages,
726
688
  onError,
727
689
  onSuccess,
690
+ tagLookupMap,
728
691
  eventContextTags
729
692
  });
730
693
  expect(onSuccess).toHaveBeenCalledWith(JSON.stringify(formData[0]), "android");
@@ -741,6 +704,7 @@ describe("validateMobilePushContent", () => {
741
704
  messages,
742
705
  onError,
743
706
  onSuccess,
707
+ tagLookupMap,
744
708
  eventContextTags
745
709
  });
746
710
  expect(onSuccess).toHaveBeenCalledWith("null", "android");
@@ -753,10 +717,11 @@ describe("validateMobilePushContent", () => {
753
717
  {
754
718
  getLiquidTags,
755
719
  formatMessage,
756
- messages,
757
- onError,
758
- onSuccess,
759
- eventContextTags,
720
+ messages,
721
+ onError,
722
+ onSuccess,
723
+ tagLookupMap,
724
+ eventContextTags,
760
725
  currentTab: 1,
761
726
  },
762
727
  );
@@ -770,10 +735,11 @@ describe("validateMobilePushContent", () => {
770
735
  {
771
736
  getLiquidTags,
772
737
  formatMessage,
773
- messages,
774
- onError,
775
- onSuccess,
776
- eventContextTags,
738
+ messages,
739
+ onError,
740
+ onSuccess,
741
+ tagLookupMap,
742
+ eventContextTags,
777
743
  currentTab: 1,
778
744
  },
779
745
  );
@@ -787,10 +753,11 @@ describe("validateMobilePushContent", () => {
787
753
  {
788
754
  getLiquidTags,
789
755
  formatMessage,
790
- messages,
791
- onError,
792
- onSuccess,
793
- eventContextTags,
756
+ messages,
757
+ onError,
758
+ onSuccess,
759
+ tagLookupMap,
760
+ eventContextTags,
794
761
  currentTab: 1,
795
762
  },
796
763
  );
@@ -804,10 +771,11 @@ describe("validateMobilePushContent", () => {
804
771
  {
805
772
  getLiquidTags,
806
773
  formatMessage,
807
- messages,
808
- onError,
809
- onSuccess,
810
- eventContextTags,
774
+ messages,
775
+ onError,
776
+ onSuccess,
777
+ tagLookupMap,
778
+ eventContextTags,
811
779
  currentTab: 1,
812
780
  },
813
781
  );
@@ -821,10 +789,11 @@ describe("validateMobilePushContent", () => {
821
789
  {
822
790
  getLiquidTags,
823
791
  formatMessage,
824
- messages,
825
- onError,
826
- onSuccess,
827
- eventContextTags,
792
+ messages,
793
+ onError,
794
+ onSuccess,
795
+ tagLookupMap,
796
+ eventContextTags,
828
797
  },
829
798
  );
830
799
  expect(onError).toHaveBeenCalled();
@@ -837,10 +806,11 @@ describe("validateMobilePushContent", () => {
837
806
  {
838
807
  getLiquidTags,
839
808
  formatMessage,
840
- messages,
841
- onError,
842
- onSuccess,
843
- eventContextTags,
809
+ messages,
810
+ onError,
811
+ onSuccess,
812
+ tagLookupMap,
813
+ eventContextTags,
844
814
  },
845
815
  );
846
816
  expect(onError).toHaveBeenCalled();
@@ -853,10 +823,11 @@ describe("validateMobilePushContent", () => {
853
823
  {
854
824
  getLiquidTags,
855
825
  formatMessage,
856
- messages,
857
- onError,
858
- onSuccess,
859
- eventContextTags,
826
+ messages,
827
+ onError,
828
+ onSuccess,
829
+ tagLookupMap,
830
+ eventContextTags,
860
831
  },
861
832
  );
862
833
  expect(onError).toHaveBeenCalled();
@@ -869,10 +840,11 @@ describe("validateMobilePushContent", () => {
869
840
  {
870
841
  getLiquidTags,
871
842
  formatMessage,
872
- messages,
873
- onError,
874
- onSuccess,
875
- eventContextTags,
843
+ messages,
844
+ onError,
845
+ onSuccess,
846
+ tagLookupMap,
847
+ eventContextTags,
876
848
  },
877
849
  );
878
850
  expect(onError).toHaveBeenCalled();
@@ -885,10 +857,11 @@ describe("validateMobilePushContent", () => {
885
857
  {
886
858
  getLiquidTags,
887
859
  formatMessage,
888
- messages,
889
- onError,
890
- onSuccess,
891
- eventContextTags,
860
+ messages,
861
+ onError,
862
+ onSuccess,
863
+ tagLookupMap,
864
+ eventContextTags,
892
865
  },
893
866
  );
894
867
  expect(onError).toHaveBeenCalled();
@@ -902,6 +875,7 @@ describe("validateInAppContent", () => {
902
875
  somethingWentWrong: { id: "wrong" },
903
876
  unsupportedTagsValidationError: { id: "unsupported" }
904
877
  };
878
+ const tagLookupMap = { foo: true };
905
879
  const eventContextTags = [{ tagName: "foo" }];
906
880
  const onError = jest.fn();
907
881
  const onSuccess = jest.fn();
@@ -910,7 +884,7 @@ describe("validateInAppContent", () => {
910
884
  jest.clearAllMocks();
911
885
  });
912
886
 
913
- it("calls onError for empty formData (validateInAppContent)", async () => {
887
+ it("calls onError for empty formData", async () => {
914
888
  const getLiquidTags = jest.fn((content, cb) =>
915
889
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
916
890
  );
@@ -919,16 +893,17 @@ describe("validateInAppContent", () => {
919
893
  {
920
894
  getLiquidTags,
921
895
  formatMessage,
922
- messages,
923
- onError,
924
- onSuccess,
925
- eventContextTags,
896
+ messages,
897
+ onError,
898
+ onSuccess,
899
+ tagLookupMap,
900
+ eventContextTags,
926
901
  }
927
902
  );
928
903
  expect(onError).toHaveBeenCalled();
929
904
  });
930
905
 
931
- it("calls onSuccess for valid android and ios content (validateInAppContent)", async () => {
906
+ it("calls onSuccess for valid android and ios content", async () => {
932
907
  const getLiquidTags = jest.fn((content, cb) =>
933
908
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
934
909
  );
@@ -948,6 +923,7 @@ describe("validateInAppContent", () => {
948
923
  messages,
949
924
  onError,
950
925
  onSuccess,
926
+ tagLookupMap,
951
927
  eventContextTags,
952
928
  singleTab: ANDROID,
953
929
  });
@@ -974,6 +950,7 @@ describe("validateInAppContent", () => {
974
950
  messages,
975
951
  onError,
976
952
  onSuccess,
953
+ tagLookupMap,
977
954
  eventContextTags,
978
955
  singleTab: IOS,
979
956
  });
@@ -1000,11 +977,11 @@ describe("getChannelData", () => {
1000
977
  expect(getChannelData("SMS", formData)).toBe("Hi Test");
1001
978
  });
1002
979
 
1003
- it("returns string with undefineds for SMS when base and template-name are empty or undefined", () => {
980
+ it("returns string with undefineds for SMS channel with missing fields", () => {
1004
981
  const formData = { base: {}, "template-name": undefined };
1005
982
  expect(getChannelData("SMS", formData)).toBe("undefined undefined");
1006
983
  });
1007
- it("returns string with undefineds for SMS when formData is empty string", () => {
984
+ it("returns string with undefineds for SMS channel with missing fields", () => {
1008
985
  expect(getChannelData("SMS", "")).toBe("undefined undefined");
1009
986
  });
1010
987