@capillarytech/creatives-library 8.0.307-alpha.0 → 8.0.308

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 (54) 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 +93 -36
  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/ErrorInfoNote/index.js +5 -2
  10. package/v2Components/FormBuilder/index.js +203 -137
  11. package/v2Components/FormBuilder/messages.js +8 -0
  12. package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
  13. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
  14. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
  15. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
  16. package/v2Containers/Cap/mockData.js +14 -0
  17. package/v2Containers/Cap/reducer.js +55 -3
  18. package/v2Containers/Cap/tests/reducer.test.js +102 -0
  19. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
  20. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
  21. package/v2Containers/CreativesContainer/constants.js +0 -6
  22. package/v2Containers/CreativesContainer/index.js +7 -47
  23. package/v2Containers/Email/index.js +5 -1
  24. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
  25. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +120 -20
  26. package/v2Containers/FTP/index.js +51 -2
  27. package/v2Containers/FTP/messages.js +4 -0
  28. package/v2Containers/InApp/index.js +122 -35
  29. package/v2Containers/InApp/tests/index.test.js +6 -17
  30. package/v2Containers/InappAdvance/index.js +112 -4
  31. package/v2Containers/InappAdvance/tests/index.test.js +0 -2
  32. package/v2Containers/Line/Container/Text/index.js +1 -0
  33. package/v2Containers/MobilePush/Create/index.js +19 -59
  34. package/v2Containers/MobilePush/Edit/index.js +20 -48
  35. package/v2Containers/MobilePushNew/index.js +32 -12
  36. package/v2Containers/MobilepushWrapper/index.js +1 -3
  37. package/v2Containers/Rcs/index.js +37 -12
  38. package/v2Containers/Sms/Create/index.js +3 -39
  39. package/v2Containers/Sms/Create/messages.js +0 -4
  40. package/v2Containers/Sms/Edit/index.js +3 -35
  41. package/v2Containers/Sms/commonMethods.js +6 -3
  42. package/v2Containers/SmsTrai/Edit/index.js +47 -11
  43. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +6 -6
  44. package/v2Containers/SmsWrapper/index.js +0 -2
  45. package/v2Containers/TemplatesV2/index.js +13 -28
  46. package/v2Containers/Viber/index.js +1 -0
  47. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
  48. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
  49. package/v2Containers/WebPush/Create/index.js +2 -2
  50. package/v2Containers/WebPush/Create/utils/validation.js +8 -17
  51. package/v2Containers/WebPush/Create/utils/validation.test.js +24 -44
  52. package/v2Containers/Whatsapp/index.js +17 -9
  53. package/v2Containers/Zalo/index.js +11 -3
  54. package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
@@ -27,17 +27,13 @@ describe("validateLiquidTemplateContent", () => {
27
27
  somethingWentWrong: { id: "wrong" },
28
28
  unsupportedTagsValidationError: { id: "unsupported" }
29
29
  };
30
+ const tagLookupMap = { foo: true };
30
31
  const eventContextTags = [{ tagName: "bar" }];
31
32
  const onError = jest.fn();
32
33
  const onSuccess = jest.fn();
33
34
 
34
35
  beforeEach(() => {
35
36
  jest.clearAllMocks();
36
- formatMessage.mockImplementation((msg, vars) =>
37
- vars && vars.unsupportedTags != null
38
- ? `${msg?.id}:${vars.unsupportedTags}`
39
- : (msg?.id ?? "unsupported")
40
- );
41
37
  });
42
38
 
43
39
  it("calls onError for empty content", async () => {
@@ -50,10 +46,11 @@ describe("validateLiquidTemplateContent", () => {
50
46
  messages,
51
47
  onError,
52
48
  onSuccess,
49
+ tagLookupMap,
53
50
  eventContextTags
54
51
  });
55
52
  expect(onError).toHaveBeenCalledWith({
56
- standardErrors: ["empty"],
53
+ standardErrors: [undefined],
57
54
  liquidErrors: [],
58
55
  tabType: undefined
59
56
  });
@@ -68,6 +65,7 @@ describe("validateLiquidTemplateContent", () => {
68
65
  getLiquidTags,
69
66
  formatMessage,
70
67
  messages,
68
+ tagLookupMap,
71
69
  eventContextTags
72
70
  });
73
71
  expect(onError).not.toHaveBeenCalled();
@@ -84,6 +82,7 @@ describe("validateLiquidTemplateContent", () => {
84
82
  messages,
85
83
  onError,
86
84
  onSuccess,
85
+ tagLookupMap,
87
86
  eventContextTags
88
87
  });
89
88
  expect(onError).toHaveBeenCalledWith({
@@ -107,6 +106,7 @@ describe("validateLiquidTemplateContent", () => {
107
106
  messages,
108
107
  onError,
109
108
  onSuccess,
109
+ tagLookupMap,
110
110
  eventContextTags
111
111
  });
112
112
  expect(onError).toHaveBeenCalledWith({
@@ -129,6 +129,7 @@ describe("validateLiquidTemplateContent", () => {
129
129
  messages,
130
130
  onError,
131
131
  onSuccess,
132
+ tagLookupMap,
132
133
  eventContextTags
133
134
  });
134
135
  expect(onError).toHaveBeenCalledWith({
@@ -149,6 +150,7 @@ describe("validateLiquidTemplateContent", () => {
149
150
  messages,
150
151
  onError,
151
152
  onSuccess,
153
+ tagLookupMap,
152
154
  eventContextTags
153
155
  });
154
156
  expect(onError).toHaveBeenCalledWith({
@@ -169,6 +171,7 @@ describe("validateLiquidTemplateContent", () => {
169
171
  messages,
170
172
  onError,
171
173
  onSuccess,
174
+ tagLookupMap,
172
175
  eventContextTags
173
176
  });
174
177
  expect(onError).toHaveBeenCalledWith({
@@ -199,6 +202,7 @@ describe("validateLiquidTemplateContent", () => {
199
202
  messages,
200
203
  onError,
201
204
  onSuccess,
205
+ tagLookupMap,
202
206
  eventContextTags
203
207
  });
204
208
  expect(onError).toHaveBeenCalledWith({
@@ -219,6 +223,7 @@ describe("validateLiquidTemplateContent", () => {
219
223
  messages,
220
224
  onError,
221
225
  onSuccess,
226
+ tagLookupMap,
222
227
  eventContextTags
223
228
  });
224
229
  expect(onError).toHaveBeenCalledWith({
@@ -228,15 +233,9 @@ describe("validateLiquidTemplateContent", () => {
228
233
  });
229
234
  });
230
235
 
231
- it("calls onError when API returns success but response.errors has validation errors (e.g. unsupported tag)", async () => {
236
+ it("calls onError for unsupported tags", async () => {
232
237
  const getLiquidTags = jest.fn((content, cb) =>
233
- cb({
234
- askAiraResponse: {
235
- errors: [{ message: "Unsupported tag: custom_tag" }],
236
- data: []
237
- },
238
- isError: false
239
- })
238
+ cb({ askAiraResponse: { errors: [], data: [{ name: "baz" }] }, isError: false })
240
239
  );
241
240
  await validateLiquidTemplateContent("foo", {
242
241
  getLiquidTags,
@@ -244,33 +243,18 @@ describe("validateLiquidTemplateContent", () => {
244
243
  messages,
245
244
  onError,
246
245
  onSuccess,
246
+ tagLookupMap,
247
247
  eventContextTags
248
248
  });
249
249
  expect(onError).toHaveBeenCalledWith({
250
250
  standardErrors: [],
251
- liquidErrors: ["Unsupported tag: custom_tag"],
251
+ liquidErrors: [undefined],
252
252
  tabType: undefined
253
253
  });
254
254
  expect(onSuccess).not.toHaveBeenCalled();
255
255
  });
256
256
 
257
- it("calls onSuccess when API returns no errors and a single extracted tag (extracted tags are not validated)", async () => {
258
- const getLiquidTags = jest.fn((content, cb) =>
259
- cb({ askAiraResponse: { errors: [], data: [{ name: "foo" }] }, isError: false })
260
- );
261
- await validateLiquidTemplateContent("foo", {
262
- getLiquidTags,
263
- formatMessage,
264
- messages,
265
- onError,
266
- onSuccess,
267
- eventContextTags
268
- });
269
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
270
- expect(onError).not.toHaveBeenCalled();
271
- });
272
-
273
- it("calls onSuccess for valid content when API returns multiple extracted tags but no errors", async () => {
257
+ it("calls onSuccess for valid content", async () => {
274
258
  const getLiquidTags = jest.fn((content, cb) =>
275
259
  cb({ askAiraResponse: { errors: [], data: [{ name: "foo" }, { name: "bar" }] }, isError: false })
276
260
  );
@@ -280,6 +264,7 @@ describe("validateLiquidTemplateContent", () => {
280
264
  messages,
281
265
  onError,
282
266
  onSuccess,
267
+ tagLookupMap,
283
268
  eventContextTags
284
269
  });
285
270
  expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
@@ -295,6 +280,7 @@ describe("validateLiquidTemplateContent", () => {
295
280
  messages,
296
281
  onError,
297
282
  onSuccess,
283
+ tagLookupMap,
298
284
  eventContextTags,
299
285
  skipTags
300
286
  });
@@ -312,6 +298,7 @@ describe("validateLiquidTemplateContent", () => {
312
298
  messages,
313
299
  onError,
314
300
  onSuccess,
301
+ tagLookupMap,
315
302
  eventContextTags,
316
303
  skipTags
317
304
  });
@@ -329,6 +316,7 @@ describe("validateLiquidTemplateContent", () => {
329
316
  messages,
330
317
  onError,
331
318
  onSuccess,
319
+ tagLookupMap,
332
320
  eventContextTags,
333
321
  skipTags
334
322
  });
@@ -346,6 +334,7 @@ describe("validateLiquidTemplateContent", () => {
346
334
  messages,
347
335
  onError,
348
336
  onSuccess,
337
+ tagLookupMap,
349
338
  eventContextTags,
350
339
  skipTags
351
340
  });
@@ -363,6 +352,7 @@ describe("validateLiquidTemplateContent", () => {
363
352
  messages,
364
353
  onError,
365
354
  onSuccess,
355
+ tagLookupMap,
366
356
  eventContextTags,
367
357
  skipTags
368
358
  });
@@ -380,6 +370,7 @@ describe("validateLiquidTemplateContent", () => {
380
370
  messages,
381
371
  onError,
382
372
  onSuccess,
373
+ tagLookupMap,
383
374
  eventContextTags,
384
375
  skipTags
385
376
  });
@@ -397,6 +388,7 @@ describe("validateLiquidTemplateContent", () => {
397
388
  messages,
398
389
  onError,
399
390
  onSuccess,
391
+ tagLookupMap,
400
392
  eventContextTags,
401
393
  skipTags
402
394
  });
@@ -414,6 +406,7 @@ describe("validateLiquidTemplateContent", () => {
414
406
  messages,
415
407
  onError,
416
408
  onSuccess,
409
+ tagLookupMap,
417
410
  eventContextTags,
418
411
  skipTags
419
412
  });
@@ -431,6 +424,7 @@ describe("validateLiquidTemplateContent", () => {
431
424
  };
432
425
  const onError = jest.fn();
433
426
  const onSuccess = jest.fn();
427
+ const tagLookupMap = {};
434
428
  const eventContextTags = [];
435
429
  await validateLiquidTemplateContent('', {
436
430
  getLiquidTags,
@@ -438,6 +432,7 @@ describe("validateLiquidTemplateContent", () => {
438
432
  messages,
439
433
  onError,
440
434
  onSuccess,
435
+ tagLookupMap,
441
436
  eventContextTags,
442
437
  });
443
438
  expect(formatMessage).toHaveBeenCalledWith(messages.emailBodyEmptyError);
@@ -449,7 +444,7 @@ describe("validateLiquidTemplateContent", () => {
449
444
  expect(onSuccess).not.toHaveBeenCalled();
450
445
  });
451
446
 
452
- it("calls onSuccess when API returns extracted tags from {% for %} template but no errors (extracted tags are not validated)", async () => {
447
+ it("should skip tags that appear in {% %} syntax (like order.items in for loop)", async () => {
453
448
  const content = '{% for item in order.items %} Hello {% endfor %}';
454
449
  const getLiquidTags = jest.fn((content, cb) =>
455
450
  cb({ askAiraResponse: { errors: [], data: [{ name: "order.items" }] }, isError: false })
@@ -460,13 +455,15 @@ describe("validateLiquidTemplateContent", () => {
460
455
  messages,
461
456
  onError,
462
457
  onSuccess,
458
+ tagLookupMap,
463
459
  eventContextTags
464
460
  });
461
+ // order.items appears in {% %} syntax, so it should be skipped and validation should pass
465
462
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
466
463
  expect(onError).not.toHaveBeenCalled();
467
464
  });
468
465
 
469
- it("calls onSuccess when API returns extracted tags in {% %} blocks but no errors", async () => {
466
+ it("should skip tags that appear only inside {% %} blocks (like item.name in for loop)", async () => {
470
467
  const content = '{% for item in order.items %} {{ item.name }} - {{ item.quantity }} {% endfor %}';
471
468
  const getLiquidTags = jest.fn((content, cb) =>
472
469
  cb({ askAiraResponse: { errors: [], data: [{ name: "item.name" }, { name: "item.quantity" }] }, isError: false })
@@ -477,13 +474,15 @@ describe("validateLiquidTemplateContent", () => {
477
474
  messages,
478
475
  onError,
479
476
  onSuccess,
477
+ tagLookupMap,
480
478
  eventContextTags
481
479
  });
480
+ // item.name and item.quantity appear inside {% for %} block, so they should be skipped
482
481
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
483
482
  expect(onError).not.toHaveBeenCalled();
484
483
  });
485
484
 
486
- it("calls onSuccess when API returns extracted tags not in content but no errors", async () => {
485
+ it("should validate tags that don't appear in content but are extracted by API", async () => {
487
486
  const content = 'Some content without the tag';
488
487
  const getLiquidTags = jest.fn((content, cb) =>
489
488
  cb({ askAiraResponse: { errors: [], data: [{ name: "extractedTag" }] }, isError: false })
@@ -494,13 +493,19 @@ describe("validateLiquidTemplateContent", () => {
494
493
  messages,
495
494
  onError,
496
495
  onSuccess,
496
+ tagLookupMap,
497
497
  eventContextTags
498
498
  });
499
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
500
- expect(onError).not.toHaveBeenCalled();
499
+ // extractedTag doesn't appear in content but was extracted by API, should be validated
500
+ expect(onError).toHaveBeenCalledWith({
501
+ standardErrors: [],
502
+ liquidErrors: [undefined],
503
+ tabType: undefined
504
+ });
505
+ expect(onSuccess).not.toHaveBeenCalled();
501
506
  });
502
507
 
503
- it("calls onSuccess when API returns tags outside {% %} but no errors", async () => {
508
+ it("should validate tags that appear outside {% %} blocks", async () => {
504
509
  const content = '{{ outsideTag }} {% for item in order.items %} {{ item.name }} {% endfor %}';
505
510
  const getLiquidTags = jest.fn((content, cb) =>
506
511
  cb({ askAiraResponse: { errors: [], data: [{ name: "outsideTag" }, { name: "item.name" }] }, isError: false })
@@ -511,70 +516,20 @@ describe("validateLiquidTemplateContent", () => {
511
516
  messages,
512
517
  onError,
513
518
  onSuccess,
519
+ tagLookupMap,
514
520
  eventContextTags
515
521
  });
516
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
517
- expect(onError).not.toHaveBeenCalled();
518
- });
519
-
520
- it("calls onSuccess when API returns tag in {{ }} and no errors", async () => {
521
- const content = 'Hello {{ unsupportedTag }} world';
522
- const getLiquidTags = jest.fn((content, cb) =>
523
- cb({ askAiraResponse: { errors: [], data: [{ name: "unsupportedTag" }] }, isError: false })
524
- );
525
- await validateLiquidTemplateContent(content, {
526
- getLiquidTags,
527
- formatMessage,
528
- messages,
529
- onError,
530
- onSuccess,
531
- eventContextTags
532
- });
533
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
534
- expect(onError).not.toHaveBeenCalled();
535
- });
536
-
537
- it("calls onSuccess when API returns tag with spacing variants and no errors", async () => {
538
- const content = '{{ tag}} and {{tag }} and {{ tag }}';
539
- const getLiquidTags = jest.fn((content, cb) =>
540
- cb({
541
- askAiraResponse: {
542
- errors: [],
543
- data: [{ name: "tag" }]
544
- },
545
- isError: false
546
- })
547
- );
548
- await validateLiquidTemplateContent(content, {
549
- getLiquidTags,
550
- formatMessage,
551
- messages,
552
- onError,
553
- onSuccess,
554
- eventContextTags
555
- });
556
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
557
- expect(onError).not.toHaveBeenCalled();
558
- });
559
-
560
- it("calls onSuccess when API returns tag inside {% %} blocks but no errors", async () => {
561
- const content = '{% for x in some.unsupported %} {{ x }} {% endfor %}';
562
- const getLiquidTags = jest.fn((content, cb) =>
563
- cb({ askAiraResponse: { errors: [], data: [{ name: "some.unsupported" }] }, isError: false })
564
- );
565
- await validateLiquidTemplateContent(content, {
566
- getLiquidTags,
567
- formatMessage,
568
- messages,
569
- onError,
570
- onSuccess,
571
- eventContextTags
522
+ // outsideTag appears outside {% %} block, so it should be validated
523
+ // item.name appears inside block, so it should be skipped
524
+ expect(onError).toHaveBeenCalledWith({
525
+ standardErrors: [],
526
+ liquidErrors: [undefined],
527
+ tabType: undefined
572
528
  });
573
- expect(onSuccess).toHaveBeenCalledWith(content, undefined);
574
- expect(onError).not.toHaveBeenCalled();
529
+ expect(onSuccess).not.toHaveBeenCalled();
575
530
  });
576
531
 
577
- it("calls onSuccess when API returns tags with dots in {% %} syntax but no errors", async () => {
532
+ it("should skip tags with dots that appear in {% %} syntax", async () => {
578
533
  const content = '{% assign myVar = order.items %} Some text';
579
534
  const getLiquidTags = jest.fn((content, cb) =>
580
535
  cb({ askAiraResponse: { errors: [], data: [{ name: "order.items" }] }, isError: false })
@@ -585,8 +540,10 @@ describe("validateLiquidTemplateContent", () => {
585
540
  messages,
586
541
  onError,
587
542
  onSuccess,
543
+ tagLookupMap,
588
544
  eventContextTags
589
545
  });
546
+ // order.items appears in {% %} syntax, so it should be skipped
590
547
  expect(onSuccess).toHaveBeenCalledWith(content, undefined);
591
548
  expect(onError).not.toHaveBeenCalled();
592
549
  });
@@ -805,6 +762,7 @@ describe("validateMobilePushContent", () => {
805
762
  somethingWentWrong: { id: "wrong" },
806
763
  unsupportedTagsValidationError: { id: "unsupported" }
807
764
  };
765
+ const tagLookupMap = { foo: true };
808
766
  const eventContextTags = [{ tagName: "foo" }];
809
767
  const onError = jest.fn();
810
768
  const onSuccess = jest.fn();
@@ -813,7 +771,7 @@ describe("validateMobilePushContent", () => {
813
771
  jest.clearAllMocks();
814
772
  });
815
773
 
816
- it("calls onError for empty formData (validateMobilePushContent)", async () => {
774
+ it("calls onError for empty formData", async () => {
817
775
  const getLiquidTags = jest.fn((content, cb) =>
818
776
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
819
777
  );
@@ -822,17 +780,18 @@ describe("validateMobilePushContent", () => {
822
780
  {
823
781
  getLiquidTags,
824
782
  formatMessage,
825
- messages,
826
- onError,
827
- onSuccess,
828
- eventContextTags,
783
+ messages,
784
+ onError,
785
+ onSuccess,
786
+ tagLookupMap,
787
+ eventContextTags,
829
788
  currentTab: 1
830
789
  }
831
790
  );
832
791
  expect(onError).toHaveBeenCalled();
833
792
  });
834
793
 
835
- it("calls onSuccess for valid android and ios content (validateMobilePushContent)", async () => {
794
+ it("calls onSuccess for valid android and ios content", async () => {
836
795
  const getLiquidTags = jest.fn((content, cb) =>
837
796
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
838
797
  );
@@ -843,6 +802,7 @@ describe("validateMobilePushContent", () => {
843
802
  messages,
844
803
  onError,
845
804
  onSuccess,
805
+ tagLookupMap,
846
806
  eventContextTags,
847
807
  currentTab: 1
848
808
  });
@@ -860,6 +820,7 @@ describe("validateMobilePushContent", () => {
860
820
  messages,
861
821
  onError,
862
822
  onSuccess,
823
+ tagLookupMap,
863
824
  eventContextTags,
864
825
  currentTab: 1
865
826
  });
@@ -877,6 +838,7 @@ describe("validateMobilePushContent", () => {
877
838
  messages,
878
839
  onError,
879
840
  onSuccess,
841
+ tagLookupMap,
880
842
  eventContextTags,
881
843
  currentTab: 2
882
844
  });
@@ -894,6 +856,7 @@ describe("validateMobilePushContent", () => {
894
856
  messages,
895
857
  onError,
896
858
  onSuccess,
859
+ tagLookupMap,
897
860
  eventContextTags
898
861
  });
899
862
  expect(onSuccess).toHaveBeenCalledWith(JSON.stringify(formData[0]), "android");
@@ -910,6 +873,7 @@ describe("validateMobilePushContent", () => {
910
873
  messages,
911
874
  onError,
912
875
  onSuccess,
876
+ tagLookupMap,
913
877
  eventContextTags
914
878
  });
915
879
  expect(onSuccess).toHaveBeenCalledWith("null", "android");
@@ -922,10 +886,11 @@ describe("validateMobilePushContent", () => {
922
886
  {
923
887
  getLiquidTags,
924
888
  formatMessage,
925
- messages,
926
- onError,
927
- onSuccess,
928
- eventContextTags,
889
+ messages,
890
+ onError,
891
+ onSuccess,
892
+ tagLookupMap,
893
+ eventContextTags,
929
894
  currentTab: 1,
930
895
  },
931
896
  );
@@ -939,10 +904,11 @@ describe("validateMobilePushContent", () => {
939
904
  {
940
905
  getLiquidTags,
941
906
  formatMessage,
942
- messages,
943
- onError,
944
- onSuccess,
945
- eventContextTags,
907
+ messages,
908
+ onError,
909
+ onSuccess,
910
+ tagLookupMap,
911
+ eventContextTags,
946
912
  currentTab: 1,
947
913
  },
948
914
  );
@@ -956,10 +922,11 @@ describe("validateMobilePushContent", () => {
956
922
  {
957
923
  getLiquidTags,
958
924
  formatMessage,
959
- messages,
960
- onError,
961
- onSuccess,
962
- eventContextTags,
925
+ messages,
926
+ onError,
927
+ onSuccess,
928
+ tagLookupMap,
929
+ eventContextTags,
963
930
  currentTab: 1,
964
931
  },
965
932
  );
@@ -973,10 +940,11 @@ describe("validateMobilePushContent", () => {
973
940
  {
974
941
  getLiquidTags,
975
942
  formatMessage,
976
- messages,
977
- onError,
978
- onSuccess,
979
- eventContextTags,
943
+ messages,
944
+ onError,
945
+ onSuccess,
946
+ tagLookupMap,
947
+ eventContextTags,
980
948
  currentTab: 1,
981
949
  },
982
950
  );
@@ -990,10 +958,11 @@ describe("validateMobilePushContent", () => {
990
958
  {
991
959
  getLiquidTags,
992
960
  formatMessage,
993
- messages,
994
- onError,
995
- onSuccess,
996
- eventContextTags,
961
+ messages,
962
+ onError,
963
+ onSuccess,
964
+ tagLookupMap,
965
+ eventContextTags,
997
966
  },
998
967
  );
999
968
  expect(onError).toHaveBeenCalled();
@@ -1006,10 +975,11 @@ describe("validateMobilePushContent", () => {
1006
975
  {
1007
976
  getLiquidTags,
1008
977
  formatMessage,
1009
- messages,
1010
- onError,
1011
- onSuccess,
1012
- eventContextTags,
978
+ messages,
979
+ onError,
980
+ onSuccess,
981
+ tagLookupMap,
982
+ eventContextTags,
1013
983
  },
1014
984
  );
1015
985
  expect(onError).toHaveBeenCalled();
@@ -1022,10 +992,11 @@ describe("validateMobilePushContent", () => {
1022
992
  {
1023
993
  getLiquidTags,
1024
994
  formatMessage,
1025
- messages,
1026
- onError,
1027
- onSuccess,
1028
- eventContextTags,
995
+ messages,
996
+ onError,
997
+ onSuccess,
998
+ tagLookupMap,
999
+ eventContextTags,
1029
1000
  },
1030
1001
  );
1031
1002
  expect(onError).toHaveBeenCalled();
@@ -1038,10 +1009,11 @@ describe("validateMobilePushContent", () => {
1038
1009
  {
1039
1010
  getLiquidTags,
1040
1011
  formatMessage,
1041
- messages,
1042
- onError,
1043
- onSuccess,
1044
- eventContextTags,
1012
+ messages,
1013
+ onError,
1014
+ onSuccess,
1015
+ tagLookupMap,
1016
+ eventContextTags,
1045
1017
  },
1046
1018
  );
1047
1019
  expect(onError).toHaveBeenCalled();
@@ -1054,10 +1026,11 @@ describe("validateMobilePushContent", () => {
1054
1026
  {
1055
1027
  getLiquidTags,
1056
1028
  formatMessage,
1057
- messages,
1058
- onError,
1059
- onSuccess,
1060
- eventContextTags,
1029
+ messages,
1030
+ onError,
1031
+ onSuccess,
1032
+ tagLookupMap,
1033
+ eventContextTags,
1061
1034
  },
1062
1035
  );
1063
1036
  expect(onError).toHaveBeenCalled();
@@ -1071,6 +1044,7 @@ describe("validateInAppContent", () => {
1071
1044
  somethingWentWrong: { id: "wrong" },
1072
1045
  unsupportedTagsValidationError: { id: "unsupported" }
1073
1046
  };
1047
+ const tagLookupMap = { foo: true };
1074
1048
  const eventContextTags = [{ tagName: "foo" }];
1075
1049
  const onError = jest.fn();
1076
1050
  const onSuccess = jest.fn();
@@ -1079,7 +1053,7 @@ describe("validateInAppContent", () => {
1079
1053
  jest.clearAllMocks();
1080
1054
  });
1081
1055
 
1082
- it("calls onError for empty formData (validateInAppContent)", async () => {
1056
+ it("calls onError for empty formData", async () => {
1083
1057
  const getLiquidTags = jest.fn((content, cb) =>
1084
1058
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
1085
1059
  );
@@ -1088,16 +1062,17 @@ describe("validateInAppContent", () => {
1088
1062
  {
1089
1063
  getLiquidTags,
1090
1064
  formatMessage,
1091
- messages,
1092
- onError,
1093
- onSuccess,
1094
- eventContextTags,
1065
+ messages,
1066
+ onError,
1067
+ onSuccess,
1068
+ tagLookupMap,
1069
+ eventContextTags,
1095
1070
  }
1096
1071
  );
1097
1072
  expect(onError).toHaveBeenCalled();
1098
1073
  });
1099
1074
 
1100
- it("calls onSuccess for valid android and ios content (validateInAppContent)", async () => {
1075
+ it("calls onSuccess for valid android and ios content", async () => {
1101
1076
  const getLiquidTags = jest.fn((content, cb) =>
1102
1077
  cb({ askAiraResponse: { errors: [], data: [] }, isError: false })
1103
1078
  );
@@ -1117,6 +1092,7 @@ describe("validateInAppContent", () => {
1117
1092
  messages,
1118
1093
  onError,
1119
1094
  onSuccess,
1095
+ tagLookupMap,
1120
1096
  eventContextTags,
1121
1097
  singleTab: ANDROID,
1122
1098
  });
@@ -1143,6 +1119,7 @@ describe("validateInAppContent", () => {
1143
1119
  messages,
1144
1120
  onError,
1145
1121
  onSuccess,
1122
+ tagLookupMap,
1146
1123
  eventContextTags,
1147
1124
  singleTab: IOS,
1148
1125
  });
@@ -1169,11 +1146,11 @@ describe("getChannelData", () => {
1169
1146
  expect(getChannelData("SMS", formData)).toBe("Hi Test");
1170
1147
  });
1171
1148
 
1172
- it("returns string with undefineds for SMS when base and template-name are empty or undefined", () => {
1149
+ it("returns string with undefineds for SMS channel with missing fields", () => {
1173
1150
  const formData = { base: {}, "template-name": undefined };
1174
1151
  expect(getChannelData("SMS", formData)).toBe("undefined undefined");
1175
1152
  });
1176
- it("returns string with undefineds for SMS when formData is empty string", () => {
1153
+ it("returns string with undefineds for SMS channel with missing fields", () => {
1177
1154
  expect(getChannelData("SMS", "")).toBe("undefined undefined");
1178
1155
  });
1179
1156