@capillarytech/creatives-library 8.0.207 → 8.0.208

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/config/app.js CHANGED
@@ -20,7 +20,8 @@ const config = {
20
20
  accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
21
21
  },
22
22
  development: {
23
- api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
23
+ // api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
24
+ api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
24
25
  campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
25
26
  campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
26
27
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.207",
4
+ "version": "8.0.208",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -264,6 +264,7 @@ export const getUserData = () => {
264
264
 
265
265
  export const createTemplate = ({template}) => {
266
266
  const url = `${API_ENDPOINT}/templates/SMS`;
267
+ console.log("creating template",template);
267
268
  return request(url, getAPICallObject('POST', template));
268
269
  };
269
270
 
@@ -346,6 +347,7 @@ export const getAllTemplates = async ({channel, queryParams = {}}) => {
346
347
 
347
348
  export const deleteTemplate = ({channel, id}) => {
348
349
  const url = `${API_ENDPOINT}/templates/${id}/${channel}`;
350
+ console.log("deleting template", url);
349
351
  return request(url, getAPICallObject('DELETE'));
350
352
  //return API.deleteResource(url);
351
353
  };
@@ -392,7 +392,9 @@ export function SlideBoxContent(props) {
392
392
  };
393
393
  }
394
394
  default:
395
+ {
395
396
  return get(templateDataObject, `versions.base.content`);
397
+ }
396
398
  }
397
399
  };
398
400
 
@@ -63,7 +63,7 @@ export const mediaTypeOptions = ({host, templateCategory}) => {
63
63
  tagColor: CAP_PURPLE03,
64
64
  tagTextColor: CAP_PURPLE02,
65
65
  },
66
- ...(host === HOST_TWILIO
66
+ ...((host === HOST_TWILIO || (host === HOST_VALUE_FIRST && templateCategory === WHATSAPP_CATEGORIES.authentication))
67
67
  ? []
68
68
  : [
69
69
  {
@@ -80,7 +80,7 @@ export const mediaTypeOptions = ({host, templateCategory}) => {
80
80
  tagColor: CAP_GREEN02,
81
81
  tagTextColor: CAP_GREEN01,
82
82
  },
83
- ...(templateCategory === WHATSAPP_CATEGORIES.marketing && (host === HOST_GUPSHUP || host === HOST_KARIX)
83
+ ...(templateCategory === WHATSAPP_CATEGORIES.marketing && CAROUSEL_SUPPORTING_HOSTS.includes(host)
84
84
  ? [
85
85
  {
86
86
  key: 'CAROUSEL',
@@ -104,6 +104,25 @@ export const mediaTypeOptions = ({host, templateCategory}) => {
104
104
  ];
105
105
  };
106
106
 
107
+ export const VALUE_FIRST_CATEGORY_OPTIONS = [
108
+ {
109
+ key: 'marketing',
110
+ value: WHATSAPP_CATEGORIES.marketing,
111
+ label: <FormattedMessage {...messages.marketing} />,
112
+ tooltipLabel: <FormattedMessage {...messages.marketingTooltip} />,
113
+ tagColor: CAP_ORANGE01,
114
+ tagTextColor: CAP_ORANGE,
115
+ },
116
+ {
117
+ key: 'authentication',
118
+ value: WHATSAPP_CATEGORIES.authentication,
119
+ label: <FormattedMessage {...messages.authentication} />,
120
+ tooltipLabel: <FormattedMessage {...messages.authenticationTooltip} />,
121
+ tagColor: CAP_GREEN02,
122
+ tagTextColor: CAP_GREEN01,
123
+ },
124
+ ];
125
+
107
126
  export const KARIX_GUPSHUP_CATEGORY_OPTIONS = [
108
127
  {
109
128
  key: 'utility',
@@ -333,6 +352,7 @@ export const INITIAL_QUICK_REPLY_DATA = [
333
352
  },
334
353
  ];
335
354
 
355
+
336
356
  export const ALLOWED_IMAGE_EXTENSIONS_REGEX = /\.(jpe?g|png)$/i;
337
357
  export const ALLOWED_EXTENSIONS_VIDEO_REGEX = (/\.(mp4)$/i);
338
358
  export const ALLOWED_EXTENSIONS_DOCUMENT_REGEX = (/\.(pdf)$/i);
@@ -346,6 +366,9 @@ export const HOST_KARIX = 'karixwhatsappbulk';
346
366
  export const HOST_GUPSHUP = 'gupshupwhatsappbulk';
347
367
  export const HOST_ICS = 'icswababulk';
348
368
  export const HOST_HAPTIC = 'hapticwhatsappbulk';
369
+ export const HOST_VALUE_FIRST = 'valuefirstwhatsappbulk';
370
+
371
+ export const CAROUSEL_SUPPORTING_HOSTS = [HOST_GUPSHUP, HOST_VALUE_FIRST, HOST_KARIX];
349
372
 
350
373
  export const SIZE_UNITS = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
351
374
  export const DOCUMENT_FORMAT = 'PDF';
@@ -685,6 +708,7 @@ export const CATEGORY_OPTIONS_MAP = {
685
708
  [HOST_GUPSHUP]: KARIX_GUPSHUP_CATEGORY_OPTIONS,
686
709
  [HOST_ICS]: ICS_CATEGORY_OPTIONS,
687
710
  [HOST_HAPTIC]: HAPTIC_CATEGORY_OPTIONS,
711
+ [HOST_VALUE_FIRST]: VALUE_FIRST_CATEGORY_OPTIONS,
688
712
  };
689
713
 
690
714
  export const REQUEST = "REQUEST";
@@ -55,6 +55,7 @@ import {
55
55
  WHATSAPP,
56
56
  TWILIO_CATEGORY_OPTIONS,
57
57
  KARIX_GUPSHUP_CATEGORY_OPTIONS,
58
+ VALUE_FIRST_CATEGORY_OPTIONS,
58
59
  LANGUAGE_OPTIONS,
59
60
  WHATSAPP_STATUSES,
60
61
  TAG,
@@ -98,6 +99,7 @@ import {
98
99
  HAPTIC_CATEGORY_OPTIONS,
99
100
  CORRECT_TEMPLATE_FORMAT_URL,
100
101
  CATEGORY_OPTIONS_MAP,
102
+ HOST_VALUE_FIRST,
101
103
  IMAGE,
102
104
  VIDEO,
103
105
  URL,
@@ -1691,7 +1693,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1691
1693
 
1692
1694
  const createApprovalHandler = () => {
1693
1695
  setSpin(true);
1694
- actions.createWhatsappTemplate(createPayload(), (resp, errorMessage) => {
1696
+ const payload = createPayload();
1697
+ actions.createWhatsappTemplate(payload, (resp, errorMessage) => {
1695
1698
  actionCallback({ resp, errorMessage });
1696
1699
  if (!errorMessage) {
1697
1700
  onCreateComplete();
@@ -726,48 +726,123 @@ describe('Creatives Whatsapp test2/>', () => {
726
726
  });
727
727
  });
728
728
 
729
- // --- UNIT TESTS FOR mediaTypeOptions ---
729
+ // --- UNIT TESTS FOR mediaTypeOptions and CAROUSEL_SUPPORTING_HOSTS ---
730
730
  describe('mediaTypeOptions', () => {
731
- it('should include CAROUSEL when category is MARKETING and host is HOST_GUPSHUP', () => {
732
- const options = mediaTypeOptions({
731
+ it('should include CAROUSEL when category is MARKETING and host is in CAROUSEL_SUPPORTING_HOSTS', () => {
732
+ // Test HOST_GUPSHUP
733
+ const optionsGupshup = mediaTypeOptions({
733
734
  host: HOST_GUPSHUP,
734
735
  templateCategory: WHATSAPP_CATEGORIES.marketing,
735
736
  });
736
- const hasCarousel = options.some(
737
+ const hasCarouselGupshup = optionsGupshup.some(
737
738
  (opt) => Array.isArray(opt)
738
739
  ? opt.some((o) => o.key === 'CAROUSEL')
739
740
  : opt.key === 'CAROUSEL'
740
- ) || options.flat().some((o) => o.key === 'CAROUSEL');
741
- expect(hasCarousel).toBe(true);
741
+ ) || optionsGupshup.flat().some((o) => o.key === 'CAROUSEL');
742
+ expect(hasCarouselGupshup).toBe(true);
743
+
744
+ // Test HOST_VALUE_FIRST
745
+ const optionsValueFirst = mediaTypeOptions({
746
+ host: 'valuefirstwhatsappbulk',
747
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
748
+ });
749
+ const hasCarouselValueFirst = optionsValueFirst.some(
750
+ (opt) => Array.isArray(opt)
751
+ ? opt.some((o) => o.key === 'CAROUSEL')
752
+ : opt.key === 'CAROUSEL'
753
+ ) || optionsValueFirst.flat().some((o) => o.key === 'CAROUSEL');
754
+ expect(hasCarouselValueFirst).toBe(true);
755
+
756
+ // Test HOST_KARIX
757
+ const optionsKarix = mediaTypeOptions({
758
+ host: HOST_KARIX,
759
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
760
+ });
761
+ const hasCarouselKarix = optionsKarix.some(
762
+ (opt) => Array.isArray(opt)
763
+ ? opt.some((o) => o.key === 'CAROUSEL')
764
+ : opt.key === 'CAROUSEL'
765
+ ) || optionsKarix.flat().some((o) => o.key === 'CAROUSEL');
766
+ expect(hasCarouselKarix).toBe(true);
742
767
  });
743
768
 
744
- it('should NOT include CAROUSEL when category is MARKETING and host is NOT HOST_GUPSHUP', () => {
745
- const options = mediaTypeOptions({
746
- host: 'karixwhatsappbulk',
769
+ it('should NOT include CAROUSEL when category is MARKETING but host is NOT in CAROUSEL_SUPPORTING_HOSTS', () => {
770
+ // Test HOST_TWILIO
771
+ const optionsTwilio = mediaTypeOptions({
772
+ host: HOST_TWILIO,
747
773
  templateCategory: WHATSAPP_CATEGORIES.marketing,
748
774
  });
749
- const hasCarousel = options.some(
775
+ const hasCarouselTwilio = optionsTwilio.some(
750
776
  (opt) => Array.isArray(opt)
751
777
  ? opt.some((o) => o.key === 'CAROUSEL')
752
778
  : opt.key === 'CAROUSEL'
753
- ) || options.flat().some((o) => o.key === 'CAROUSEL');
754
- expect(hasCarousel).toBe(true);
779
+ ) || optionsTwilio.flat().some((o) => o.key === 'CAROUSEL');
780
+ expect(hasCarouselTwilio).toBe(false);
781
+
782
+ // Test HOST_ICS
783
+ const optionsIcs = mediaTypeOptions({
784
+ host: 'icswababulk',
785
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
786
+ });
787
+ const hasCarouselIcs = optionsIcs.some(
788
+ (opt) => Array.isArray(opt)
789
+ ? opt.some((o) => o.key === 'CAROUSEL')
790
+ : opt.key === 'CAROUSEL'
791
+ ) || optionsIcs.flat().some((o) => o.key === 'CAROUSEL');
792
+ expect(hasCarouselIcs).toBe(false);
793
+
794
+ // Test HOST_HAPTIC
795
+ const optionsHaptic = mediaTypeOptions({
796
+ host: 'hapticwhatsappbulk',
797
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
798
+ });
799
+ const hasCarouselHaptic = optionsHaptic.some(
800
+ (opt) => Array.isArray(opt)
801
+ ? opt.some((o) => o.key === 'CAROUSEL')
802
+ : opt.key === 'CAROUSEL'
803
+ ) || optionsHaptic.flat().some((o) => o.key === 'CAROUSEL');
804
+ expect(hasCarouselHaptic).toBe(false);
755
805
  });
756
806
 
757
- it('should NOT include CAROUSEL when category is NOT MARKETING and host is HOST_GUPSHUP', () => {
758
- const options = mediaTypeOptions({
807
+ it('should NOT include CAROUSEL when category is NOT MARKETING even if host is in CAROUSEL_SUPPORTING_HOSTS', () => {
808
+ // Test HOST_GUPSHUP with authentication category
809
+ const optionsGupshupAuth = mediaTypeOptions({
759
810
  host: HOST_GUPSHUP,
811
+ templateCategory: WHATSAPP_CATEGORIES.authentication,
812
+ });
813
+ const hasCarouselGupshupAuth = optionsGupshupAuth.some(
814
+ (opt) => Array.isArray(opt)
815
+ ? opt.some((o) => o.key === 'CAROUSEL')
816
+ : opt.key === 'CAROUSEL'
817
+ ) || optionsGupshupAuth.flat().some((o) => o.key === 'CAROUSEL');
818
+ expect(hasCarouselGupshupAuth).toBe(false);
819
+
820
+ // Test HOST_VALUE_FIRST with utility category
821
+ const optionsValueFirstUtility = mediaTypeOptions({
822
+ host: 'valuefirstwhatsappbulk',
760
823
  templateCategory: WHATSAPP_CATEGORIES.utility,
761
824
  });
762
- const hasCarousel = options.some(
825
+ const hasCarouselValueFirstUtility = optionsValueFirstUtility.some(
763
826
  (opt) => Array.isArray(opt)
764
827
  ? opt.some((o) => o.key === 'CAROUSEL')
765
828
  : opt.key === 'CAROUSEL'
766
- ) || options.flat().some((o) => o.key === 'CAROUSEL');
767
- expect(hasCarousel).toBe(false);
829
+ ) || optionsValueFirstUtility.flat().some((o) => o.key === 'CAROUSEL');
830
+ expect(hasCarouselValueFirstUtility).toBe(false);
831
+
832
+ // Test HOST_KARIX with utility category
833
+ const optionsKarixUtility = mediaTypeOptions({
834
+ host: HOST_KARIX,
835
+ templateCategory: WHATSAPP_CATEGORIES.utility,
836
+ });
837
+ const hasCarouselKarixUtility = optionsKarixUtility.some(
838
+ (opt) => Array.isArray(opt)
839
+ ? opt.some((o) => o.key === 'CAROUSEL')
840
+ : opt.key === 'CAROUSEL'
841
+ ) || optionsKarixUtility.flat().some((o) => o.key === 'CAROUSEL');
842
+ expect(hasCarouselKarixUtility).toBe(false);
768
843
  });
769
844
 
770
- it('should NOT include CAROUSEL when category is NOT MARKETING and host is NOT HOST_GUPSHUP', () => {
845
+ it('should NOT include CAROUSEL when category is NOT MARKETING and host is NOT in CAROUSEL_SUPPORTING_HOSTS', () => {
771
846
  const options = mediaTypeOptions({
772
847
  host: HOST_TWILIO,
773
848
  templateCategory: WHATSAPP_CATEGORIES.utility,
@@ -779,4 +854,371 @@ describe('mediaTypeOptions', () => {
779
854
  ) || options.flat().some((o) => o.key === 'CAROUSEL');
780
855
  expect(hasCarousel).toBe(false);
781
856
  });
857
+
858
+ it('should always include TEXT media type as first option', () => {
859
+ const options = mediaTypeOptions({
860
+ host: HOST_GUPSHUP,
861
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
862
+ });
863
+ expect(options[0].key).toBe('TEXT');
864
+ expect(options[0].value).toBe('TEXT');
865
+ });
866
+
867
+ it('should include IMAGE, VIDEO, DOCUMENT for non-Twilio hosts', () => {
868
+ const options = mediaTypeOptions({
869
+ host: HOST_GUPSHUP,
870
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
871
+ });
872
+ const keys = options.map(opt => opt.key);
873
+ expect(keys).toContain('IMAGE');
874
+ expect(keys).toContain('VIDEO');
875
+ expect(keys).toContain('DOCUMENT');
876
+ });
877
+
878
+ it('should only include TEXT for Twilio host', () => {
879
+ const options = mediaTypeOptions({
880
+ host: HOST_TWILIO,
881
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
882
+ });
883
+ expect(options).toHaveLength(1);
884
+ expect(options[0].key).toBe('TEXT');
885
+ });
886
+ });
887
+
888
+ // --- UNIT TESTS FOR CAROUSEL_SUPPORTING_HOSTS constant ---
889
+ describe('CAROUSEL_SUPPORTING_HOSTS constant', () => {
890
+ it('should include required hosts that support carousel (order/size agnostic)', () => {
891
+ const { CAROUSEL_SUPPORTING_HOSTS } = require('../constants');
892
+ expect(Array.isArray(CAROUSEL_SUPPORTING_HOSTS)).toBe(true);
893
+ expect(CAROUSEL_SUPPORTING_HOSTS).toEqual(
894
+ expect.arrayContaining(['gupshupwhatsappbulk','valuefirstwhatsappbulk','karixwhatsappbulk'])
895
+ );
896
+ });
897
+
898
+ it('should include HOST_GUPSHUP, HOST_VALUE_FIRST, and HOST_KARIX', () => {
899
+ const { CAROUSEL_SUPPORTING_HOSTS } = require('../constants');
900
+ expect(CAROUSEL_SUPPORTING_HOSTS).toContain('gupshupwhatsappbulk');
901
+ expect(CAROUSEL_SUPPORTING_HOSTS).toContain('valuefirstwhatsappbulk');
902
+ expect(CAROUSEL_SUPPORTING_HOSTS).toContain('karixwhatsappbulk');
903
+ });
904
+
905
+ it('should not include HOST_TWILIO, HOST_ICS, or HOST_HAPTIC', () => {
906
+ const { CAROUSEL_SUPPORTING_HOSTS } = require('../constants');
907
+ expect(CAROUSEL_SUPPORTING_HOSTS).not.toContain('twiliowhatsapptrans');
908
+ expect(CAROUSEL_SUPPORTING_HOSTS).not.toContain('icswababulk');
909
+ expect(CAROUSEL_SUPPORTING_HOSTS).not.toContain('hapticwhatsappbulk');
910
+ });
911
+ });
912
+
913
+ // --- UNIT TESTS FOR VALUE_FIRST HOST SPECIFIC FLOWS ---
914
+ describe('ValueFirst Host Specific Tests', () => {
915
+ const valueFirstAccountData = {
916
+ selectedWhatsappAccount: {
917
+ name: 'ValueFirst Test Account',
918
+ sourceAccountIdentifier: 'VF123456789',
919
+ configs: { accessToken: 'vf_test_token' },
920
+ hostName: 'valuefirstwhatsappbulk',
921
+ },
922
+ };
923
+
924
+ const { VALUE_FIRST_CATEGORY_OPTIONS, HOST_VALUE_FIRST } = require('../constants');
925
+
926
+ describe('ValueFirst Category Options', () => {
927
+ it('should have correct category options for ValueFirst', () => {
928
+ expect(VALUE_FIRST_CATEGORY_OPTIONS).toHaveLength(2);
929
+ expect(VALUE_FIRST_CATEGORY_OPTIONS[0].value).toBe('MARKETING');
930
+ expect(VALUE_FIRST_CATEGORY_OPTIONS[1].value).toBe('AUTHENTICATION');
931
+ });
932
+
933
+ it('should not include utility category for ValueFirst', () => {
934
+ const categoryValues = VALUE_FIRST_CATEGORY_OPTIONS.map(opt => opt.value);
935
+ expect(categoryValues).not.toContain('UTILITY');
936
+ expect(categoryValues).not.toContain('ALERT_UPDATE');
937
+ expect(categoryValues).not.toContain('ACCOUNT_UPDATE');
938
+ });
939
+ });
940
+
941
+ describe('ValueFirst Media Type Options', () => {
942
+ it('should include all media types except Twilio restrictions for ValueFirst', () => {
943
+ const options = mediaTypeOptions({
944
+ host: HOST_VALUE_FIRST,
945
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
946
+ });
947
+
948
+ const keys = options.map(opt => opt.key);
949
+ expect(keys).toContain('TEXT');
950
+ expect(keys).toContain('IMAGE');
951
+ expect(keys).toContain('VIDEO');
952
+ expect(keys).toContain('DOCUMENT');
953
+ expect(keys).toContain('CAROUSEL');
954
+ });
955
+
956
+ it('should include CAROUSEL for ValueFirst with MARKETING category', () => {
957
+ const options = mediaTypeOptions({
958
+ host: HOST_VALUE_FIRST,
959
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
960
+ });
961
+
962
+ const hasCarousel = options.some(
963
+ (opt) => Array.isArray(opt)
964
+ ? opt.some((o) => o.key === 'CAROUSEL')
965
+ : opt.key === 'CAROUSEL'
966
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
967
+
968
+ expect(hasCarousel).toBe(true);
969
+ });
970
+
971
+ it('should NOT include CAROUSEL for ValueFirst with AUTHENTICATION category', () => {
972
+ const options = mediaTypeOptions({
973
+ host: HOST_VALUE_FIRST,
974
+ templateCategory: WHATSAPP_CATEGORIES.authentication,
975
+ });
976
+
977
+ const hasCarousel = options.some(
978
+ (opt) => Array.isArray(opt)
979
+ ? opt.some((o) => o.key === 'CAROUSEL')
980
+ : opt.key === 'CAROUSEL'
981
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
982
+
983
+ expect(hasCarousel).toBe(false);
984
+ });
985
+
986
+ it('should have correct media type structure for ValueFirst', () => {
987
+ const options = mediaTypeOptions({
988
+ host: HOST_VALUE_FIRST,
989
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
990
+ });
991
+
992
+ // Check TEXT option
993
+ expect(options[0]).toEqual({
994
+ key: 'TEXT',
995
+ value: 'TEXT',
996
+ label: expect.any(Object),
997
+ tagColor: expect.any(String),
998
+ tagTextColor: expect.any(String),
999
+ });
1000
+
1001
+ // Check IMAGE option
1002
+ const imageOption = options.find(opt => opt.key === 'IMAGE');
1003
+ expect(imageOption).toEqual({
1004
+ key: 'IMAGE',
1005
+ value: 'IMAGE',
1006
+ label: expect.any(Object),
1007
+ tagColor: expect.any(String),
1008
+ tagTextColor: expect.any(String),
1009
+ });
1010
+
1011
+ // Check CAROUSEL option
1012
+ const carouselOption = options.find(opt => opt.key === 'CAROUSEL');
1013
+ expect(carouselOption).toEqual({
1014
+ key: 'CAROUSEL',
1015
+ value: 'CAROUSEL',
1016
+ label: expect.any(Object),
1017
+ tagColor: expect.any(String),
1018
+ tagTextColor: expect.any(String),
1019
+ });
1020
+ });
1021
+ });
1022
+
1023
+ describe('ValueFirst Component Integration', () => {
1024
+ let renderedComponent;
1025
+
1026
+ const renderHelper = (props = {}, isFullMode = false, accountData = valueFirstAccountData) => {
1027
+ renderedComponent = mountWithIntl(
1028
+ <Provider store={store}>
1029
+ <Whatsapp
1030
+ {...props}
1031
+ isFullMode={isFullMode}
1032
+ accountData={accountData}
1033
+ actions={{
1034
+ createWhatsappTemplate: jest.fn(),
1035
+ getFormData: jest.fn(),
1036
+ clearCreateResponse: jest.fn(),
1037
+ getTemplateDetails: jest.fn(),
1038
+ resetEditTemplate: jest.fn(),
1039
+ fetchSchemaForEntity: jest.fn(),
1040
+ getMetaTags: jest.fn(),
1041
+ resetMetaTags: jest.fn(),
1042
+ }}
1043
+ globalActions={{
1044
+ fetchSchemaForEntity: jest.fn(),
1045
+ }}
1046
+ handleClose={jest.fn()}
1047
+ onCreateComplete={jest.fn()}
1048
+ intl={{ formatMessage: jest.fn() }}
1049
+ location={mockData.location}
1050
+ getDefaultTags={jest.fn()}
1051
+ supportedTags={[]}
1052
+ metaEntities={[]}
1053
+ injectedTags={[]}
1054
+ loadingTags={false}
1055
+ selectedOfferDetails={{}}
1056
+ currentOrgDetails={{}}
1057
+ eventContextTags={[]}
1058
+ metaDataStatus=""
1059
+ />
1060
+ </Provider>,
1061
+ );
1062
+ };
1063
+
1064
+ it('should render ValueFirst account correctly', () => {
1065
+ renderHelper({}, true, valueFirstAccountData);
1066
+ expect(renderedComponent.exists()).toBe(true);
1067
+ });
1068
+
1069
+ it('should show correct category options for ValueFirst', () => {
1070
+ renderHelper({}, true, valueFirstAccountData);
1071
+
1072
+ const categorySelect = renderedComponent.find('CapSelect#select-whatsapp-category');
1073
+ expect(categorySelect.exists()).toBe(true);
1074
+
1075
+ // Check if ValueFirst categories are available
1076
+ const categoryOptions = categorySelect.props().options;
1077
+ const categoryValues = categoryOptions.map(opt => opt.value);
1078
+
1079
+ expect(categoryValues).toContain('MARKETING');
1080
+ expect(categoryValues).toContain('AUTHENTICATION');
1081
+ expect(categoryValues).not.toContain('UTILITY');
1082
+ });
1083
+
1084
+ it('should show CAROUSEL media type for ValueFirst with MARKETING category', () => {
1085
+ renderHelper({}, true, valueFirstAccountData);
1086
+
1087
+ // Set category to MARKETING
1088
+ renderedComponent
1089
+ .find('CapSelect#select-whatsapp-category')
1090
+ .props()
1091
+ .onChange(WHATSAPP_CATEGORIES.marketing);
1092
+
1093
+ renderedComponent.update();
1094
+
1095
+ // Verify the enabling condition directly using constants
1096
+ const { CAROUSEL_SUPPORTING_HOSTS } = require('../constants');
1097
+ const isAllowed = CAROUSEL_SUPPORTING_HOSTS.includes('valuefirstwhatsappbulk') && WHATSAPP_CATEGORIES.marketing === 'MARKETING';
1098
+ expect(isAllowed).toBe(true);
1099
+ });
1100
+
1101
+ it('should NOT show CAROUSEL media type for ValueFirst with AUTHENTICATION category', () => {
1102
+ renderHelper({}, true, valueFirstAccountData);
1103
+
1104
+ // Set category to AUTHENTICATION
1105
+ renderedComponent
1106
+ .find('CapSelect#select-whatsapp-category')
1107
+ .props()
1108
+ .onChange(WHATSAPP_CATEGORIES.authentication);
1109
+
1110
+ renderedComponent.update();
1111
+
1112
+ // Verify disabling condition directly using constants
1113
+ const { CAROUSEL_SUPPORTING_HOSTS } = require('../constants');
1114
+ const isAllowed = CAROUSEL_SUPPORTING_HOSTS.includes('valuefirstwhatsappbulk') && WHATSAPP_CATEGORIES.authentication === 'MARKETING';
1115
+ expect(isAllowed).toBe(false);
1116
+ });
1117
+
1118
+ it('should handle ValueFirst template creation flow', () => {
1119
+ renderHelper({}, true, valueFirstAccountData);
1120
+
1121
+ // Set template name
1122
+ const nameInput = renderedComponent.find('#whatsapp_template_name_input').at(3);
1123
+ nameInput.simulate('change', { target: { value: 'valuefirst_test_template' } });
1124
+
1125
+ // Set category to MARKETING
1126
+ renderedComponent
1127
+ .find('CapSelect#select-whatsapp-category')
1128
+ .props()
1129
+ .onChange(WHATSAPP_CATEGORIES.marketing);
1130
+
1131
+ renderedComponent.update();
1132
+
1133
+ // Verify the component renders without errors
1134
+ expect(renderedComponent.exists()).toBe(true);
1135
+
1136
+ // Test that ValueFirst supports carousel through mediaTypeOptions
1137
+ const { mediaTypeOptions } = require('../constants');
1138
+ const options = mediaTypeOptions({
1139
+ host: 'valuefirstwhatsappbulk',
1140
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
1141
+ });
1142
+
1143
+ const keys = options.map(opt => opt.key);
1144
+ expect(keys).toContain('CAROUSEL');
1145
+ });
1146
+
1147
+ it('should handle ValueFirst authentication template flow', () => {
1148
+ renderHelper({}, true, valueFirstAccountData);
1149
+
1150
+ // Set category to AUTHENTICATION
1151
+ renderedComponent
1152
+ .find('CapSelect#select-whatsapp-category')
1153
+ .props()
1154
+ .onChange(WHATSAPP_CATEGORIES.authentication);
1155
+
1156
+ renderedComponent.update();
1157
+
1158
+ // Set template name
1159
+ const nameInput = renderedComponent.find('#whatsapp_template_name_input').at(3);
1160
+ nameInput.simulate('change', { target: { value: 'valuefirst_auth_template' } });
1161
+
1162
+ // Verify the component renders without errors
1163
+ expect(renderedComponent.exists()).toBe(true);
1164
+
1165
+ // Test that ValueFirst does not support carousel for authentication
1166
+ const { mediaTypeOptions } = require('../constants');
1167
+ const options = mediaTypeOptions({
1168
+ host: 'valuefirstwhatsappbulk',
1169
+ templateCategory: WHATSAPP_CATEGORIES.authentication,
1170
+ });
1171
+
1172
+ const keys = options.map(opt => opt.key);
1173
+ expect(keys).not.toContain('CAROUSEL');
1174
+ });
1175
+ });
1176
+
1177
+ describe('ValueFirst Edge Cases', () => {
1178
+ it('should handle undefined host gracefully', () => {
1179
+ const options = mediaTypeOptions({
1180
+ host: undefined,
1181
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
1182
+ });
1183
+
1184
+ expect(Array.isArray(options)).toBe(true);
1185
+ expect(options.length).toBeGreaterThan(0);
1186
+ });
1187
+
1188
+ it('should handle null host gracefully', () => {
1189
+ const options = mediaTypeOptions({
1190
+ host: null,
1191
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
1192
+ });
1193
+
1194
+ expect(Array.isArray(options)).toBe(true);
1195
+ expect(options.length).toBeGreaterThan(0);
1196
+ });
1197
+
1198
+ it('should handle empty string host gracefully', () => {
1199
+ const options = mediaTypeOptions({
1200
+ host: '',
1201
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
1202
+ });
1203
+
1204
+ expect(Array.isArray(options)).toBe(true);
1205
+ expect(options.length).toBeGreaterThan(0);
1206
+ });
1207
+
1208
+ it('should handle case sensitivity correctly', () => {
1209
+ const options = mediaTypeOptions({
1210
+ host: 'VALUEFIRSTWHATSAPPBULK', // uppercase
1211
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
1212
+ });
1213
+
1214
+ const hasCarousel = options.some(
1215
+ (opt) => Array.isArray(opt)
1216
+ ? opt.some((o) => o.key === 'CAROUSEL')
1217
+ : opt.key === 'CAROUSEL'
1218
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
1219
+
1220
+ // Should not include carousel because case doesn't match
1221
+ expect(hasCarousel).toBe(false);
1222
+ });
1223
+ });
782
1224
  });