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