@capillarytech/creatives-library 8.0.201-alpha.0 → 8.0.201

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.201-alpha.0",
4
+ "version": "8.0.201",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -5,6 +5,7 @@ import { SlideBoxContent } from '../SlideBoxContent';
5
5
  import mockdata from '../../mockdata';
6
6
  import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
7
7
  import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
8
+ import * as commonUtils from '../../../utils/common';
8
9
 
9
10
  const {
10
11
  whatsappEditTemplateData,
@@ -50,6 +51,11 @@ describe('Test SlideBoxContent container', () => {
50
51
  global.Date = originalDate;
51
52
  });
52
53
 
54
+ afterEach(() => {
55
+ // Clean up all mocks after each test
56
+ jest.restoreAllMocks();
57
+ });
58
+
53
59
  const renderFunction = (channel, mode, templateData, additionalProps = {}) => {
54
60
  renderedComponent = shallowWithIntl(
55
61
  <SlideBoxContent
@@ -704,9 +710,9 @@ describe('Test SlideBoxContent container', () => {
704
710
  // Mobile Push Loyalty Module Tests
705
711
  describe('Mobile Push with Loyalty Module', () => {
706
712
  it('Should render MobliPushEdit for loyalty module in library mode (edit)', () => {
707
- renderFunction('mobilepush', 'editTemplate', {
713
+ renderFunction('MOBILEPUSH', 'editTemplate', {
708
714
  _id: 'test-id',
709
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
715
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
710
716
  }, {
711
717
  isFullMode: false,
712
718
  isLoyaltyModule: true
@@ -715,9 +721,9 @@ describe('Test SlideBoxContent container', () => {
715
721
  });
716
722
 
717
723
  it('Should render MobilePushNew for loyalty module in full mode (edit)', () => {
718
- renderFunction('mobilepush', 'editTemplate', {
724
+ renderFunction('MOBILEPUSH', 'editTemplate', {
719
725
  _id: 'test-id',
720
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
726
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
721
727
  }, {
722
728
  isFullMode: true,
723
729
  isLoyaltyModule: true
@@ -726,9 +732,9 @@ describe('Test SlideBoxContent container', () => {
726
732
  });
727
733
 
728
734
  it('Should render MobilepushWrapper for loyalty module in library mode (create)', () => {
729
- renderFunction('mobilepush', 'createTemplate', {
735
+ renderFunction('MOBILEPUSH', 'createTemplate', {
730
736
  mode: 'create',
731
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
737
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
732
738
  }, {
733
739
  isFullMode: false,
734
740
  isLoyaltyModule: true
@@ -737,9 +743,9 @@ describe('Test SlideBoxContent container', () => {
737
743
  });
738
744
 
739
745
  it('Should render MobilePushNew for loyalty module in full mode (create)', () => {
740
- renderFunction('mobilepush', 'createTemplate', {
746
+ renderFunction('MOBILEPUSH', 'createTemplate', {
741
747
  mode: 'create',
742
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
748
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
743
749
  }, {
744
750
  isFullMode: true,
745
751
  isLoyaltyModule: true
@@ -748,9 +754,9 @@ describe('Test SlideBoxContent container', () => {
748
754
  });
749
755
 
750
756
  it('Should render MobilePushNew for non-loyalty module in library mode (edit)', () => {
751
- renderFunction('mobilepush', 'editTemplate', {
757
+ renderFunction('MOBILEPUSH', 'editTemplate', {
752
758
  _id: 'test-id',
753
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
759
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
754
760
  }, {
755
761
  isFullMode: false,
756
762
  isLoyaltyModule: false
@@ -759,15 +765,37 @@ describe('Test SlideBoxContent container', () => {
759
765
  });
760
766
 
761
767
  it('Should render MobilePushNew for non-loyalty module in library mode (create)', () => {
762
- renderFunction('mobilepush', 'createTemplate', {
768
+ renderFunction('MOBILEPUSH', 'createTemplate', {
763
769
  mode: 'create',
764
- type: 'mobilepush' // Use lowercase to match constants.MOBILE_PUSH
770
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
765
771
  }, {
766
772
  isFullMode: false,
767
773
  isLoyaltyModule: false
768
774
  });
769
775
  expect(renderedComponent).toMatchSnapshot();
770
776
  });
777
+
778
+ it('Should render MobilePushNew for non-loyalty module in full mode (edit)', () => {
779
+ renderFunction('MOBILEPUSH', 'editTemplate', {
780
+ _id: 'test-id',
781
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
782
+ }, {
783
+ isFullMode: true,
784
+ isLoyaltyModule: false
785
+ });
786
+ expect(renderedComponent).toMatchSnapshot();
787
+ });
788
+
789
+ it('Should render MobilePushNew for non-loyalty module in full mode (create)', () => {
790
+ renderFunction('MOBILEPUSH', 'createTemplate', {
791
+ mode: 'create',
792
+ type: 'MOBILEPUSH' // Use uppercase to match constants.MOBILE_PUSH
793
+ }, {
794
+ isFullMode: true,
795
+ isLoyaltyModule: false
796
+ });
797
+ expect(renderedComponent).toMatchSnapshot();
798
+ });
771
799
  });
772
800
 
773
801
  // Additional edge case tests to cover uncovered lines
@@ -790,9 +818,7 @@ describe('Test SlideBoxContent container', () => {
790
818
  // This should cover line 251 in SMS content processing
791
819
  // Need isDltEnabled = true and updatedSmsEditor as array
792
820
  // Mock hasTraiDltFeature to return true
793
- const commonUtils = require('../../../utils/common');
794
- const originalHasTraiDltFeature = commonUtils.hasTraiDltFeature;
795
- commonUtils.hasTraiDltFeature = jest.fn(() => true);
821
+ jest.spyOn(commonUtils, 'hasTraiDltFeature').mockReturnValue(true);
796
822
 
797
823
  const smsTemplateData = {
798
824
  type: 'SMS',
@@ -808,8 +834,6 @@ describe('Test SlideBoxContent container', () => {
808
834
  isFullMode: false
809
835
  });
810
836
 
811
- // Restore original function
812
- commonUtils.hasTraiDltFeature = originalHasTraiDltFeature;
813
837
  expect(renderedComponent).toMatchSnapshot();
814
838
  });
815
839
 
@@ -683,17 +683,251 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
683
683
  </SlideBoxContent__CreativesWrapper>
684
684
  `;
685
685
 
686
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for loyalty module in full mode (create) 1`] = `<SlideBoxContent__CreativesWrapper />`;
686
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for loyalty module in full mode (create) 1`] = `
687
+ <SlideBoxContent__CreativesWrapper>
688
+ <ForwardRef
689
+ date={0}
690
+ getDefaultTags=""
691
+ isFullMode={true}
692
+ key="creatives-mobilepush-wrapper"
693
+ onCreateComplete={[MockFunction]}
694
+ query={
695
+ Object {
696
+ "isEditFromCampaigns": undefined,
697
+ "module": "default",
698
+ "type": false,
699
+ }
700
+ }
701
+ templateData={
702
+ Object {
703
+ "mode": "create",
704
+ "type": "MOBILEPUSH",
705
+ }
706
+ }
707
+ type=""
708
+ />
709
+ </SlideBoxContent__CreativesWrapper>
710
+ `;
687
711
 
688
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for loyalty module in full mode (edit) 1`] = `<SlideBoxContent__CreativesWrapper />`;
712
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for loyalty module in full mode (edit) 1`] = `
713
+ <SlideBoxContent__CreativesWrapper>
714
+ <ForwardRef
715
+ getDefaultTags=""
716
+ isFullMode={true}
717
+ location={
718
+ Object {
719
+ "pathname": "/mobilepush/edit/",
720
+ "query": Object {
721
+ "isEditFromCampaigns": undefined,
722
+ "module": "default",
723
+ "type": false,
724
+ },
725
+ }
726
+ }
727
+ params={
728
+ Object {
729
+ "id": "test-id",
730
+ }
731
+ }
732
+ route={
733
+ Object {
734
+ "name": "mobilepush",
735
+ }
736
+ }
737
+ templateData={
738
+ Object {
739
+ "_id": "test-id",
740
+ "type": "MOBILEPUSH",
741
+ }
742
+ }
743
+ type=""
744
+ />
745
+ </SlideBoxContent__CreativesWrapper>
746
+ `;
689
747
 
690
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in library mode (create) 1`] = `<SlideBoxContent__CreativesWrapper />`;
748
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in full mode (create) 1`] = `
749
+ <SlideBoxContent__CreativesWrapper>
750
+ <ForwardRef
751
+ date={0}
752
+ getDefaultTags=""
753
+ isFullMode={true}
754
+ key="creatives-mobilepush-wrapper"
755
+ onCreateComplete={[MockFunction]}
756
+ query={
757
+ Object {
758
+ "isEditFromCampaigns": undefined,
759
+ "module": "default",
760
+ "type": false,
761
+ }
762
+ }
763
+ templateData={
764
+ Object {
765
+ "mode": "create",
766
+ "type": "MOBILEPUSH",
767
+ }
768
+ }
769
+ type=""
770
+ />
771
+ </SlideBoxContent__CreativesWrapper>
772
+ `;
691
773
 
692
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in library mode (edit) 1`] = `<SlideBoxContent__CreativesWrapper />`;
774
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in full mode (edit) 1`] = `
775
+ <SlideBoxContent__CreativesWrapper>
776
+ <ForwardRef
777
+ getDefaultTags=""
778
+ isFullMode={true}
779
+ location={
780
+ Object {
781
+ "pathname": "/mobilepush/edit/",
782
+ "query": Object {
783
+ "isEditFromCampaigns": undefined,
784
+ "module": "default",
785
+ "type": false,
786
+ },
787
+ }
788
+ }
789
+ params={
790
+ Object {
791
+ "id": "test-id",
792
+ }
793
+ }
794
+ route={
795
+ Object {
796
+ "name": "mobilepush",
797
+ }
798
+ }
799
+ templateData={
800
+ Object {
801
+ "_id": "test-id",
802
+ "type": "MOBILEPUSH",
803
+ }
804
+ }
805
+ type=""
806
+ />
807
+ </SlideBoxContent__CreativesWrapper>
808
+ `;
693
809
 
694
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilepushWrapper for loyalty module in library mode (create) 1`] = `<SlideBoxContent__CreativesWrapper />`;
810
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in library mode (create) 1`] = `
811
+ <SlideBoxContent__CreativesWrapper>
812
+ <ForwardRef
813
+ date={0}
814
+ getDefaultTags=""
815
+ isFullMode={false}
816
+ key="creatives-mobilepush-wrapper"
817
+ onCreateComplete={[MockFunction]}
818
+ query={
819
+ Object {
820
+ "isEditFromCampaigns": undefined,
821
+ "module": "library",
822
+ "type": "embedded",
823
+ }
824
+ }
825
+ templateData={
826
+ Object {
827
+ "mode": "create",
828
+ "type": "MOBILEPUSH",
829
+ }
830
+ }
831
+ type=""
832
+ />
833
+ </SlideBoxContent__CreativesWrapper>
834
+ `;
835
+
836
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilePushNew for non-loyalty module in library mode (edit) 1`] = `
837
+ <SlideBoxContent__CreativesWrapper>
838
+ <ForwardRef
839
+ getDefaultTags=""
840
+ isFullMode={false}
841
+ location={
842
+ Object {
843
+ "pathname": "/mobilepush/edit/",
844
+ "query": Object {
845
+ "isEditFromCampaigns": undefined,
846
+ "module": "library",
847
+ "type": "embedded",
848
+ },
849
+ }
850
+ }
851
+ params={
852
+ Object {
853
+ "id": "test-id",
854
+ }
855
+ }
856
+ route={
857
+ Object {
858
+ "name": "mobilepush",
859
+ }
860
+ }
861
+ templateData={
862
+ Object {
863
+ "_id": "test-id",
864
+ "type": "MOBILEPUSH",
865
+ }
866
+ }
867
+ type=""
868
+ />
869
+ </SlideBoxContent__CreativesWrapper>
870
+ `;
695
871
 
696
- exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobliPushEdit for loyalty module in library mode (edit) 1`] = `<SlideBoxContent__CreativesWrapper />`;
872
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobilepushWrapper for loyalty module in library mode (create) 1`] = `
873
+ <SlideBoxContent__CreativesWrapper>
874
+ <Connect(MobilepushWrapper)
875
+ date={0}
876
+ isFullMode={false}
877
+ key="creatives-mobilepush-wrapper"
878
+ query={
879
+ Object {
880
+ "isEditFromCampaigns": undefined,
881
+ "module": "library",
882
+ "type": "embedded",
883
+ }
884
+ }
885
+ templateData={
886
+ Object {
887
+ "mode": "create",
888
+ "type": "MOBILEPUSH",
889
+ }
890
+ }
891
+ type=""
892
+ />
893
+ </SlideBoxContent__CreativesWrapper>
894
+ `;
895
+
896
+ exports[`Test SlideBoxContent container Mobile Push with Loyalty Module Should render MobliPushEdit for loyalty module in library mode (edit) 1`] = `
897
+ <SlideBoxContent__CreativesWrapper>
898
+ <ForwardRef
899
+ getDefaultTags=""
900
+ isFullMode={false}
901
+ location={
902
+ Object {
903
+ "pathname": "/mobilepush/edit/",
904
+ "query": Object {
905
+ "isEditFromCampaigns": undefined,
906
+ "module": "library",
907
+ "type": "embedded",
908
+ },
909
+ }
910
+ }
911
+ params={
912
+ Object {
913
+ "id": "test-id",
914
+ }
915
+ }
916
+ route={
917
+ Object {
918
+ "name": "mobilepush",
919
+ }
920
+ }
921
+ templateData={
922
+ Object {
923
+ "_id": "test-id",
924
+ "type": "MOBILEPUSH",
925
+ }
926
+ }
927
+ type=""
928
+ />
929
+ </SlideBoxContent__CreativesWrapper>
930
+ `;
697
931
 
698
932
  exports[`Test SlideBoxContent container Should handle isTestAndPreviewMode IIFE implementation correctly 1`] = `
699
933
  <SlideBoxContent__CreativesWrapper>
@@ -24,11 +24,10 @@ export function* createTemplate({template, callback}) {
24
24
  errorMsg,
25
25
  });
26
26
  } catch (error) {
27
- // Call callback with error if provided, otherwise dispatch failure action
27
+ // Always dispatch failure action first, then call callback if provided
28
+ yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
28
29
  if (callback) {
29
30
  yield call(callback, new Error(errorMsg || error.message || error.toString()));
30
- } else {
31
- yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
32
31
  }
33
32
  }
34
33
  }
@@ -96,11 +95,10 @@ export function* editTemplate({ template, callback }) {
96
95
  yield call(callback, editResponseData);
97
96
  }
98
97
  } catch (error) {
99
- // Call callback with error if provided, otherwise dispatch failure action
98
+ // Always dispatch failure action first, then call callback if provided
99
+ yield put({ type: types.EDIT_TEMPLATE_FAILURE, error, errorMsg });
100
100
  if (callback) {
101
101
  yield call(callback, new Error(errorMsg || error.message || error.toString()));
102
- } else {
103
- yield put({ type: types.EDIT_TEMPLATE_FAILURE, error, errorMsg });
104
102
  }
105
103
  }
106
104
  }
@@ -121,6 +121,7 @@ describe('MobilePushNew Sagas', () => {
121
121
  [matchers.call.fn(Api.createMobilePushTemplateV2), throwError(error)],
122
122
  ])
123
123
  .call(Api.createMobilePushTemplateV2, template)
124
+ .put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg: undefined })
124
125
  .call(callback, new Error('Network error'))
125
126
  .run();
126
127
  });
@@ -392,6 +393,7 @@ describe('MobilePushNew Sagas', () => {
392
393
  [matchers.call.fn(Api.createMobilePushTemplateV2), throwError(error)],
393
394
  ])
394
395
  .call(Api.createMobilePushTemplateV2, template)
396
+ .put({ type: types.EDIT_TEMPLATE_FAILURE, error, errorMsg: undefined })
395
397
  .call(callback, new Error('Network error'))
396
398
  .run();
397
399
  });