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