@capillarytech/creatives-library 8.0.206 → 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 +2 -1
- package/package.json +1 -1
- package/services/api.js +2 -0
- package/v2Containers/Assets/images/facebookIllustration.svg +23 -0
- package/v2Containers/Assets/images/lineIllustration.svg +87 -0
- package/v2Containers/Assets/images/viberIllustration.svg +60 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +2 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +188 -0
- package/v2Containers/Templates/index.js +9 -113
- package/v2Containers/Templates/messages.js +24 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +323 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +130 -0
- package/v2Containers/Templates/tests/index.test.js +45 -83
- package/v2Containers/Whatsapp/constants.js +26 -2
- package/v2Containers/Whatsapp/index.js +4 -1
- package/v2Containers/Whatsapp/tests/index.test.js +460 -18
|
@@ -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
|
|
732
|
-
|
|
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
|
|
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
|
-
) ||
|
|
741
|
-
expect(
|
|
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
|
|
745
|
-
|
|
746
|
-
|
|
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
|
|
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
|
-
) ||
|
|
754
|
-
expect(
|
|
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
|
|
758
|
-
|
|
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
|
|
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
|
-
) ||
|
|
767
|
-
expect(
|
|
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
|
|
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
|
});
|