@capillarytech/creatives-library 8.0.345-alpha.12 → 8.0.345-alpha.13

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 (138) hide show
  1. package/constants/unified.js +0 -29
  2. package/package.json +1 -1
  3. package/services/api.js +20 -0
  4. package/services/tests/api.test.js +59 -13
  5. package/utils/commonUtils.js +1 -19
  6. package/v2Components/CapActionButton/constants.js +0 -7
  7. package/v2Components/CapActionButton/index.js +109 -167
  8. package/v2Components/CapActionButton/index.scss +6 -157
  9. package/v2Components/CapActionButton/messages.js +3 -19
  10. package/v2Components/CapActionButton/tests/index.test.js +17 -41
  11. package/v2Components/CapCustomSkeleton/index.js +1 -1
  12. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  13. package/v2Components/CapTagList/index.js +0 -10
  14. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  15. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  16. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  17. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  18. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  19. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  20. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  21. package/v2Components/CommonTestAndPreview/SendTestMessage.js +5 -10
  22. package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +15 -160
  23. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +76 -341
  24. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  25. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -11
  26. package/v2Components/CommonTestAndPreview/constants.js +2 -38
  27. package/v2Components/CommonTestAndPreview/index.js +186 -676
  28. package/v2Components/CommonTestAndPreview/messages.js +3 -49
  29. package/v2Components/CommonTestAndPreview/sagas.js +6 -15
  30. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +284 -308
  31. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  32. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  33. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  34. package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +1 -8
  35. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +13 -34
  36. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +283 -281
  37. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  38. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -132
  39. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  40. package/v2Components/FormBuilder/index.js +10 -8
  41. package/v2Components/TemplatePreview/_templatePreview.scss +23 -33
  42. package/v2Components/TemplatePreview/index.js +28 -143
  43. package/v2Components/TemplatePreview/tests/index.test.js +0 -142
  44. package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
  45. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  46. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  47. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +9 -0
  48. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  49. package/v2Containers/CreativesContainer/SlideBoxFooter.js +4 -11
  50. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  51. package/v2Containers/CreativesContainer/constants.js +0 -9
  52. package/v2Containers/CreativesContainer/index.js +108 -300
  53. package/v2Containers/CreativesContainer/index.scss +1 -51
  54. package/v2Containers/CreativesContainer/messages.js +4 -0
  55. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  56. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  57. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  58. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  59. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +18 -20
  60. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  61. package/v2Containers/Rcs/constants.js +8 -119
  62. package/v2Containers/Rcs/index.js +812 -2375
  63. package/v2Containers/Rcs/index.scss +6 -276
  64. package/v2Containers/Rcs/messages.js +3 -38
  65. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +70345 -98302
  66. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  67. package/v2Containers/Rcs/tests/index.test.js +121 -152
  68. package/v2Containers/Rcs/tests/mockData.js +0 -38
  69. package/v2Containers/Rcs/tests/utils.test.js +30 -646
  70. package/v2Containers/Rcs/utils.js +11 -478
  71. package/v2Containers/Sms/Create/index.js +40 -100
  72. package/v2Containers/SmsTrai/Create/index.js +4 -9
  73. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  74. package/v2Containers/SmsTrai/Edit/index.js +130 -636
  75. package/v2Containers/SmsTrai/Edit/messages.js +4 -14
  76. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2296 -4249
  77. package/v2Containers/SmsWrapper/index.js +8 -37
  78. package/v2Containers/TagList/index.js +0 -6
  79. package/v2Containers/Templates/ChannelTypeIllustration.js +23 -6
  80. package/v2Containers/Templates/_templates.scss +126 -181
  81. package/v2Containers/Templates/actions.js +36 -11
  82. package/v2Containers/Templates/constants.js +23 -2
  83. package/v2Containers/Templates/index.js +333 -142
  84. package/v2Containers/Templates/messages.js +68 -0
  85. package/v2Containers/Templates/reducer.js +68 -0
  86. package/v2Containers/Templates/sagas.js +98 -55
  87. package/v2Containers/Templates/selectors.js +12 -0
  88. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +12 -0
  89. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1256 -1042
  90. package/v2Containers/Templates/tests/index.test.js +6 -0
  91. package/v2Containers/Templates/tests/reducer.test.js +178 -0
  92. package/v2Containers/Templates/tests/sagas.test.js +436 -200
  93. package/v2Containers/Templates/tests/selector.test.js +32 -0
  94. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  95. package/v2Containers/TemplatesV2/index.js +23 -86
  96. package/v2Containers/Whatsapp/index.js +20 -3
  97. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -578
  98. package/utils/rcsPayloadUtils.js +0 -92
  99. package/utils/templateVarUtils.js +0 -201
  100. package/utils/tests/templateVarUtils.test.js +0 -204
  101. package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +0 -18
  102. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  103. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  104. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  105. package/v2Components/SmsFallback/constants.js +0 -73
  106. package/v2Components/SmsFallback/index.js +0 -955
  107. package/v2Components/SmsFallback/index.scss +0 -265
  108. package/v2Components/SmsFallback/messages.js +0 -78
  109. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
  110. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  111. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  112. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  113. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  114. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
  115. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  116. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  117. package/v2Components/TemplatePreview/constants.js +0 -2
  118. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  119. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  120. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  121. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  122. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  123. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  124. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  125. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  126. package/v2Containers/Rcs/index.js.rej +0 -1336
  127. package/v2Containers/Rcs/index.scss.rej +0 -74
  128. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
  129. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +0 -128
  130. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
  131. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  132. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  133. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  134. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  135. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  136. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  137. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  138. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -23,6 +23,9 @@ describe('Test Templates container', () => {
23
23
  const getUserList = jest.fn();
24
24
  const getSenderDetails = jest.fn();
25
25
  const resetTemplate = jest.fn();
26
+ const setArchivedMode = jest.fn();
27
+ const clearTemplateSelection = jest.fn();
28
+ const toggleTemplateSelection = jest.fn();
26
29
  let renderedComponent;
27
30
 
28
31
  beforeEach(() => {
@@ -56,6 +59,9 @@ describe('Test Templates container', () => {
56
59
  getUserList,
57
60
  getSenderDetails,
58
61
  resetTemplate,
62
+ setArchivedMode,
63
+ clearTemplateSelection,
64
+ toggleTemplateSelection,
59
65
  }}
60
66
  location={{
61
67
  pathname: `/${channel}`,
@@ -353,3 +353,181 @@ describe("test reducer - SET account actions clear templates", () => {
353
353
  expect(result.templates).toEqual([]);
354
354
  });
355
355
  });
356
+
357
+ describe("test reducer - archive actions", () => {
358
+ afterEach(() => {
359
+ jest.clearAllMocks();
360
+ });
361
+
362
+ it("should handle SET_ARCHIVE_FILTER", () => {
363
+ const action = { type: types.SET_ARCHIVE_FILTER, filter: 'archived' };
364
+ const result = reducer(initialState, action).toJS();
365
+ expect(result.archiveFilter).toBe('archived');
366
+ expect(result.templates).toEqual([]);
367
+ expect(result.selectedTemplateIds).toEqual([]);
368
+ });
369
+
370
+ it("should handle SET_ARCHIVED_MODE with isArchived true", () => {
371
+ const action = { type: types.SET_ARCHIVED_MODE, isArchived: true };
372
+ const result = reducer(initialState, action).toJS();
373
+ expect(result.isArchivedMode).toBe(true);
374
+ expect(result.archiveFilter).toBe('archived');
375
+ expect(result.templates).toEqual([]);
376
+ expect(result.selectedTemplateIds).toEqual([]);
377
+ });
378
+
379
+ it("should handle SET_ARCHIVED_MODE with isArchived false", () => {
380
+ const action = { type: types.SET_ARCHIVED_MODE, isArchived: false };
381
+ const result = reducer(initialState, action).toJS();
382
+ expect(result.isArchivedMode).toBe(false);
383
+ expect(result.archiveFilter).toBe('active');
384
+ });
385
+
386
+ it("should handle TOGGLE_TEMPLATE_SELECTION - add id", () => {
387
+ const action = { type: types.TOGGLE_TEMPLATE_SELECTION, id: 'id1' };
388
+ const result = reducer(initialState, action).toJS();
389
+ expect(result.selectedTemplateIds).toEqual(['id1']);
390
+ });
391
+
392
+ it("should handle TOGGLE_TEMPLATE_SELECTION - remove id if already selected", () => {
393
+ const { fromJS } = require('immutable');
394
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1', 'id2']));
395
+ const action = { type: types.TOGGLE_TEMPLATE_SELECTION, id: 'id1' };
396
+ const result = reducer(stateWithSelected, action).toJS();
397
+ expect(result.selectedTemplateIds).toEqual(['id2']);
398
+ });
399
+
400
+ it("should handle TOGGLE_TEMPLATE_SELECTION - add id when selectedTemplateIds is a plain array (legacy state)", () => {
401
+ // Covers the Array.isArray branch of the defensive fallback
402
+ const stateWithPlainArray = initialState.set('selectedTemplateIds', ['id1']);
403
+ const action = { type: types.TOGGLE_TEMPLATE_SELECTION, id: 'id2' };
404
+ const result = reducer(stateWithPlainArray, action).toJS();
405
+ expect(result.selectedTemplateIds).toEqual(['id1', 'id2']);
406
+ });
407
+
408
+ it("should handle TOGGLE_TEMPLATE_SELECTION - remove id when selectedTemplateIds is a plain array (legacy state)", () => {
409
+ // Covers the Array.isArray branch of the defensive fallback
410
+ const stateWithPlainArray = initialState.set('selectedTemplateIds', ['id1', 'id2']);
411
+ const action = { type: types.TOGGLE_TEMPLATE_SELECTION, id: 'id1' };
412
+ const result = reducer(stateWithPlainArray, action).toJS();
413
+ expect(result.selectedTemplateIds).toEqual(['id2']);
414
+ });
415
+
416
+ it("should handle TOGGLE_TEMPLATE_SELECTION - add id when selectedTemplateIds is undefined (stale persisted state)", () => {
417
+ // Covers the final fallback to [] when rawSelected is neither Immutable nor Array
418
+ const stateWithUndefined = initialState.set('selectedTemplateIds', undefined);
419
+ const action = { type: types.TOGGLE_TEMPLATE_SELECTION, id: 'id1' };
420
+ const result = reducer(stateWithUndefined, action).toJS();
421
+ expect(result.selectedTemplateIds).toEqual(['id1']);
422
+ });
423
+
424
+ it("should handle SELECT_ALL_TEMPLATES", () => {
425
+ const action = { type: types.SELECT_ALL_TEMPLATES, ids: ['id1', 'id2', 'id3'] };
426
+ const result = reducer(initialState, action).toJS();
427
+ expect(result.selectedTemplateIds).toEqual(['id1', 'id2', 'id3']);
428
+ });
429
+
430
+ it("should handle CLEAR_TEMPLATE_SELECTION", () => {
431
+ const { fromJS } = require('immutable');
432
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1', 'id2']));
433
+ const action = { type: types.CLEAR_TEMPLATE_SELECTION };
434
+ const result = reducer(stateWithSelected, action).toJS();
435
+ expect(result.selectedTemplateIds).toEqual([]);
436
+ });
437
+
438
+ it("should handle ARCHIVE_TEMPLATE_REQUEST", () => {
439
+ const action = { type: types.ARCHIVE_TEMPLATE_REQUEST };
440
+ const result = reducer(initialState, action).toJS();
441
+ expect(result.archiveInProgress).toBe(true);
442
+ });
443
+
444
+ it("should handle ARCHIVE_TEMPLATE_SUCCESS", () => {
445
+ const action = { type: types.ARCHIVE_TEMPLATE_SUCCESS };
446
+ const result = reducer(initialState, action).toJS();
447
+ expect(result.archiveInProgress).toBe(false);
448
+ });
449
+
450
+ it("should remove archived template id from selectedTemplateIds on ARCHIVE_TEMPLATE_SUCCESS", () => {
451
+ const { fromJS } = require('immutable');
452
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1', 'id2', 'id3']));
453
+ const action = { type: types.ARCHIVE_TEMPLATE_SUCCESS, id: 'id2' };
454
+ const result = reducer(stateWithSelected, action).toJS();
455
+ expect(result.archiveInProgress).toBe(false);
456
+ expect(result.selectedTemplateIds).toEqual(['id1', 'id3']);
457
+ });
458
+
459
+ it("should handle ARCHIVE_TEMPLATE_FAILURE", () => {
460
+ const action = { type: types.ARCHIVE_TEMPLATE_FAILURE };
461
+ const result = reducer(initialState, action).toJS();
462
+ expect(result.archiveInProgress).toBe(false);
463
+ });
464
+
465
+ it("should handle UNARCHIVE_TEMPLATE_REQUEST", () => {
466
+ const action = { type: types.UNARCHIVE_TEMPLATE_REQUEST };
467
+ const result = reducer(initialState, action).toJS();
468
+ expect(result.unarchiveInProgress).toBe(true);
469
+ });
470
+
471
+ it("should handle UNARCHIVE_TEMPLATE_SUCCESS", () => {
472
+ const action = { type: types.UNARCHIVE_TEMPLATE_SUCCESS };
473
+ const result = reducer(initialState, action).toJS();
474
+ expect(result.unarchiveInProgress).toBe(false);
475
+ });
476
+
477
+ it("should remove unarchived template id from selectedTemplateIds on UNARCHIVE_TEMPLATE_SUCCESS", () => {
478
+ const { fromJS } = require('immutable');
479
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1', 'id2', 'id3']));
480
+ const action = { type: types.UNARCHIVE_TEMPLATE_SUCCESS, id: 'id1' };
481
+ const result = reducer(stateWithSelected, action).toJS();
482
+ expect(result.unarchiveInProgress).toBe(false);
483
+ expect(result.selectedTemplateIds).toEqual(['id2', 'id3']);
484
+ });
485
+
486
+ it("should handle UNARCHIVE_TEMPLATE_FAILURE", () => {
487
+ const action = { type: types.UNARCHIVE_TEMPLATE_FAILURE };
488
+ const result = reducer(initialState, action).toJS();
489
+ expect(result.unarchiveInProgress).toBe(false);
490
+ });
491
+
492
+ it("should handle BULK_ARCHIVE_REQUEST", () => {
493
+ const action = { type: types.BULK_ARCHIVE_REQUEST };
494
+ const result = reducer(initialState, action).toJS();
495
+ expect(result.bulkArchiveInProgress).toBe(true);
496
+ });
497
+
498
+ it("should handle BULK_ARCHIVE_SUCCESS", () => {
499
+ const { fromJS } = require('immutable');
500
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1']));
501
+ const action = { type: types.BULK_ARCHIVE_SUCCESS };
502
+ const result = reducer(stateWithSelected, action).toJS();
503
+ expect(result.bulkArchiveInProgress).toBe(false);
504
+ expect(result.selectedTemplateIds).toEqual([]);
505
+ });
506
+
507
+ it("should handle BULK_ARCHIVE_FAILURE", () => {
508
+ const action = { type: types.BULK_ARCHIVE_FAILURE };
509
+ const result = reducer(initialState, action).toJS();
510
+ expect(result.bulkArchiveInProgress).toBe(false);
511
+ });
512
+
513
+ it("should handle BULK_UNARCHIVE_REQUEST", () => {
514
+ const action = { type: types.BULK_UNARCHIVE_REQUEST };
515
+ const result = reducer(initialState, action).toJS();
516
+ expect(result.bulkUnarchiveInProgress).toBe(true);
517
+ });
518
+
519
+ it("should handle BULK_UNARCHIVE_SUCCESS", () => {
520
+ const { fromJS } = require('immutable');
521
+ const stateWithSelected = initialState.set('selectedTemplateIds', fromJS(['id1']));
522
+ const action = { type: types.BULK_UNARCHIVE_SUCCESS };
523
+ const result = reducer(stateWithSelected, action).toJS();
524
+ expect(result.bulkUnarchiveInProgress).toBe(false);
525
+ expect(result.selectedTemplateIds).toEqual([]);
526
+ });
527
+
528
+ it("should handle BULK_UNARCHIVE_FAILURE", () => {
529
+ const action = { type: types.BULK_UNARCHIVE_FAILURE };
530
+ const result = reducer(initialState, action).toJS();
531
+ expect(result.bulkUnarchiveInProgress).toBe(false);
532
+ });
533
+ });