@capillarytech/creatives-library 9.2.3 → 9.2.4-alpha.feature-rcs-multi-account.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +9 -0
  3. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +44 -3
  4. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +14 -0
  5. package/v2Components/CommonTestAndPreview/SendTestMessage.js +14 -0
  6. package/v2Components/CommonTestAndPreview/index.js +118 -11
  7. package/v2Components/CommonTestAndPreview/reducer.js +8 -2
  8. package/v2Components/CommonTestAndPreview/selectors.js +6 -0
  9. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +11 -0
  10. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +92 -0
  11. package/v2Components/CommonTestAndPreview/tests/index.test.js +200 -0
  12. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +4 -0
  13. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +10 -0
  14. package/v2Components/TestAndPreviewSlidebox/index.js +8 -0
  15. package/v2Containers/CommunicationFlow/CommunicationFlow.js +9 -1
  16. package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +76 -1
  17. package/v2Containers/CommunicationFlow/messages.js +12 -0
  18. package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +5 -0
  19. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +195 -19
  20. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +37 -4
  21. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +360 -0
  22. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +25 -0
  23. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +80 -0
  24. package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +39 -8
  25. package/v2Containers/CreativesContainer/index.js +24 -0
  26. package/v2Containers/CreativesContainer/tests/index.test.js +82 -0
  27. package/v2Containers/Rcs/accountUtils.js +126 -0
  28. package/v2Containers/Rcs/index.js +30 -4
  29. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +108 -0
  30. package/v2Containers/Rcs/tests/accountUtils.test.js +178 -0
  31. package/v2Containers/Rcs/tests/testAndPreviewAccount.test.js +193 -0
  32. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +27 -0
  33. package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
  34. package/v2Containers/Templates/index.js +10 -5
  35. package/v2Containers/Templates/messages.js +4 -0
  36. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
  37. package/v2Containers/Templates/tests/index.test.js +112 -0
  38. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
@@ -0,0 +1,178 @@
1
+ import {
2
+ isRcsAccountForAccountId,
3
+ findRcsAccountByAccountId,
4
+ pickRcsDomainForAccount,
5
+ isRcsAccountNotConfigured,
6
+ getRcsDomainsForAccount,
7
+ getParsedRcsDomainAccountId,
8
+ getRcsAccountIdFromCreativeForm,
9
+ resolveRcsAccountKey,
10
+ RCS_ACCOUNT_UNAVAILABLE,
11
+ } from '../accountUtils';
12
+
13
+ const getDomainAccountId = (domain) => domain?.sourceAccountIdentifier;
14
+
15
+ describe('Rcs/accountUtils', () => {
16
+ describe('isRcsAccountForAccountId', () => {
17
+ const account = { id: 101, sourceAccountIdentifier: 'acc-A' };
18
+
19
+ it('matches sourceAccountIdentifier or WeCRM id', () => {
20
+ expect(isRcsAccountForAccountId(account, 'acc-A')).toBe(true);
21
+ expect(isRcsAccountForAccountId(account, 101)).toBe(true);
22
+ expect(isRcsAccountForAccountId(account, '101')).toBe(true);
23
+ expect(isRcsAccountForAccountId(account, ' acc-A ')).toBe(true);
24
+ });
25
+
26
+ it('does not match a different id', () => {
27
+ expect(isRcsAccountForAccountId(account, 'acc-B')).toBe(false);
28
+ });
29
+
30
+ it('returns false for empty id or account', () => {
31
+ expect(isRcsAccountForAccountId(account, '')).toBe(false);
32
+ expect(isRcsAccountForAccountId(account, undefined)).toBe(false);
33
+ expect(isRcsAccountForAccountId(null, 'acc-A')).toBe(false);
34
+ });
35
+ });
36
+
37
+ describe('findRcsAccountByAccountId', () => {
38
+ const accounts = [{ id: 13750, sourceAccountIdentifier: 'acc-A' }, { id: 13751, sourceAccountIdentifier: 'acc-B' }];
39
+
40
+ it('finds the account by WeCRM id (library-mode saved accountId)', () => {
41
+ expect(findRcsAccountByAccountId(accounts, 13751)).toBe(accounts[1]);
42
+ expect(findRcsAccountByAccountId(accounts, '13750')).toBe(accounts[0]);
43
+ });
44
+
45
+ it('finds the account by sourceAccountIdentifier', () => {
46
+ expect(findRcsAccountByAccountId(accounts, 'acc-B')).toBe(accounts[1]);
47
+ });
48
+
49
+ it('returns null when nothing matches or input is missing', () => {
50
+ expect(findRcsAccountByAccountId(accounts, 99)).toBeNull();
51
+ expect(findRcsAccountByAccountId(accounts, '')).toBeNull();
52
+ expect(findRcsAccountByAccountId(null, 13750)).toBeNull();
53
+ });
54
+ });
55
+
56
+ describe('pickRcsDomainForAccount', () => {
57
+ const domainA = { domainId: 1, sourceAccountIdentifier: 'acc-A' };
58
+ const domainB = { domainId: 2, sourceAccountIdentifier: 'acc-B' };
59
+
60
+ it('picks the domain of the account', () => {
61
+ expect(pickRcsDomainForAccount([domainA, domainB], 'acc-B', getDomainAccountId)).toBe(domainB);
62
+ expect(pickRcsDomainForAccount([domainA, domainB], ' acc-A ', getDomainAccountId)).toBe(domainA);
63
+ });
64
+
65
+ it('returns null when the account is known but has no domain (not configured)', () => {
66
+ expect(pickRcsDomainForAccount([domainA, domainB], 'acc-C', getDomainAccountId)).toBeNull();
67
+ expect(pickRcsDomainForAccount([domainA], 'acc-C', getDomainAccountId)).toBeNull();
68
+ });
69
+
70
+ it('uses the only domain when it carries no account id (legacy single-domain org)', () => {
71
+ const legacyDomain = { domainId: 9, sourceAccountIdentifier: '' };
72
+ expect(pickRcsDomainForAccount([legacyDomain], 'acc-A', getDomainAccountId)).toBe(legacyDomain);
73
+ });
74
+
75
+ it('does not use an unmatched domain without account id when there are several', () => {
76
+ const legacyDomain = { domainId: 9, sourceAccountIdentifier: '' };
77
+ expect(pickRcsDomainForAccount([legacyDomain, domainB], 'acc-A', getDomainAccountId)).toBeNull();
78
+ });
79
+
80
+ it('uses the first domain when the account is unknown (pre-multi-account behaviour)', () => {
81
+ expect(pickRcsDomainForAccount([domainA, domainB], '', getDomainAccountId)).toBe(domainA);
82
+ expect(pickRcsDomainForAccount([domainA, domainB], undefined, getDomainAccountId)).toBe(domainA);
83
+ });
84
+
85
+ it('returns null when there are no domains', () => {
86
+ expect(pickRcsDomainForAccount([], 'acc-A', getDomainAccountId)).toBeNull();
87
+ expect(pickRcsDomainForAccount(undefined, '', getDomainAccountId)).toBeNull();
88
+ });
89
+ });
90
+
91
+ describe('isRcsAccountNotConfigured', () => {
92
+ const domains = [{ sourceAccountIdentifier: 'acc-A' }, { sourceAccountIdentifier: 'acc-B' }];
93
+
94
+ it('is true only for a known account without a domain', () => {
95
+ expect(isRcsAccountNotConfigured(domains, 'acc-C', getDomainAccountId)).toBe(true);
96
+ expect(isRcsAccountNotConfigured(domains, 'acc-A', getDomainAccountId)).toBe(false);
97
+ });
98
+
99
+ it('is false when the account is unknown', () => {
100
+ expect(isRcsAccountNotConfigured(domains, '', getDomainAccountId)).toBe(false);
101
+ expect(isRcsAccountNotConfigured([], '', getDomainAccountId)).toBe(false);
102
+ });
103
+
104
+ it('is true for a known account when the settled RCS domain list is empty', () => {
105
+ expect(isRcsAccountNotConfigured([], 'acc-C', getDomainAccountId)).toBe(true);
106
+ expect(isRcsAccountNotConfigured(undefined, 'acc-C', getDomainAccountId)).toBe(true);
107
+ });
108
+
109
+ it('is true for an account that is no longer available', () => {
110
+ expect(isRcsAccountNotConfigured(domains, RCS_ACCOUNT_UNAVAILABLE, getDomainAccountId)).toBe(true);
111
+ });
112
+ });
113
+
114
+ describe('resolveRcsAccountKey', () => {
115
+ const accounts = [{ id: 13750, sourceAccountIdentifier: 'acc-A' }];
116
+
117
+ it('is "none" (unknown, first-domain behaviour) without a saved accountId', () => {
118
+ expect(resolveRcsAccountKey({ accountId: '', accounts, isLoaded: true })).toEqual({ status: 'none', accountKey: '' });
119
+ });
120
+
121
+ it('resolves a saved WeCRM id or sourceAccountIdentifier', () => {
122
+ expect(resolveRcsAccountKey({ accountId: 13750, accounts, isLoaded: true }))
123
+ .toEqual({ status: 'resolved', accountKey: 'acc-A' });
124
+ expect(resolveRcsAccountKey({ accountId: 'acc-A', accounts: [], isLoaded: false }))
125
+ .toEqual({ status: 'pending', accountKey: '' });
126
+ });
127
+
128
+ it('is "pending" while the accounts are loading and "failed" when the request failed', () => {
129
+ expect(resolveRcsAccountKey({ accountId: 13750, accounts: [], isLoaded: false }))
130
+ .toEqual({ status: 'pending', accountKey: '' });
131
+ expect(resolveRcsAccountKey({
132
+ accountId: 13750, accounts: [], isLoaded: false, hasFailed: true,
133
+ })).toEqual({ status: 'failed', accountKey: '' });
134
+ });
135
+
136
+ it('is "missing" (account unavailable) when loaded without the saved account', () => {
137
+ expect(resolveRcsAccountKey({ accountId: 99999, accounts, isLoaded: true }))
138
+ .toEqual({ status: 'missing', accountKey: RCS_ACCOUNT_UNAVAILABLE });
139
+ });
140
+ });
141
+ describe('getRcsDomainsForAccount', () => {
142
+ const domainA = { domainId: 1, sourceAccountIdentifier: 'acc-A' };
143
+ const domainA2 = { domainId: 3, sourceAccountIdentifier: 'acc-A' };
144
+ const domainB = { domainId: 2, sourceAccountIdentifier: 'acc-B' };
145
+
146
+ it('returns every domain of the account', () => {
147
+ expect(getRcsDomainsForAccount([domainA, domainB, domainA2], 'acc-A', getParsedRcsDomainAccountId))
148
+ .toEqual([domainA, domainA2]);
149
+ });
150
+
151
+ it('returns all domains when the account is unknown', () => {
152
+ expect(getRcsDomainsForAccount([domainA, domainB], '', getParsedRcsDomainAccountId)).toEqual([domainA, domainB]);
153
+ });
154
+
155
+ it('returns [] for an unavailable account, even with a single legacy domain', () => {
156
+ expect(getRcsDomainsForAccount([{ domainId: 9 }], RCS_ACCOUNT_UNAVAILABLE, getParsedRcsDomainAccountId)).toEqual([]);
157
+ });
158
+
159
+ it('returns [] when the account has no domain, and the legacy domain when it is the only one', () => {
160
+ expect(getRcsDomainsForAccount([domainA, domainB], 'acc-C', getParsedRcsDomainAccountId)).toEqual([]);
161
+ const legacyDomain = { domainId: 9 };
162
+ expect(getRcsDomainsForAccount([legacyDomain], 'acc-C', getParsedRcsDomainAccountId)).toEqual([legacyDomain]);
163
+ });
164
+ });
165
+
166
+ describe('getRcsAccountIdFromCreativeForm', () => {
167
+ it('reads rcsContent.accountId from versions or content shapes', () => {
168
+ expect(getRcsAccountIdFromCreativeForm({ versions: { base: { content: { RCS: { rcsContent: { accountId: 13750 } } } } } }))
169
+ .toBe('13750');
170
+ expect(getRcsAccountIdFromCreativeForm({ content: { RCS: { rcsContent: { accountId: 'acc-A' } } } })).toBe('acc-A');
171
+ });
172
+
173
+ it('returns "" when there is no account id', () => {
174
+ expect(getRcsAccountIdFromCreativeForm({})).toBe('');
175
+ expect(getRcsAccountIdFromCreativeForm(undefined)).toBe('');
176
+ });
177
+ });
178
+ });
@@ -0,0 +1,193 @@
1
+ /**
2
+ * RCS multi-account: Test & Preview must use the account an existing template was saved with,
3
+ * not the account currently selected on the listing (all card types, carousel included).
4
+ */
5
+ import React from 'react';
6
+ import { Provider } from 'react-redux';
7
+ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
8
+ import { initialReducer } from '../../../initialReducer';
9
+ import { mountWithIntl } from '../../../../app/helpers/intl-enzym-test-helpers';
10
+ import { Rcs } from '../index';
11
+ import history from '../../../utils/history';
12
+
13
+ jest.mock('react-redux', () => {
14
+ const actual = jest.requireActual('react-redux');
15
+ return { ...actual, useDispatch: jest.fn(() => jest.fn()) };
16
+ });
17
+ jest.mock('../../../v2Containers/TagList/index.js', () => ({
18
+ __esModule: true,
19
+ default: () => <div className="tag-mock">TagList</div>,
20
+ }));
21
+ jest.mock('../../../v2Components/CapImageUpload', () => ({
22
+ __esModule: true,
23
+ default: () => <div className="cap-image-upload-mock" />,
24
+ }));
25
+ jest.mock('../../../v2Components/CapVideoUpload', () => ({
26
+ __esModule: true,
27
+ default: () => <div className="cap-video-upload-mock" />,
28
+ }));
29
+ jest.mock('../../../v2Components/CapActionButton', () => ({
30
+ __esModule: true,
31
+ default: () => <div className="cap-action-button-mock" />,
32
+ }));
33
+ jest.mock('@capillarytech/cap-ui-library/CapIcon', () => ({
34
+ __esModule: true,
35
+ default: () => <span className="cap-icon-mock" />,
36
+ }));
37
+ jest.mock('../../CreativesContainer', () => ({
38
+ __esModule: true,
39
+ default: () => <div className="creatives-container-mock" />,
40
+ }));
41
+ // Stub records the form data handed to Test & Preview.
42
+ const mockTestAndPreviewFormData = jest.fn();
43
+ jest.mock('../../../v2Components/TestAndPreviewSlidebox', () => ({
44
+ __esModule: true,
45
+ default: ({ show, formData }) => {
46
+ if (show) mockTestAndPreviewFormData(formData);
47
+ return show ? <div className="mock-test-preview" /> : null;
48
+ },
49
+ }));
50
+
51
+ let store;
52
+ beforeAll(() => {
53
+ store = configureStore({}, initialReducer, history);
54
+ });
55
+
56
+ const ACCOUNT_A = {
57
+ id: 13750, name: 'Brand A', sourceAccountIdentifier: 'acc-A', configs: { accessToken: 'token-A' },
58
+ };
59
+ const ACCOUNT_B = {
60
+ id: 13751, name: 'Brand B', sourceAccountIdentifier: 'acc-B', configs: { accessToken: 'token-B' },
61
+ };
62
+
63
+ const carouselCard = (title) => ({
64
+ title,
65
+ description: `${title} description`,
66
+ mediaType: 'IMAGE',
67
+ media: { mediaUrl: 'https://example.com/a.jpeg', thumbnailUrl: '', height: 'MEDIUM' },
68
+ suggestions: [],
69
+ Status: 'approved',
70
+ });
71
+
72
+ const buildTemplateDetails = ({ cardType, savedAccountId }) => ({
73
+ _id: 'rcs_1',
74
+ name: 'RcsTemplate',
75
+ type: 'RCS',
76
+ versions: {
77
+ base: {
78
+ content: {
79
+ RCS: {
80
+ rcsContent: {
81
+ ...(savedAccountId != null && { accountId: savedAccountId }),
82
+ cardType,
83
+ cardSettings: cardType === 'CAROUSEL'
84
+ ? { cardOrientation: 'VERTICAL', cardWidth: 'SMALL' }
85
+ : { cardOrientation: 'VERTICAL' },
86
+ contentType: cardType === 'CAROUSEL' ? 'RICHCARD' : 'text_message',
87
+ cardContent: cardType === 'CAROUSEL'
88
+ ? [carouselCard('Bali'), carouselCard('Swiss')]
89
+ : [{ title: '', description: 'Hello there', mediaType: 'NONE', Status: 'approved' }],
90
+ },
91
+ },
92
+ },
93
+ },
94
+ },
95
+ });
96
+
97
+ const renderEditAndOpenTestAndPreview = ({
98
+ cardType, savedAccountId, selectedRcsAccount, libraryTemplateData,
99
+ }) => {
100
+ const wrapper = mountWithIntl(
101
+ <Provider store={store}>
102
+ <Rcs
103
+ actions={{
104
+ uploadRcsAsset: jest.fn(),
105
+ clearRcsMediaAsset: jest.fn(),
106
+ createTemplate: jest.fn(),
107
+ clearCreateResponse: jest.fn(),
108
+ getTemplateDetails: jest.fn((id, setSpin) => setSpin && setSpin(false)),
109
+ editTemplate: jest.fn(),
110
+ clearEditResponse: jest.fn(),
111
+ }}
112
+ globalActions={{ fetchSchemaForEntity: jest.fn() }}
113
+ onCreateComplete={jest.fn()}
114
+ handleClose={jest.fn()}
115
+ intl={{ formatMessage: jest.fn() }}
116
+ location={{ pathname: '/rcs/edit', query: { type: false, module: 'default' }, search: '' }}
117
+ params={{ id: 'rcs_1' }}
118
+ rcsData={{ templateDetails: libraryTemplateData ? undefined : buildTemplateDetails({ cardType, savedAccountId }) }}
119
+ accountData={{ selectedRcsAccount }}
120
+ templateData={libraryTemplateData || {}}
121
+ isFullMode={!libraryTemplateData}
122
+ loadingTags={false}
123
+ metaEntities={[]}
124
+ getDefaultTags
125
+ smsRegister="DLT"
126
+ />
127
+ </Provider>,
128
+ );
129
+ wrapper.update();
130
+ wrapper.find('button.rcs-test-preview-btn').last().simulate('click');
131
+ wrapper.update();
132
+ const calls = mockTestAndPreviewFormData.mock.calls;
133
+ const formData = calls[calls.length - 1]?.[0];
134
+ return formData?.versions?.base?.content?.RCS?.rcsContent?.accountId;
135
+ };
136
+
137
+ describe('Rcs - Test & Preview account for an existing template', () => {
138
+ beforeEach(() => {
139
+ mockTestAndPreviewFormData.mockClear();
140
+ });
141
+
142
+ it('uses the saved account A for a carousel saved under A while B is selected', () => {
143
+ const previewAccountId = renderEditAndOpenTestAndPreview({
144
+ cardType: 'CAROUSEL', savedAccountId: ACCOUNT_A.id, selectedRcsAccount: ACCOUNT_B,
145
+ });
146
+ expect(previewAccountId).toBe(String(ACCOUNT_A.id));
147
+ });
148
+
149
+ it('uses the saved account A for a standalone template saved under A while B is selected', () => {
150
+ const previewAccountId = renderEditAndOpenTestAndPreview({
151
+ cardType: 'STANDALONE', savedAccountId: ACCOUNT_A.id, selectedRcsAccount: ACCOUNT_B,
152
+ });
153
+ expect(previewAccountId).toBe(String(ACCOUNT_A.id));
154
+ });
155
+
156
+ it('uses the saved account when it is the sourceAccountIdentifier (full-mode save) and another account is selected', () => {
157
+ const previewAccountId = renderEditAndOpenTestAndPreview({
158
+ cardType: 'CAROUSEL', savedAccountId: ACCOUNT_A.sourceAccountIdentifier, selectedRcsAccount: ACCOUNT_B,
159
+ });
160
+ expect(previewAccountId).toBe(ACCOUNT_A.sourceAccountIdentifier);
161
+ });
162
+
163
+ it('keeps the selected account WeCRM id when the selection is the saved account', () => {
164
+ const previewAccountId = renderEditAndOpenTestAndPreview({
165
+ cardType: 'CAROUSEL', savedAccountId: ACCOUNT_A.sourceAccountIdentifier, selectedRcsAccount: ACCOUNT_A,
166
+ });
167
+ expect(previewAccountId).toBe(String(ACCOUNT_A.id));
168
+ });
169
+
170
+ it('uses the selected account when the template has no saved account', () => {
171
+ const previewAccountId = renderEditAndOpenTestAndPreview({
172
+ cardType: 'CAROUSEL', savedAccountId: undefined, selectedRcsAccount: ACCOUNT_B,
173
+ });
174
+ expect(previewAccountId).toBe(String(ACCOUNT_B.id));
175
+ });
176
+ it('uses the root accountId of a library templateData (consumer shape) when nested rcsContent has none', () => {
177
+ const previewAccountId = renderEditAndOpenTestAndPreview({
178
+ selectedRcsAccount: ACCOUNT_B,
179
+ libraryTemplateData: {
180
+ channel: 'RCS',
181
+ creativeName: 'travelcard_bali',
182
+ accountId: ACCOUNT_A.id,
183
+ rcsContent: {
184
+ contentType: 'RICHCARD',
185
+ cardType: 'CAROUSEL',
186
+ cardSettings: { cardOrientation: 'VERTICAL', cardWidth: 'SMALL' },
187
+ cardContent: [carouselCard('Bali'), carouselCard('Swiss')],
188
+ },
189
+ },
190
+ });
191
+ expect(previewAccountId).toBe(String(ACCOUNT_A.id));
192
+ });
193
+ });
@@ -12733,6 +12733,7 @@ FREE GIFTS-
12733
12733
  extractedTags={Immutable.List []}
12734
12734
  fetchPrefilledValuesError={null}
12735
12735
  fetchPrefilledValuesErrors={Array []}
12736
+ fetchWeCrmAccountsError={null}
12736
12737
  formData={
12737
12738
  Object {
12738
12739
  "templateConfigs": Object {
@@ -12758,6 +12759,7 @@ FREE GIFTS-
12758
12759
  isFetchingTestCustomers={false}
12759
12760
  isFetchingTestGroups={false}
12760
12761
  isLoadingSenderDetails={false}
12762
+ isLoadingWeCrmAccounts={false}
12761
12763
  isSearchingCustomer={false}
12762
12764
  isSendingCcsTestMessage={false}
12763
12765
  isSendingTestMessage={false}
@@ -12821,6 +12823,7 @@ FREE GIFTS-
12821
12823
  extractedTags={Immutable.List []}
12822
12824
  fetchPrefilledValuesError={null}
12823
12825
  fetchPrefilledValuesErrors={Array []}
12826
+ fetchWeCrmAccountsError={null}
12824
12827
  formData={
12825
12828
  Object {
12826
12829
  "templateConfigs": Object {
@@ -15091,6 +15094,7 @@ new message content.",
15091
15094
  isFetchingTestCustomers={false}
15092
15095
  isFetchingTestGroups={false}
15093
15096
  isLoadingSenderDetails={false}
15097
+ isLoadingWeCrmAccounts={false}
15094
15098
  isSearchingCustomer={false}
15095
15099
  isSendingCcsTestMessage={false}
15096
15100
  isSendingTestMessage={false}
@@ -15163,6 +15167,7 @@ FREE GIFTS-
15163
15167
  extractedTags={Immutable.List []}
15164
15168
  fetchPrefilledValuesError={null}
15165
15169
  fetchPrefilledValuesErrors={Array []}
15170
+ fetchWeCrmAccountsError={null}
15166
15171
  formData={
15167
15172
  Object {
15168
15173
  "templateConfigs": Object {
@@ -17433,6 +17438,7 @@ new message content.",
17433
17438
  isFetchingTestCustomers={false}
17434
17439
  isFetchingTestGroups={false}
17435
17440
  isLoadingSenderDetails={false}
17441
+ isLoadingWeCrmAccounts={false}
17436
17442
  isSearchingCustomer={false}
17437
17443
  isSendingCcsTestMessage={false}
17438
17444
  isSendingTestMessage={false}
@@ -17554,8 +17560,11 @@ FREE GIFTS-
17554
17560
  isFetchingTestCustomers={false}
17555
17561
  isFetchingTestGroups={false}
17556
17562
  isLoadingSenderDetails={false}
17563
+ isRcsAccountLookupFailed={false}
17557
17564
  isSendingTestMessage={false}
17565
+ onRetryRcsAccountLookup={[Function]}
17558
17566
  onSaveDeliverySettings={[Function]}
17567
+ rcsSourceAccountIdentifier=""
17559
17568
  registeredSenderIds={Array []}
17560
17569
  renderAddTestCustomerButton={[Function]}
17561
17570
  searchValue=""
@@ -31870,6 +31879,7 @@ FREE GIFTS-
31870
31879
  extractedTags={Immutable.List []}
31871
31880
  fetchPrefilledValuesError={null}
31872
31881
  fetchPrefilledValuesErrors={Array []}
31882
+ fetchWeCrmAccountsError={null}
31873
31883
  formData={
31874
31884
  Object {
31875
31885
  "templateConfigs": Object {
@@ -31895,6 +31905,7 @@ FREE GIFTS-
31895
31905
  isFetchingTestCustomers={false}
31896
31906
  isFetchingTestGroups={false}
31897
31907
  isLoadingSenderDetails={false}
31908
+ isLoadingWeCrmAccounts={false}
31898
31909
  isSearchingCustomer={false}
31899
31910
  isSendingCcsTestMessage={false}
31900
31911
  isSendingTestMessage={false}
@@ -31958,6 +31969,7 @@ FREE GIFTS-
31958
31969
  extractedTags={Immutable.List []}
31959
31970
  fetchPrefilledValuesError={null}
31960
31971
  fetchPrefilledValuesErrors={Array []}
31972
+ fetchWeCrmAccountsError={null}
31961
31973
  formData={
31962
31974
  Object {
31963
31975
  "templateConfigs": Object {
@@ -34228,6 +34240,7 @@ new message content.",
34228
34240
  isFetchingTestCustomers={false}
34229
34241
  isFetchingTestGroups={false}
34230
34242
  isLoadingSenderDetails={false}
34243
+ isLoadingWeCrmAccounts={false}
34231
34244
  isSearchingCustomer={false}
34232
34245
  isSendingCcsTestMessage={false}
34233
34246
  isSendingTestMessage={false}
@@ -34300,6 +34313,7 @@ FREE GIFTS-
34300
34313
  extractedTags={Immutable.List []}
34301
34314
  fetchPrefilledValuesError={null}
34302
34315
  fetchPrefilledValuesErrors={Array []}
34316
+ fetchWeCrmAccountsError={null}
34303
34317
  formData={
34304
34318
  Object {
34305
34319
  "templateConfigs": Object {
@@ -36570,6 +36584,7 @@ new message content.",
36570
36584
  isFetchingTestCustomers={false}
36571
36585
  isFetchingTestGroups={false}
36572
36586
  isLoadingSenderDetails={false}
36587
+ isLoadingWeCrmAccounts={false}
36573
36588
  isSearchingCustomer={false}
36574
36589
  isSendingCcsTestMessage={false}
36575
36590
  isSendingTestMessage={false}
@@ -36691,8 +36706,11 @@ FREE GIFTS-
36691
36706
  isFetchingTestCustomers={false}
36692
36707
  isFetchingTestGroups={false}
36693
36708
  isLoadingSenderDetails={false}
36709
+ isRcsAccountLookupFailed={false}
36694
36710
  isSendingTestMessage={false}
36711
+ onRetryRcsAccountLookup={[Function]}
36695
36712
  onSaveDeliverySettings={[Function]}
36713
+ rcsSourceAccountIdentifier=""
36696
36714
  registeredSenderIds={Array []}
36697
36715
  renderAddTestCustomerButton={[Function]}
36698
36716
  searchValue=""
@@ -49543,6 +49561,7 @@ FREE GIFTS-
49543
49561
  extractedTags={Immutable.List []}
49544
49562
  fetchPrefilledValuesError={null}
49545
49563
  fetchPrefilledValuesErrors={Array []}
49564
+ fetchWeCrmAccountsError={null}
49546
49565
  formData={
49547
49566
  Object {
49548
49567
  "templateConfigs": Object {
@@ -49568,6 +49587,7 @@ FREE GIFTS-
49568
49587
  isFetchingTestCustomers={false}
49569
49588
  isFetchingTestGroups={false}
49570
49589
  isLoadingSenderDetails={false}
49590
+ isLoadingWeCrmAccounts={false}
49571
49591
  isSearchingCustomer={false}
49572
49592
  isSendingCcsTestMessage={false}
49573
49593
  isSendingTestMessage={false}
@@ -49631,6 +49651,7 @@ FREE GIFTS-
49631
49651
  extractedTags={Immutable.List []}
49632
49652
  fetchPrefilledValuesError={null}
49633
49653
  fetchPrefilledValuesErrors={Array []}
49654
+ fetchWeCrmAccountsError={null}
49634
49655
  formData={
49635
49656
  Object {
49636
49657
  "templateConfigs": Object {
@@ -51901,6 +51922,7 @@ new message content.",
51901
51922
  isFetchingTestCustomers={false}
51902
51923
  isFetchingTestGroups={false}
51903
51924
  isLoadingSenderDetails={false}
51925
+ isLoadingWeCrmAccounts={false}
51904
51926
  isSearchingCustomer={false}
51905
51927
  isSendingCcsTestMessage={false}
51906
51928
  isSendingTestMessage={false}
@@ -51973,6 +51995,7 @@ FREE GIFTS-
51973
51995
  extractedTags={Immutable.List []}
51974
51996
  fetchPrefilledValuesError={null}
51975
51997
  fetchPrefilledValuesErrors={Array []}
51998
+ fetchWeCrmAccountsError={null}
51976
51999
  formData={
51977
52000
  Object {
51978
52001
  "templateConfigs": Object {
@@ -54243,6 +54266,7 @@ new message content.",
54243
54266
  isFetchingTestCustomers={false}
54244
54267
  isFetchingTestGroups={false}
54245
54268
  isLoadingSenderDetails={false}
54269
+ isLoadingWeCrmAccounts={false}
54246
54270
  isSearchingCustomer={false}
54247
54271
  isSendingCcsTestMessage={false}
54248
54272
  isSendingTestMessage={false}
@@ -54364,8 +54388,11 @@ FREE GIFTS-
54364
54388
  isFetchingTestCustomers={false}
54365
54389
  isFetchingTestGroups={false}
54366
54390
  isLoadingSenderDetails={false}
54391
+ isRcsAccountLookupFailed={false}
54367
54392
  isSendingTestMessage={false}
54393
+ onRetryRcsAccountLookup={[Function]}
54368
54394
  onSaveDeliverySettings={[Function]}
54395
+ rcsSourceAccountIdentifier=""
54369
54396
  registeredSenderIds={Array []}
54370
54397
  renderAddTestCustomerButton={[Function]}
54371
54398
  searchValue=""
@@ -152,6 +152,18 @@ function ChannelTypeIllustration(props) {
152
152
  };
153
153
  }
154
154
 
155
+ // RCS (same as WhatsApp): no hostName means the selected account has no matching domain.
156
+ if (type === RCS && !hostName) {
157
+ return {
158
+ illustrationImage: whatsappOrZaloAccountIllustration,
159
+ title: <FormattedMessage {...messages.rcsAccountNotConfiguredTitle} />,
160
+ description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
161
+ descriptionPosition: 'bottom',
162
+ descriptionClassName: 'illustration-desc zalo-illustration',
163
+ buttonClassName: 'zalo-illustration-button',
164
+ };
165
+ }
166
+
155
167
  if (type === WEBPUSH) {
156
168
  return {
157
169
  buttonLabel: <FormattedMessage {...messages.newWebPushTemplate} values={{ template: templateText }} />,
@@ -2143,7 +2143,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2143
2143
  isTraiDltFeature = this.checkDLTfeatureEnable();
2144
2144
  break;
2145
2145
  case RCS:
2146
- filteredTemplates = this.filterRcsTemplates(templates);
2146
+ // Same as WhatsApp: no hostName means the account's domain is not configured, so no templates are shown.
2147
+ filteredTemplates = this.state?.hostName ? this.filterRcsTemplates(templates) : [];
2147
2148
  break;
2148
2149
  case ZALO:
2149
2150
  filteredTemplates = this.filterZaloTemplates(templates);
@@ -2934,6 +2935,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2934
2935
  const noApprovedWhatsappZaloTemplates = filteredEmptyAndFullModeAs(false) && !isEmpty(this.state?.hostName);
2935
2936
  const showWhatsappIllustration = accountWithNoHostWhatsapp(WHATSAPP_LOWERCASE);
2936
2937
  const showZaloIllustration = accountWithNoHostZalo(ZALO_LOWERCASE)
2938
+ // RCS (same as WhatsApp): the selected account has no matching domain, so it is not configured.
2939
+ // Shown even with a search term carried over from another account (no templates are ever listed for it).
2940
+ const showRcsAccountNotConfigured = channelLowerCase === RCS_LOWERCASE && !this.state?.hostName
2941
+ && !isLoading && !get(this.props, 'Templates.isArchivedMode', false);
2937
2942
 
2938
2943
  const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
2939
2944
 
@@ -2984,7 +2989,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2984
2989
  />
2985
2990
  )}
2986
2991
  {<div>
2987
- {!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError) ? (
2992
+ {!showRcsAccountNotConfigured && (!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError)) ? (
2988
2993
  <div className={!isEmpty(this.state.searchText) && isEmpty(cardDataList) ? '' : this.isFullMode() ? "v2-pagination-container" : "v2-pagination-container-half"}>
2989
2994
  <CapCustomCardList
2990
2995
  key={`${currentChannel}-card-list`}
@@ -3027,10 +3032,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
3027
3032
  </div>
3028
3033
  )
3029
3034
  }
3030
- {showIllustrationForChannel(RCS_LOWERCASE) &&
3035
+ {(showIllustrationForChannel(RCS_LOWERCASE) || showRcsAccountNotConfigured) &&
3031
3036
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
3032
- <ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} canCreate={this.canPerform(PERMISSIONS.CREATIVE_CREATE)} currentChannel={currentChannel}/>
3033
- {filteredEmptyAndFullModeAs(false) && this.whatsappZaloIllustrationText(noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc)}
3037
+ <ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} canCreate={this.canPerform(PERMISSIONS.CREATIVE_CREATE)} currentChannel={currentChannel} hostName={this.state?.hostName}/>
3038
+ {!showRcsAccountNotConfigured && filteredEmptyAndFullModeAs(false) && this.whatsappZaloIllustrationText(noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc)}
3034
3039
  </div>
3035
3040
  }
3036
3041
  {showIllustrationForChannel(INAPP_LOWERCASE) &&
@@ -410,6 +410,10 @@ export default defineMessages({
410
410
  id: `${scope}.accountNotConfiguredDescription`,
411
411
  defaultMessage: 'Please contact your Customer Success Manager to fix the issue.',
412
412
  },
413
+ "rcsAccountNotConfiguredTitle": {
414
+ id: `${scope}.rcsAccountNotConfiguredTitle`,
415
+ defaultMessage: 'RCS account is not configured',
416
+ },
413
417
  "zaloAccountNotConfiguredTitle": {
414
418
  id: `${scope}.zaloAccountNotConfiguredTitle`,
415
419
  defaultMessage: 'Zalo account is not configured',
@@ -152,8 +152,8 @@ describe('ChannelTypeIllustration', () => {
152
152
  });
153
153
 
154
154
  describe('RCS Channel', () => {
155
- it('should return correct illustration info for RCS channel', () => {
156
- const component = renderComponent({ currentChannel: RCS });
155
+ it('should return correct illustration info for RCS channel when hostName is available', () => {
156
+ const component = renderComponent({ currentChannel: RCS, hostName: 'ics' });
157
157
  const capIllustration = component.find('CapIllustration');
158
158
 
159
159
  expect(capIllustration.prop('illustrationImage')).toBe('test-file-stub');
@@ -164,6 +164,18 @@ describe('ChannelTypeIllustration', () => {
164
164
  expect(capIllustration.prop('descriptionPosition')).toBe('bottom');
165
165
  expect(capIllustration.prop('descriptionClassName')).toBe('illustration-desc rcs-illustration');
166
166
  });
167
+
168
+ it('should return account not configured info for RCS when hostName is not available (same as WhatsApp)', () => {
169
+ const component = renderComponent({ currentChannel: RCS, hostName: '' });
170
+ const capIllustration = component.find('CapIllustration');
171
+
172
+ expect(capIllustration.prop('title').props.id).toBe('creatives.containersV2.Templates.rcsAccountNotConfiguredTitle');
173
+ expect(capIllustration.prop('description').props.id).toBe('creatives.containersV2.Templates.accountNotConfiguredDescription');
174
+ expect(capIllustration.prop('descriptionClassName')).toBe('illustration-desc zalo-illustration');
175
+ expect(capIllustration.prop('buttonClassName')).toBe('zalo-illustration-button');
176
+ expect(capIllustration.prop('onClick')).toBeUndefined();
177
+ expect(capIllustration.prop('buttonLabel')).toBeUndefined();
178
+ });
167
179
  });
168
180
 
169
181
  describe('ZALO Channel', () => {