@capillarytech/creatives-library 8.0.65-alpha.0 → 8.0.65-alpha.2

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.65-alpha.0",
4
+ "version": "8.0.65-alpha.2",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -94,9 +94,13 @@ describe("Creatives testing template creation", () => {
94
94
  name: globalMessages.email.defaultMessage,
95
95
  });
96
96
  await userEvent.click(whatsapp);
97
- expect(await creativesScreen.findByText(
98
- /Whatsapp accounts are not setup for your brand/i, undefined, { timeout: 10000 })
99
- ).toBeInTheDocument();
97
+ waitFor(() => {
98
+ expect(
99
+ creativesScreen.getByText(
100
+ /Whatsapp accounts are not setup for your brand/i
101
+ )
102
+ ).toBeInTheDocument();
103
+ }, { timeout: 50000, interval: 500 });
100
104
  await userEvent.click(line);
101
105
  //assertions for template filters for line channel
102
106
  expect(creativesScreen.getByText(/rich video message/i)).toBeInTheDocument();
@@ -980,8 +980,8 @@ Click {{unsubscribe}} to unsubscribe
980
980
  "base": Object {
981
981
  "content": Object {
982
982
  "whatsapp": Object {
983
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
984
- "accountId": "107499611940863",
983
+ "accessToken": "Bearer abcd",
984
+ "accountId": "12345",
985
985
  "buttonType": "CTA",
986
986
  "buttons": Array [
987
987
  Object {
@@ -251,21 +251,25 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
251
251
  this.delayTimer = 0;
252
252
  }
253
253
 
254
+ // This function is to map the selected source account identifier and the connectionProperties data of domainPropertiesData object to get the hostName.
254
255
  getHostName(selectedSourceAccountIdentifier, domainPropertiesData = []) {
255
- if (isEmpty(domainPropertiesData) || !selectedSourceAccountIdentifier) {
256
+ if (!selectedSourceAccountIdentifier || isEmpty(domainPropertiesData)) {
257
+ this.setState({ hostName: '' });
256
258
  return '';
257
259
  }
258
- for (const domainData of domainPropertiesData) {
259
- const { hostName, connectionProperties: { account_sid, wabaId, userid, sourceAccountIdentifier, oa_id } = {}} = domainData?.domainProperties || {};
260
- // If sourceAccountIdentifier is not present in the domainProperties, then it will try to find in account_sid, wabaId, user_id.
261
- // wabaId, user_id is, account_sid are for Karix, Gupshup, and Twilio (Whatsapp) respectively and oa_id is for Zalo.
262
- const sourceAccountIdentifiersArray = [account_sid, wabaId, userid, oa_id, sourceAccountIdentifier];
263
- if (sourceAccountIdentifiersArray.includes(selectedSourceAccountIdentifier)) {
264
- this.setState({hostName});
265
- return hostName;
266
- }
267
- }
268
- };
260
+
261
+ const domainHostName = domainPropertiesData?.find(({ domainProperties }) => {
262
+ const {
263
+ connectionProperties: { account_sid, wabaId, userid, sourceAccountIdentifier, oa_id } = {},
264
+ } = domainProperties || {};
265
+ // If sourceAccountIdentifier is not present in the domainProperties object, then it will try to find in account_sid, wabaId, user_id.
266
+ // wabaId, user_id, account_sid are for Karix, Gupshup, and Twilio (Whatsapp) respectively and oa_id is for Zalo.
267
+ return [account_sid, wabaId, userid, oa_id, sourceAccountIdentifier].includes(selectedSourceAccountIdentifier);
268
+ })?.domainProperties?.hostName || '';
269
+
270
+ this.setState({ hostName: domainHostName });
271
+ return domainHostName;
272
+ }
269
273
 
270
274
  componentWillMount() {
271
275
  if (this.state.channel === '') {
@@ -632,15 +636,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
632
636
  const { weCrmAccounts: weCrmAccountsList = [], senderDetails = {} } = get(nextProps, 'Templates', {});
633
637
  const weCrmChannels = [WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
634
638
 
635
- // Keeping the wechat flow separate as it has different logic for setting the account.
639
+ // Keeping the wechat flow separate as it has different logic for setting the account. Currently we don't support wechat but still keeping the flow.
636
640
  if (weCrmAccountsList?.length === 1 && this.state?.defaultAccount && selectedChannel === WECHAT_LOWERCASE && !isEmpty(senderDetails?.hostName)) {
637
- if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
638
- paramsDefault = {
639
- name: this.state.searchText,
640
- sortBy: this.state.sortBy,
641
- };
642
- }
643
-
644
641
  const { sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
645
642
  const {
646
643
  wecrm_app_id,
@@ -651,13 +648,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
651
648
  wecrmId: wecrm_app_id,
652
649
  wecrmToken: wecrm_token,
653
650
  originalId: sourceAccountIdentifier,
651
+ name: this.state.searchText,
652
+ sortBy: this.state.sortBy,
654
653
  }
655
- nextProps.actions.setWeChatAccount(
656
- weCrmAccountsList[0],
657
- );
658
-
654
+ nextProps.actions.setWeChatAccount(weCrmAccountsList[0]);
659
655
  this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
660
- this.getAllTemplates({ params: paramsDefault }, true);
656
+ this.getAllTemplates({params: paramsDefault}, true);
661
657
  }
662
658
 
663
659
  if (weCrmAccountsList?.length && this.state?.defaultAccount && (weCrmChannels.includes(selectedChannel))) {
@@ -666,14 +662,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
666
662
  const hostName = this.getHostName(isSingleAccount ? weCrmAccountsList[0]?.sourceAccountIdentifier : selectedAccount?.sourceAccountIdentifier, senderDetails?.domainProperties);
667
663
 
668
664
  if (!isEmpty(hostName)) {
669
- let paramsDefault = {};
670
- if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
671
- paramsDefault = {
672
- name: this.state.searchText,
673
- sortBy: this.state.sortBy,
674
- };
675
- }
676
-
665
+ const paramsDefault = {};
677
666
  const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
678
667
  if (isSingleAccount) {
679
668
  weCrmAccountsList[0].hostName = hostName;
@@ -690,14 +679,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
690
679
  if (selectedChannel === WHATSAPP_LOWERCASE) {
691
680
  paramsDefault.accountId = sourceAccountIdentifier;
692
681
  paramsDefault.host = hostName || this.props.Templates?.selectedWhatsappAccount?.hostName;
682
+ paramsDefault.name = this.state.searchText;
683
+ paramsDefault.sortBy = this.state.sortBy;
693
684
  }
694
- this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: isSingleAccount ? weCrmAccountsList[0]?.name : selectedAccount?.name });
685
+ this.setState({ defaultAccount: false });
695
686
  /**
696
687
  * Incase of multiple accounts, getAllTemplates is called on selecting the account. It's handled in onAccountSelect function.
697
688
  * But for single account, onAccountSelect function won't get executed and getAllTemplates will be excuted.
698
689
  */
699
690
  if (weCrmAccountsList?.length === 1) {
700
- this.getAllTemplates({params: paramsDefault}, true);
691
+ this.getAllTemplates({ params: paramsDefault }, true);
701
692
  }
702
693
  }
703
694
  }
@@ -774,11 +765,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
774
765
  }
775
766
  }
776
767
 
777
- // Always set activeMode before getAllTemplates call
778
768
  this.setState({ activeMode: TEMPLATES_MODE }, () => {
779
769
  // Restrict getAllTemplates call only if selectedChannel is ZALO or WHATSAPP and hostName is empty
780
770
  if (!(isZaloOrWhatsapp && !params?.host)) {
781
- console.log(">>> GETALLTEMPLATES onaccount select ", { params });
782
771
  this.getAllTemplates({ params, resetPage: true });
783
772
  }
784
773
  });
@@ -1457,17 +1446,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1457
1446
  const accounts = get(this.props, 'Templates.weCrmAccounts');
1458
1447
  const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates) || !this.state.hostName;
1459
1448
  const noFilteredWhatsappZaloTemplates = this.isFullMode() && !isEmpty(templates) && isEmpty(filteredTemplates);
1460
- const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates);
1461
- const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state.hostName ;
1449
+ const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates) && !isEmpty(this.state?.hostName);;
1450
+ const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state?.hostName ;
1462
1451
  const showZaloIllustration = !isEmpty(this.props.Templates.selectedZaloAccount) && [ZALO_LOWERCASE].includes(channelLowerCase);
1463
1452
  const showRcsIllustration = channelLowerCase === RCS_LOWERCASE && isEmpty(templates);
1464
1453
  const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
1465
1454
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
1466
- console.log(">>> state ", {showWhatsappIllustration, showZaloIllustration, noLoaderAndSearchText, noApprovedWhatsappZaloTemplates, noFilteredWhatsappZaloTemplates, noWhatsappZaloTemplates, channelLowerCase, host: this.state.hostName, templates: this.props.Templates,
1467
- mp: (["mobilepush"].includes(this.state.channel.toLowerCase()) &&
1468
- isEmpty(filteredTemplates) &&
1469
- isEmpty(this.state.searchText))
1470
- })
1471
1455
  return (<div>
1472
1456
  {[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
1473
1457
  {filterContent}
@@ -2665,7 +2649,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2665
2649
  channel = channel.toUpperCase();
2666
2650
  const { Templates: templates = {}, location = {} } = this.props;
2667
2651
  const { query = {} } = location;
2668
- const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {} } = templates;
2652
+ const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {}, senderDetails } = templates;
2669
2653
  const isWechatChannel = channel === WECHAT;
2670
2654
  const isMobilePushChannel = channel === MOBILE_PUSH;
2671
2655
  const isInAppChannel = channel === INAPP;
@@ -2755,6 +2739,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2755
2739
  break;
2756
2740
  }
2757
2741
  let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
2742
+ // Zalo and Whatsapp has dependencies on domainProperties to get the hostName. Show loader until the domainProperties are fetched.
2743
+ const isDomainPropertiesLoading = [WHATSAPP, ZALO].includes(channel) && senderDetails?.status === "REQUEST";
2758
2744
  if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
2759
2745
  const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
2760
2746
  const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
@@ -2773,7 +2759,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2773
2759
  if (channel === WECHAT && !commonUtil.hasWechatFeatureEnabled()) {
2774
2760
  showNoAccountHeader = true;
2775
2761
  }
2776
- return (<CapSkeleton loading={fetchingWeCrmAccounts} active paragraph={{ rows: 10 }}>
2762
+ return (<CapSkeleton loading={fetchingWeCrmAccounts || isDomainPropertiesLoading} active paragraph={{ rows: 10 }}>
2777
2763
  {showNoAccountHeader ? <FormattedMessage {...noAccountHeader} /> :
2778
2764
  <div style={{ overflowX: "auto", paddingBottom: CAP_SPACE_16 }}>
2779
2765
  <CapHeader
@@ -10,11 +10,49 @@ exports[`Test Templates container Should render correct component for whatsapp c
10
10
  }
11
11
  }
12
12
  >
13
- <FormattedMessage
14
- defaultMessage="Whatsapp accounts are not setup for your brand"
15
- id="creatives.containersV2.Templates.noAccountsPresentWhatsapp"
16
- values={Object {}}
17
- />
13
+ <div
14
+ style={
15
+ Object {
16
+ "overflowX": "auto",
17
+ "paddingBottom": "1.142rem",
18
+ }
19
+ }
20
+ >
21
+ <CapHeader
22
+ className="select-account-header"
23
+ description="Choose the account to send content"
24
+ descriptionClass=""
25
+ inline={false}
26
+ size="regular"
27
+ title="Whatsapp account"
28
+ titleClass=""
29
+ />
30
+ <CapRadioCard
31
+ cardHeight="48px"
32
+ cardWidth="276px"
33
+ className="select-account"
34
+ defaultValue=""
35
+ onChange={[Function]}
36
+ panes={
37
+ Array [
38
+ Object {
39
+ "icon": <CapIconAvatar
40
+ backgroundProps={Object {}}
41
+ height="2rem"
42
+ labelProps={Object {}}
43
+ text="W"
44
+ width="auto"
45
+ />,
46
+ "key": "abc12",
47
+ "title": "WhatsappAccount",
48
+ "value": "WhatsappAccount",
49
+ },
50
+ ]
51
+ }
52
+ selected=""
53
+ size="small"
54
+ />
55
+ </div>
18
56
  </CapSkeleton>
19
57
  `;
20
58
 
@@ -190,6 +228,30 @@ exports[`Test Templates container Should render temlates when whatsapp templates
190
228
  templateInProgress={false}
191
229
  >
192
230
  <div>
231
+ <CapHeader
232
+ description={
233
+ <React.Fragment>
234
+ <CapHeading
235
+ type="h3"
236
+ >
237
+
238
+
239
+
240
+ </CapHeading>
241
+ </React.Fragment>
242
+ }
243
+ descriptionClass=""
244
+ inline={false}
245
+ size="regular"
246
+ title={
247
+ <CapHeading
248
+ type="h4"
249
+ >
250
+ Whatsapp account
251
+ </CapHeading>
252
+ }
253
+ titleClass=""
254
+ />
193
255
  <div
194
256
  className="action-container"
195
257
  >
@@ -423,6 +485,30 @@ exports[`Test Templates container Should render temlates when whatsapp templates
423
485
  templateInProgress={false}
424
486
  >
425
487
  <div>
488
+ <CapHeader
489
+ description={
490
+ <React.Fragment>
491
+ <CapHeading
492
+ type="h3"
493
+ >
494
+
495
+
496
+
497
+ </CapHeading>
498
+ </React.Fragment>
499
+ }
500
+ descriptionClass=""
501
+ inline={false}
502
+ size="regular"
503
+ title={
504
+ <CapHeading
505
+ type="h4"
506
+ >
507
+ Whatsapp account
508
+ </CapHeading>
509
+ }
510
+ titleClass=""
511
+ />
426
512
  <div
427
513
  className="action-container"
428
514
  >
@@ -782,6 +868,30 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
782
868
  templateInProgress={false}
783
869
  >
784
870
  <div>
871
+ <CapHeader
872
+ description={
873
+ <React.Fragment>
874
+ <CapHeading
875
+ type="h3"
876
+ >
877
+
878
+
879
+
880
+ </CapHeading>
881
+ </React.Fragment>
882
+ }
883
+ descriptionClass=""
884
+ inline={false}
885
+ size="regular"
886
+ title={
887
+ <CapHeading
888
+ type="h4"
889
+ >
890
+ Whatsapp account
891
+ </CapHeading>
892
+ }
893
+ titleClass=""
894
+ />
785
895
  <div
786
896
  className="action-container"
787
897
  >
@@ -1100,8 +1210,8 @@ Click {{unsubscribe}} to unsubscribe
1100
1210
  "base": Object {
1101
1211
  "content": Object {
1102
1212
  "whatsapp": Object {
1103
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
1104
- "accountId": "107499611940863",
1213
+ "accessToken": "Bearer abcd",
1214
+ "accountId": "12345",
1105
1215
  "buttonType": "CTA",
1106
1216
  "buttons": Array [
1107
1217
  Object {
@@ -1237,6 +1347,30 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
1237
1347
  templateInProgress={false}
1238
1348
  >
1239
1349
  <div>
1350
+ <CapHeader
1351
+ description={
1352
+ <React.Fragment>
1353
+ <CapHeading
1354
+ type="h3"
1355
+ >
1356
+
1357
+
1358
+
1359
+ </CapHeading>
1360
+ </React.Fragment>
1361
+ }
1362
+ descriptionClass=""
1363
+ inline={false}
1364
+ size="regular"
1365
+ title={
1366
+ <CapHeading
1367
+ type="h4"
1368
+ >
1369
+ Whatsapp account
1370
+ </CapHeading>
1371
+ }
1372
+ titleClass=""
1373
+ />
1240
1374
  <div
1241
1375
  className="action-container"
1242
1376
  >
@@ -1537,8 +1671,8 @@ Click {{unsubscribe}} to unsubscribe
1537
1671
  "base": Object {
1538
1672
  "content": Object {
1539
1673
  "whatsapp": Object {
1540
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
1541
- "accountId": "107499611940863",
1674
+ "accessToken": "Bearer abcd",
1675
+ "accountId": "12345",
1542
1676
  "buttonType": "CTA",
1543
1677
  "buttons": Array [
1544
1678
  Object {
@@ -1674,6 +1808,30 @@ exports[`Test Templates container Test max templates warning 1`] = `
1674
1808
  templateInProgress={false}
1675
1809
  >
1676
1810
  <div>
1811
+ <CapHeader
1812
+ description={
1813
+ <React.Fragment>
1814
+ <CapHeading
1815
+ type="h3"
1816
+ >
1817
+
1818
+
1819
+
1820
+ </CapHeading>
1821
+ </React.Fragment>
1822
+ }
1823
+ descriptionClass=""
1824
+ inline={false}
1825
+ size="regular"
1826
+ title={
1827
+ <CapHeading
1828
+ type="h4"
1829
+ >
1830
+ Whatsapp account
1831
+ </CapHeading>
1832
+ }
1833
+ titleClass=""
1834
+ />
1677
1835
  <div
1678
1836
  className="action-container"
1679
1837
  >
@@ -1974,8 +2132,8 @@ Click {{unsubscribe}} to unsubscribe
1974
2132
  "base": Object {
1975
2133
  "content": Object {
1976
2134
  "whatsapp": Object {
1977
- "accessToken": "Bearer gDwEuRIm9icV6phixociSw==",
1978
- "accountId": "107499611940863",
2135
+ "accessToken": "Bearer abcd",
2136
+ "accountId": "12345",
1979
2137
  "buttonType": "CTA",
1980
2138
  "buttons": Array [
1981
2139
  Object {
@@ -2111,6 +2269,30 @@ exports[`Test Templates container Test removing all whatsapp filterss 1`] = `
2111
2269
  templateInProgress={false}
2112
2270
  >
2113
2271
  <div>
2272
+ <CapHeader
2273
+ description={
2274
+ <React.Fragment>
2275
+ <CapHeading
2276
+ type="h3"
2277
+ >
2278
+
2279
+
2280
+
2281
+ </CapHeading>
2282
+ </React.Fragment>
2283
+ }
2284
+ descriptionClass=""
2285
+ inline={false}
2286
+ size="regular"
2287
+ title={
2288
+ <CapHeading
2289
+ type="h4"
2290
+ >
2291
+ Whatsapp account
2292
+ </CapHeading>
2293
+ }
2294
+ titleClass=""
2295
+ />
2114
2296
  <div
2115
2297
  className="action-container"
2116
2298
  >
@@ -2370,6 +2552,30 @@ exports[`Test Templates container Test removing all whatsapp filterss 2`] = `
2370
2552
  templateInProgress={false}
2371
2553
  >
2372
2554
  <div>
2555
+ <CapHeader
2556
+ description={
2557
+ <React.Fragment>
2558
+ <CapHeading
2559
+ type="h3"
2560
+ >
2561
+
2562
+
2563
+
2564
+ </CapHeading>
2565
+ </React.Fragment>
2566
+ }
2567
+ descriptionClass=""
2568
+ inline={false}
2569
+ size="regular"
2570
+ title={
2571
+ <CapHeading
2572
+ type="h4"
2573
+ >
2574
+ Whatsapp account
2575
+ </CapHeading>
2576
+ }
2577
+ titleClass=""
2578
+ />
2373
2579
  <div
2374
2580
  className="action-container"
2375
2581
  >
@@ -2603,6 +2809,30 @@ exports[`Test Templates container Test removing single filter 1`] = `
2603
2809
  templateInProgress={false}
2604
2810
  >
2605
2811
  <div>
2812
+ <CapHeader
2813
+ description={
2814
+ <React.Fragment>
2815
+ <CapHeading
2816
+ type="h3"
2817
+ >
2818
+
2819
+
2820
+
2821
+ </CapHeading>
2822
+ </React.Fragment>
2823
+ }
2824
+ descriptionClass=""
2825
+ inline={false}
2826
+ size="regular"
2827
+ title={
2828
+ <CapHeading
2829
+ type="h4"
2830
+ >
2831
+ Whatsapp account
2832
+ </CapHeading>
2833
+ }
2834
+ titleClass=""
2835
+ />
2606
2836
  <div
2607
2837
  className="action-container"
2608
2838
  >
@@ -72,3 +72,34 @@ export const getAllTemplatesListFailure = {
72
72
  "message": "Resource Not Found",
73
73
  "error": {},
74
74
  };
75
+
76
+ export const senderDetailsWhatsapp = {
77
+ channel: "WHATSAPP",
78
+ domainProperties: {
79
+ connectionProperties: {
80
+ account_sid: "testSourceAccount",
81
+ wabaId: "testSourceAccount",
82
+ userid: "testSourceAccount",
83
+ sourceAccountIdentifier: "testSourceAccount",
84
+ },
85
+ hostname: "testWhatsappHost",
86
+ },
87
+ };
88
+
89
+ export const senderDetailsZalo = {
90
+ channel: "ZALO",
91
+ domainProperties: {
92
+ connectionProperties: {
93
+ oa_id: "testSourceAccount",
94
+ sourceAccountIdentifier: "testSourceAccount",
95
+ },
96
+ hostname: "testZaloHost",
97
+ },
98
+ };
99
+
100
+ export const senderDetailsSMS = {
101
+ channel: "SMS",
102
+ hostName: "TestSMSHost",
103
+ };
104
+
105
+ export const errorMessage = ["Error fetching sender details"];
@@ -48,3 +48,63 @@ describe("test reducer", () => {
48
48
  });
49
49
  });
50
50
  });
51
+
52
+
53
+ describe("test reducer - sender details", () => {
54
+ afterEach(() => {
55
+ jest.clearAllMocks();
56
+ });
57
+
58
+ it("should handle GET_SENDER_DETAILS_REQUEST", () => {
59
+ const action = { type: types.GET_SENDER_DETAILS_REQUEST };
60
+ expect(reducer(initialState, action).toJS()).toEqual({
61
+ ...initialState.toJS(),
62
+ senderDetails: { status: "REQUEST" },
63
+ });
64
+ });
65
+
66
+ it("should handle GET_SENDER_DETAILS_SUCCESS for WHATSAPP (multi-account channel)", () => {
67
+ const action = {
68
+ type: types.GET_SENDER_DETAILS_SUCCESS,
69
+ payload: mockData.senderDetailsWhatsapp,
70
+ };
71
+ expect(reducer(initialState, action).toJS()).toEqual({
72
+ ...initialState.toJS(),
73
+ senderDetails: {
74
+ status: "SUCCESS",
75
+ domainProperties: mockData.senderDetailsWhatsapp.domainProperties,
76
+ errors: [],
77
+ },
78
+ });
79
+ });
80
+
81
+ it("should handle GET_SENDER_DETAILS_SUCCESS for non-multi-account channel", () => {
82
+ const action = {
83
+ type: types.GET_SENDER_DETAILS_SUCCESS,
84
+ payload: mockData.senderDetailsSMS.hostName,
85
+ };
86
+ expect(reducer(initialState, action).toJS()).toEqual({
87
+ ...initialState.toJS(),
88
+ senderDetails: {
89
+ status: "SUCCESS",
90
+ hostName: mockData.senderDetailsSMS.hostName,
91
+ errors: [],
92
+ },
93
+ });
94
+ });
95
+
96
+ it("should handle GET_SENDER_DETAILS_FAILURE", () => {
97
+ const action = {
98
+ type: types.GET_SENDER_DETAILS_FAILURE,
99
+ payload: mockData.errorMessage,
100
+ };
101
+ expect(reducer(initialState, action).toJS()).toEqual({
102
+ ...initialState.toJS(),
103
+ senderDetails: {
104
+ status: "FAILURE",
105
+ hostName: "",
106
+ errors: mockData.errorMessage,
107
+ },
108
+ });
109
+ });
110
+ });
@@ -12,15 +12,15 @@ export default {
12
12
  isActive: true,
13
13
  sourceTypeId: 19,
14
14
  configs: {
15
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
15
+ accessToken: "Bearer abcd",
16
16
  promotionalMessagingSSID: "",
17
17
  transactionalMessagingSSID: "",
18
18
  },
19
19
  hostName: "karixwhatsappbulk",
20
20
  toMirror: true,
21
21
  id: 12721,
22
- uuid: "93c52a35824a4bea8650d7d0232b2e3c",
23
- sourceAccountIdentifier: "107499611940863",
22
+ uuid: "abc12",
23
+ sourceAccountIdentifier: "12345",
24
24
  commChannels: ["whatsapp"],
25
25
  },
26
26
  getAllTemplatesInProgress: false,
@@ -28,6 +28,114 @@ export default {
28
28
  weCRMtemplates: [],
29
29
  senderDetails: {
30
30
  status: "SUCCESS",
31
+ domainProperties: [
32
+ {
33
+ "id": 249341,
34
+ "orgId": 50074,
35
+ "label": "",
36
+ "domainProperties": {
37
+ "id": 3972,
38
+ "domainName": "whatsapp_mobile_push",
39
+ "description": "whatsapp_mobile_push_karix",
40
+ "contactInfo": [
41
+ {
42
+ "id": 100776,
43
+ "domainPropId": 3972,
44
+ "messageClass": "WHATSAPP",
45
+ "type": "gsm_sender_id",
46
+ "label": "whatsapptesting",
47
+ "value": "919611759663",
48
+ "valid": true,
49
+ "default": true
50
+ },
51
+ {
52
+ "id": 102485,
53
+ "domainPropId": 3972,
54
+ "messageClass": "WHATSAPP",
55
+ "type": "cdma_sender_id",
56
+ "label": "whatsapptesting",
57
+ "value": "919611759663",
58
+ "valid": true,
59
+ "default": true
60
+ },
61
+ {
62
+ "id": 102486,
63
+ "domainPropId": 3972,
64
+ "messageClass": "WHATSAPP",
65
+ "type": "cdma_sender_id",
66
+ "label": "not_working",
67
+ "value": "919876543210",
68
+ "valid": true,
69
+ "default": false
70
+ },
71
+ {
72
+ "id": 102487,
73
+ "domainPropId": 3972,
74
+ "messageClass": "WHATSAPP",
75
+ "type": "gsm_sender_id",
76
+ "label": "not_working",
77
+ "value": "919876543210",
78
+ "valid": true,
79
+ "default": false
80
+ }
81
+ ],
82
+ "xengageEnabled": false,
83
+ "connectionProperties": {
84
+ "919611759663_whatsapp_pool_id": "CAP001",
85
+ "authToken": "Bearer abcd",
86
+ "sourceAccountIdentifier": "12345",
87
+ "wabaId": "12345",
88
+ "whatsapp_pool_id": "CAP001"
89
+ },
90
+ "hostName": "karixwhatsappbulk"
91
+ },
92
+ "priority": 1,
93
+ "valid": true
94
+ },
95
+ {
96
+ "id": 276278,
97
+ "orgId": 50074,
98
+ "label": "",
99
+ "domainProperties": {
100
+ "id": 4294,
101
+ "domainName": "gupshup",
102
+ "description": "gupshup whatsapp test",
103
+ "contactInfo": [
104
+ {
105
+ "id": 101616,
106
+ "domainPropId": 4294,
107
+ "messageClass": "WHATSAPP",
108
+ "type": "gsm_sender_id",
109
+ "label": "gupshup test",
110
+ "value": "gupshuptest",
111
+ "description": "",
112
+ "valid": true,
113
+ "default": true
114
+ },
115
+ {
116
+ "id": 101617,
117
+ "domainPropId": 4294,
118
+ "messageClass": "WHATSAPP",
119
+ "type": "cdma_sender_id",
120
+ "label": "gupshupt est",
121
+ "value": "gupshuptest",
122
+ "description": "",
123
+ "valid": true,
124
+ "default": true
125
+ }
126
+ ],
127
+ "xengageEnabled": false,
128
+ "connectionProperties": {
129
+ "password": "qrtCAJCz",
130
+ "sourceAccountIdentifier": "123456",
131
+ "userid": "123456"
132
+ },
133
+ "hostName": "gupshupwhatsappbulk"
134
+ },
135
+ "priority": 1,
136
+ "valid": true
137
+ },
138
+ ],
31
139
  hostName: "karixwhatsappbulk",
32
140
  errors: [],
33
141
  },
@@ -42,14 +150,14 @@ export default {
42
150
  isActive: true,
43
151
  sourceTypeId: 19,
44
152
  configs: {
45
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
153
+ accessToken: "Bearer abcd",
46
154
  promotionalMessagingSSID: "",
47
155
  transactionalMessagingSSID: "",
48
156
  },
49
157
  toMirror: true,
50
158
  id: 12721,
51
- uuid: "93c52a35824a4bea8650d7d0232b2e3c",
52
- sourceAccountIdentifier: "107499611940863",
159
+ uuid: "abc12",
160
+ sourceAccountIdentifier: "12345",
53
161
  commChannels: ["whatsapp"],
54
162
  },
55
163
  ],
@@ -68,8 +176,8 @@ export default {
68
176
  status: "pending",
69
177
  templateId: "720951875646523",
70
178
  hostName: "karixwhatsappbulk",
71
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
72
- accountId: "107499611940863",
179
+ accessToken: "Bearer abcd",
180
+ accountId: "12345",
73
181
  templateEditor: false,
74
182
  karixFileHandle:
75
183
  "4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y",
@@ -124,8 +232,8 @@ export default {
124
232
  status: "pending",
125
233
  templateId: "4916570121786087",
126
234
  hostName: "karixwhatsappbulk",
127
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
128
- accountId: "107499611940863",
235
+ accessToken: "Bearer abcd",
236
+ accountId: "12345",
129
237
  templateEditor: false,
130
238
  karixFileHandle:
131
239
  "4::aW1hZ2UvanBlZw==:ARY0H4Z85fo_TTfmAYJpqpnSbBlE3VaIYyr9S_Exg7GV_EhOo-30AVAoe35d0ZH8Cx5ZaJ3U2RovzzqVHPUnMK_7wFY7RNngsTwWc4vnZ7bMoA:e:1658404539:259409122277300:100066839164237:ARaPlACD4a5lw9Wp4X4",
@@ -173,8 +281,8 @@ export default {
173
281
  status: "pending",
174
282
  templateId: "732848961277130",
175
283
  hostName: "karixwhatsappbulk",
176
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
177
- accountId: "107499611940863",
284
+ accessToken: "Bearer abcd",
285
+ accountId: "12345",
178
286
  templateEditor: false,
179
287
  karixFileHandle:
180
288
  "4::aW1hZ2UvanBlZw==:ARYfsmvPHCeI0Q3ixfzpZ3gOIoYjrkx6STalsi58_twFIqB5rvPKsKPH7yL_eXMfbmXGq_X0qiLrL7FaSSFq_uzudytfoOj9Oh5ueb1uUV367A:e:1658404470:259409122277300:100066839164237:ARaaojq13hSRpe7h0Tw",
@@ -223,8 +331,8 @@ export default {
223
331
  status: "pending",
224
332
  templateId: "993272384701160",
225
333
  hostName: "karixwhatsappbulk",
226
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
227
- accountId: "107499611940863",
334
+ accessToken: "Bearer abcd",
335
+ accountId: "12345",
228
336
  templateEditor: false,
229
337
  karixFileHandle:
230
338
  "4::aW1hZ2UvanBlZw==:ARa6WKa8LHjcJf2DBWokWtAvxkowam2zBaUJvEwxyWH2EamzQv7-GlX7bsf6IKkdWKLAATpfo_vkAgQ8mWLf2wvVNEVBmPWk3yyrWDnVI44_9A:e:1658404412:259409122277300:100066839164237:ARYyRilqCb6hSKHtjYQ",
@@ -264,8 +372,8 @@ export default {
264
372
  status: "pending",
265
373
  templateId: "1838206886365227",
266
374
  hostName: "karixwhatsappbulk",
267
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
268
- accountId: "107499611940863",
375
+ accessToken: "Bearer abcd",
376
+ accountId: "12345",
269
377
  templateEditor: false,
270
378
  mediaType: "TEXT",
271
379
  languages: [
@@ -301,8 +409,8 @@ export default {
301
409
  status: "pending",
302
410
  templateId: "412858944197174",
303
411
  hostName: "karixwhatsappbulk",
304
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
305
- accountId: "107499611940863",
412
+ accessToken: "Bearer abcd",
413
+ accountId: "12345",
306
414
  templateEditor: false,
307
415
  mediaType: "TEXT",
308
416
  languages: [
@@ -1150,7 +1258,7 @@ export default {
1150
1258
  channel: "EMAIL",
1151
1259
  validity: true,
1152
1260
  },
1153
- getWhatsappContentOutput: "1234567890\nClick {{unsubscribe}} to unsubscribe",
1261
+ getWhatsappContentOutput: "123450\nClick {{unsubscribe}} to unsubscribe",
1154
1262
  getWhatsappStatusOutput1: {
1155
1263
  key: "approved",
1156
1264
  label: (
@@ -1216,8 +1324,8 @@ export default {
1216
1324
  status: "approved",
1217
1325
  templateId: "720951875646523",
1218
1326
  hostName: "karixwhatsappbulk",
1219
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
1220
- accountId: "107499611940863",
1327
+ accessToken: "Bearer abcd",
1328
+ accountId: "12345",
1221
1329
  templateEditor: false,
1222
1330
  karixFileHandle:
1223
1331
  "4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y",
@@ -1274,8 +1382,8 @@ export default {
1274
1382
  status: "approved",
1275
1383
  templateId: "720951875646523",
1276
1384
  hostName: "karixwhatsappbulk",
1277
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
1278
- accountId: "107499611940863",
1385
+ accessToken: "Bearer abcd",
1386
+ accountId: "12345",
1279
1387
  templateEditor: false,
1280
1388
  karixFileHandle:
1281
1389
  "4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y",
@@ -1334,8 +1442,8 @@ export default {
1334
1442
  status: "approved",
1335
1443
  templateId: "720951875646523",
1336
1444
  hostName: "karixwhatsappbulk",
1337
- accessToken: "Bearer gDwEuRIm9icV6phixociSw==",
1338
- accountId: "107499611940863",
1445
+ accessToken: "Bearer abcd",
1446
+ accountId: "12345",
1339
1447
  templateEditor: false,
1340
1448
  karixFileHandle:
1341
1449
  "4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y",