@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
@@ -11,6 +11,7 @@ import {
11
11
  render, screen, waitFor, act,
12
12
  } from '@testing-library/react';
13
13
  import { IntlProvider } from 'react-intl';
14
+ import { RCS_ACCOUNT_UNAVAILABLE } from '../../../v2Containers/Rcs/accountUtils';
14
15
  import CommonTestAndPreview from '../index';
15
16
  import { CHANNELS, MEDIA_TYPE_CAROUSEL } from '../constants';
16
17
 
@@ -213,6 +214,205 @@ describe('CommonTestAndPreview', () => {
213
214
  });
214
215
 
215
216
  describe('Delivery settings / sender ID', () => {
217
+ describe('RCS multi-account (same as WhatsApp)', () => {
218
+ const rcsDomainA = {
219
+ domainId: 1,
220
+ dgmId: 11,
221
+ domainName: 'RCS A',
222
+ sourceAccountIdentifier: 'acc-A',
223
+ gsmSenders: [{ value: 'RCS_A' }],
224
+ cdmaSenders: [],
225
+ };
226
+ const rcsDomainB = {
227
+ domainId: 2,
228
+ dgmId: 22,
229
+ domainName: 'RCS B',
230
+ sourceAccountIdentifier: 'acc-B',
231
+ gsmSenders: [{ value: 'RCS_B' }],
232
+ cdmaSenders: [],
233
+ };
234
+ const senderDetailsByChannel = { [CHANNELS.RCS]: [rcsDomainA, rcsDomainB] };
235
+ const rcsWecrmAccounts = [
236
+ { id: 13750, name: 'Brand A', sourceAccountIdentifier: 'acc-A' },
237
+ { id: 13751, name: 'Brand B', sourceAccountIdentifier: 'acc-B' },
238
+ { id: 13752, name: 'Brand C', sourceAccountIdentifier: 'acc-C' },
239
+ ];
240
+ // Saved RCS creative as campaigns / journeys pass it: rcsContent.accountId = WeCRM id
241
+ const rcsFormData = (accountId) => ({
242
+ versions: { base: { content: { RCS: { rcsContent: { cardContent: [], ...(accountId != null && { accountId }) } } } } },
243
+ });
244
+ const renderRcs = ({ accountId, wecrmAccounts = rcsWecrmAccounts } = {}) => render(
245
+ <TestWrapper>
246
+ <CommonTestAndPreview
247
+ {...defaultProps}
248
+ channel={CHANNELS.RCS}
249
+ formData={rcsFormData(accountId)}
250
+ senderDetailsByChannel={senderDetailsByChannel}
251
+ wecrmAccounts={wecrmAccounts}
252
+ />
253
+ </TestWrapper>
254
+ );
255
+
256
+ it('fetches the RCS WeCRM accounts', async () => {
257
+ renderRcs({ accountId: 13751 });
258
+ await waitFor(() => {
259
+ expect(mockActions.getWeCrmAccountsRequested).toHaveBeenCalledWith({ sourceName: CHANNELS.RCS });
260
+ });
261
+ });
262
+
263
+ it('resolves the saved WeCRM accountId and defaults to that account domain', async () => {
264
+ renderRcs({ accountId: 13751 });
265
+ await waitFor(() => {
266
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({
267
+ domainId: 2,
268
+ domainGatewayMapId: 22,
269
+ gsmSenderId: '2|RCS_B',
270
+ });
271
+ });
272
+ expect(lastSendTestMessageProps.rcsSourceAccountIdentifier).toBe('acc-B');
273
+ });
274
+
275
+ it('also resolves an accountId that is the sourceAccountIdentifier (editor)', async () => {
276
+ renderRcs({ accountId: 'acc-B' });
277
+ await waitFor(() => {
278
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 2, gsmSenderId: '2|RCS_B' });
279
+ });
280
+ });
281
+
282
+ it('defaults to the first RCS domain when the account is unknown (no accountId)', async () => {
283
+ renderRcs({});
284
+ await waitFor(() => {
285
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 1, gsmSenderId: '1|RCS_A' });
286
+ });
287
+ expect(lastSendTestMessageProps.rcsSourceAccountIdentifier).toBe('');
288
+ });
289
+
290
+ it('sets no default RCS sender when the account has no domain of its own (not configured)', async () => {
291
+ renderRcs({ accountId: 13752 });
292
+ await waitFor(() => {
293
+ expect(lastSendTestMessageProps.rcsSourceAccountIdentifier).toBe('acc-C');
294
+ });
295
+ expect(lastSendTestMessageProps.deliverySettings?.gsmSenderId || '').toBe('');
296
+ expect(lastSendTestMessageProps.deliverySettings?.domainId ?? null).toBeNull();
297
+ });
298
+
299
+ const rerenderRcs = (rerender, {
300
+ accountId, wecrmAccounts = rcsWecrmAccounts, senderDetails, isLoadingWeCrmAccounts = false,
301
+ fetchWeCrmAccountsError = null,
302
+ }) => rerender(
303
+ <TestWrapper>
304
+ <CommonTestAndPreview
305
+ {...defaultProps}
306
+ channel={CHANNELS.RCS}
307
+ formData={rcsFormData(accountId)}
308
+ senderDetailsByChannel={senderDetails || senderDetailsByChannel}
309
+ wecrmAccounts={wecrmAccounts}
310
+ isLoadingWeCrmAccounts={isLoadingWeCrmAccounts}
311
+ fetchWeCrmAccountsError={fetchWeCrmAccountsError}
312
+ />
313
+ </TestWrapper>
314
+ );
315
+ const expectSendBlocked = () => {
316
+ lastSendTestMessageProps.handleSendTestMessage();
317
+ expect(mockActions.createMessageMetaRequested).not.toHaveBeenCalled();
318
+ expect(mockActions.sendTestMessageRequested).not.toHaveBeenCalled();
319
+ };
320
+
321
+ it('leaves the RCS sender unset and blocks sending while the saved account lookup is pending', async () => {
322
+ const { rerender } = render(<TestWrapper><div /></TestWrapper>);
323
+ rerenderRcs(rerender, { accountId: 13751, wecrmAccounts: [], isLoadingWeCrmAccounts: true });
324
+ await waitFor(() => {
325
+ expect(typeof lastSendTestMessageProps?.handleSendTestMessage).toBe('function');
326
+ });
327
+ expect(lastSendTestMessageProps.deliverySettings?.gsmSenderId || '').toBe('');
328
+ expect(lastSendTestMessageProps.deliverySettings?.domainId ?? null).toBeNull();
329
+ expect(lastSendTestMessageProps.isRcsAccountLookupFailed).toBe(false);
330
+ expectSendBlocked();
331
+
332
+ rerenderRcs(rerender, { accountId: 13751 });
333
+ await waitFor(() => {
334
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 2, gsmSenderId: '2|RCS_B' });
335
+ });
336
+ });
337
+
338
+ it('shows the lookup failure with a retry, leaves the sender unset and blocks sending when the request failed', async () => {
339
+ const { rerender } = render(<TestWrapper><div /></TestWrapper>);
340
+ rerenderRcs(rerender, { accountId: 13751, wecrmAccounts: [], fetchWeCrmAccountsError: 'down' });
341
+ await waitFor(() => {
342
+ expect(lastSendTestMessageProps.isRcsAccountLookupFailed).toBe(true);
343
+ });
344
+ expect(lastSendTestMessageProps.deliverySettings?.gsmSenderId || '').toBe('');
345
+ expectSendBlocked();
346
+
347
+ mockActions.getWeCrmAccountsRequested.mockClear();
348
+ lastSendTestMessageProps.onRetryRcsAccountLookup();
349
+ expect(mockActions.getWeCrmAccountsRequested).toHaveBeenCalledWith({ sourceName: CHANNELS.RCS });
350
+ });
351
+
352
+ it('treats a completed lookup without the saved account as unavailable and blocks sending', async () => {
353
+ renderRcs({ accountId: 99999 });
354
+ await waitFor(() => {
355
+ expect(lastSendTestMessageProps.rcsSourceAccountIdentifier).toBe(RCS_ACCOUNT_UNAVAILABLE);
356
+ });
357
+ expect(lastSendTestMessageProps.deliverySettings?.gsmSenderId || '').toBe('');
358
+ expect(lastSendTestMessageProps.isRcsAccountLookupFailed).toBe(false);
359
+ expectSendBlocked();
360
+ });
361
+
362
+ it('keeps the same delivery settings state when no RCS / fallback sender is available (no repeated renders)', async () => {
363
+ const noSenderDomain = {
364
+ domainId: 5, dgmId: 55, domainName: 'RCS empty', sourceAccountIdentifier: 'acc-B', gsmSenders: [], cdmaSenders: [],
365
+ };
366
+ const noSenderDetails = { [CHANNELS.RCS]: [noSenderDomain] };
367
+ const { rerender } = render(<TestWrapper><div /></TestWrapper>);
368
+ rerenderRcs(rerender, { accountId: 13751, senderDetails: noSenderDetails });
369
+ await waitFor(() => {
370
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 5, gsmSenderId: '' });
371
+ });
372
+ const settledDeliverySettings = lastSendTestMessageProps.deliverySettings;
373
+ rerenderRcs(rerender, { accountId: 13751, senderDetails: noSenderDetails });
374
+ rerenderRcs(rerender, { accountId: 13751, senderDetails: noSenderDetails });
375
+ expect(lastSendTestMessageProps.deliverySettings).toBe(settledDeliverySettings);
376
+ });
377
+
378
+ it('restores an empty RCS sender for the newly resolved account and keeps the SMS fallback sender', async () => {
379
+ const smsFallbackDomain = {
380
+ domainId: 7, domainName: 'SMS D', gsmSenders: [{ value: 'FB1' }], cdmaSenders: [],
381
+ };
382
+ const senderDetails = { ...senderDetailsByChannel, [CHANNELS.SMS]: [smsFallbackDomain] };
383
+ const { rerender } = render(<TestWrapper><div /></TestWrapper>);
384
+ // Account first resolves to A: RCS + SMS-fallback defaults.
385
+ rerenderRcs(rerender, {
386
+ accountId: 13751,
387
+ wecrmAccounts: [{ id: 13751, sourceAccountIdentifier: 'acc-A' }],
388
+ senderDetails,
389
+ });
390
+ await waitFor(() => {
391
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ gsmSenderId: '1|RCS_A', cdmaSenderId: '7|FB1' });
392
+ });
393
+ // Account now maps to one without a domain: RCS sender cleared, SMS fallback kept.
394
+ rerenderRcs(rerender, {
395
+ accountId: 13751,
396
+ wecrmAccounts: [{ id: 13751, sourceAccountIdentifier: 'acc-X' }],
397
+ senderDetails,
398
+ });
399
+ await waitFor(() => {
400
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ gsmSenderId: '', cdmaSenderId: '7|FB1' });
401
+ });
402
+ // Account resolves to B (has a domain): RCS sender restored although the SMS fallback is set.
403
+ rerenderRcs(rerender, {
404
+ accountId: 13751,
405
+ wecrmAccounts: [{ id: 13751, sourceAccountIdentifier: 'acc-B' }],
406
+ senderDetails,
407
+ });
408
+ await waitFor(() => {
409
+ expect(lastSendTestMessageProps.deliverySettings).toMatchObject({
410
+ domainId: 2, gsmSenderId: '2|RCS_B', cdmaSenderId: '7|FB1',
411
+ });
412
+ });
413
+ });
414
+ });
415
+
216
416
  it('should call getSenderDetailsRequested when show and channel is SMS', async () => {
217
417
  render(
218
418
  <TestWrapper>
@@ -99,6 +99,7 @@ describe('previewAndTestReducer', () => {
99
99
  [CHANNELS.WHATSAPP]: [],
100
100
  }),
101
101
  wecrmAccounts: fromJS([]),
102
+ isLoadingWeCrmAccounts: false,
102
103
  isLoadingSenderDetails: false,
103
104
  fetchSenderDetailsError: null,
104
105
  fetchWeCrmAccountsError: null,
@@ -964,6 +965,7 @@ describe('previewAndTestReducer', () => {
964
965
  const result = previewAndTestReducer(stateWithError, action);
965
966
 
966
967
  expect(result.get('fetchWeCrmAccountsError')).toBeNull();
968
+ expect(result.get('isLoadingWeCrmAccounts')).toBe(true);
967
969
  });
968
970
  });
969
971
 
@@ -978,6 +980,7 @@ describe('previewAndTestReducer', () => {
978
980
 
979
981
  expect(result.get('wecrmAccounts')).toEqual(fromJS(accounts));
980
982
  expect(result.get('fetchWeCrmAccountsError')).toBeNull();
983
+ expect(result.get('isLoadingWeCrmAccounts')).toBe(false);
981
984
  });
982
985
 
983
986
  it('should handle empty accounts', () => {
@@ -1000,6 +1003,7 @@ describe('previewAndTestReducer', () => {
1000
1003
  const result = previewAndTestReducer(initialState, action);
1001
1004
 
1002
1005
  expect(result.get('fetchWeCrmAccountsError')).toBe('WeCRM fetch failed');
1006
+ expect(result.get('isLoadingWeCrmAccounts')).toBe(false);
1003
1007
  });
1004
1008
  });
1005
1009
 
@@ -36,6 +36,7 @@ import {
36
36
  makeSelectSenderDetailsForChannel,
37
37
  makeSelectSenderDetailsByChannel,
38
38
  makeSelectWeCrmAccounts,
39
+ makeSelectIsLoadingWeCrmAccounts,
39
40
  makeSelectIsLoadingSenderDetails,
40
41
  makeSelectFetchSenderDetailsError,
41
42
  makeSelectFetchWeCrmAccountsError,
@@ -647,6 +648,15 @@ describe('CommonTestAndPreview Selectors', () => {
647
648
  });
648
649
  });
649
650
 
651
+ describe('makeSelectIsLoadingWeCrmAccounts', () => {
652
+ it('reflects the WeCRM accounts request state and defaults to false', () => {
653
+ const selector = makeSelectIsLoadingWeCrmAccounts();
654
+ expect(selector(fromJS({ commonTestAndPreview: { isLoadingWeCrmAccounts: true } }))).toBe(true);
655
+ expect(selector(fromJS({ commonTestAndPreview: {} }))).toBe(false);
656
+ expect(selector(fromJS({}))).toBe(false);
657
+ });
658
+ });
659
+
650
660
  describe('makeSelectWeCrmAccounts', () => {
651
661
  it('should select wecrmAccounts and convert to JS array', () => {
652
662
  const selector = makeSelectWeCrmAccounts();
@@ -43,6 +43,8 @@ import {
43
43
  makeSelectFetchPrefilledValuesErrors,
44
44
  makeSelectSenderDetailsByChannel,
45
45
  makeSelectWeCrmAccounts,
46
+ makeSelectIsLoadingWeCrmAccounts,
47
+ makeSelectFetchWeCrmAccountsError,
46
48
  makeSelectIsLoadingSenderDetails,
47
49
  } from '../CommonTestAndPreview/selectors';
48
50
 
@@ -108,6 +110,8 @@ TestAndPreviewSlidebox.propTypes = {
108
110
  intl: PropTypes.object.isRequired,
109
111
  senderDetailsByChannel: PropTypes.object,
110
112
  wecrmAccounts: PropTypes.array,
113
+ isLoadingWeCrmAccounts: PropTypes.bool,
114
+ fetchWeCrmAccountsError: PropTypes.any,
111
115
  isLoadingSenderDetails: PropTypes.bool,
112
116
  orgUnitId: PropTypes.number,
113
117
  /** notify/ui only — see CommonTestAndPreview's handleSendTestMessage. */
@@ -129,6 +133,8 @@ TestAndPreviewSlidebox.defaultProps = {
129
133
  rcsTestPreviewOptions: undefined,
130
134
  senderDetailsByChannel: {},
131
135
  wecrmAccounts: [],
136
+ isLoadingWeCrmAccounts: false,
137
+ fetchWeCrmAccountsError: null,
132
138
  isLoadingSenderDetails: false,
133
139
  orgUnitId: -1,
134
140
  smsFallbackContent: null,
@@ -156,6 +162,8 @@ const mapStateToProps = createStructuredSelector({
156
162
  isSendingCcsTestMessage: makeSelectIsSendingCcsTestMessage(),
157
163
  senderDetailsByChannel: makeSelectSenderDetailsByChannel(),
158
164
  wecrmAccounts: makeSelectWeCrmAccounts(),
165
+ isLoadingWeCrmAccounts: makeSelectIsLoadingWeCrmAccounts(),
166
+ fetchWeCrmAccountsError: makeSelectFetchWeCrmAccountsError(),
159
167
  isLoadingSenderDetails: makeSelectIsLoadingSenderDetails(),
160
168
  });
161
169
 
@@ -60,6 +60,9 @@ const getDeliveryChannels = (contentItems) => {
60
60
 
61
61
  const hasDeliverySettingForChannel = (channelSetting, channel) => {
62
62
  const settings = channelSetting[channel];
63
+ // RCS needs its own RCS sender: SMS-fallback values alone are not enough (an RCS account without its
64
+ // own domain has no RCS sender, so the communication must not be saved).
65
+ if (channel === 'RCS') return !!(settings?.rcsSender || settings?.senderMobNum);
63
66
  return !!settings && Object.values(settings).some((v) => v !== null && v !== '' && v !== undefined);
64
67
  };
65
68
 
@@ -102,6 +105,8 @@ const CommunicationFlow = ({
102
105
  };
103
106
  });
104
107
  const [validationErrors, setValidationErrors] = useState({});
108
+ // True while DeliverySettingsSection is still resolving the RCS template's account (lookup pending / failed).
109
+ const [isRcsAccountPending, setIsRcsAccountPending] = useState(false);
105
110
 
106
111
  // Fetch-by-id: populate stepData from the CommDefinition itself when the consumer only
107
112
  // supplied a commDefinitionId (see shouldFetchCommDefinition above). Shared with
@@ -131,10 +136,12 @@ const CommunicationFlow = ({
131
136
  (channel) => !hasDeliverySettingForChannel(channelSetting, channel),
132
137
  );
133
138
  if (anyChannelMissingSenderDetails) return true;
139
+ // A saved RCS sender may belong to another account until the template's account resolves.
140
+ if (deliveryChannels.includes('RCS') && isRcsAccountPending) return true;
134
141
  }
135
142
 
136
143
  return false;
137
- }, [enabledSteps, stepData.communicationStrategy, stepData.contentItems, stepData.deliverySetting, config?.features?.deliverySettingsData]);
144
+ }, [enabledSteps, stepData.communicationStrategy, stepData.contentItems, stepData.deliverySetting, config?.features?.deliverySettingsData, isRcsAccountPending]);
138
145
 
139
146
  /**
140
147
  * Get aggregated data from all steps
@@ -365,6 +372,7 @@ const CommunicationFlow = ({
365
372
  types: config.features?.incentivesData?.types || INCENTIVE_TYPES,
366
373
  }}
367
374
  deliverySettingsData={config.features?.deliverySettingsData}
375
+ onRcsAccountPendingChange={setIsRcsAccountPending}
368
376
  config={config}
369
377
  capData={cap || capData}
370
378
  isContentLoading={isFetchingCommDefinition}
@@ -5,6 +5,8 @@ jest.mock('../../../services/api', () => ({
5
5
  editCommDefinition: jest.fn(),
6
6
  getCommDefinition: jest.fn(),
7
7
  getCommDefinitionVersion: jest.fn(),
8
+ getDomainProperties: jest.fn(),
9
+ fetchWeCrmAccounts: jest.fn(),
8
10
  }));
9
11
 
10
12
  jest.mock('../utils/mapCommDefinitionToStepData', () => ({
@@ -43,7 +45,7 @@ jest.mock('../../CreativesContainer', () => function MockCreativesContainer({
43
45
  import { Provider } from 'react-redux';
44
46
  import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
45
47
  import {
46
- render as rtlRender, screen, waitFor, within, fireEvent,
48
+ render as rtlRender, screen, waitFor, within, fireEvent, act,
47
49
  } from '@testing-library/react';
48
50
  import userEvent from '@testing-library/user-event';
49
51
  import '@testing-library/jest-dom';
@@ -51,6 +53,7 @@ import { IntlProvider } from 'react-intl';
51
53
  import history from '../../../utils/history';
52
54
  import { initialReducer } from '../../../initialReducer';
53
55
  import CommunicationFlow from '../CommunicationFlow';
56
+ import { getDomainProperties, fetchWeCrmAccounts } from '../../../services/api';
54
57
  import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
55
58
  import { createCommDefinition, editCommDefinition } from '../../../services/api';
56
59
  import { fetchAndMapCommDefinition } from '../utils/mapCommDefinitionToStepData';
@@ -356,6 +359,78 @@ describe('isSaveDisabled', () => {
356
359
  expect(screen.getByRole('button', { name: /^save$/i })).not.toBeDisabled();
357
360
  });
358
361
 
362
+ it('is true for RCS with only SMS-fallback values and no RCS sender (RCS account not configured)', () => {
363
+ renderWithFlow({
364
+ features: {
365
+ communicationStrategyData: { required: true, options: STRATEGY_OPTIONS },
366
+ contentTemplateData: { required: true, channels: CHANNELS },
367
+ deliverySettingsData: {},
368
+ },
369
+ initialData: {
370
+ communicationStrategy: SINGLE_TEMPLATE,
371
+ contentItems: [{ channel: 'RCS', templateData: {} }],
372
+ deliverySetting: { channelSetting: { RCS: { rcsSender: '', senderMobNum: '', smsFallbackSenderId: 'FB' } } },
373
+ },
374
+ });
375
+ expect(screen.getByRole('button', { name: /^save$/i })).toBeDisabled();
376
+ });
377
+
378
+ it('is false for RCS once it has an RCS sender', () => {
379
+ renderWithFlow({
380
+ features: {
381
+ communicationStrategyData: { required: true, options: STRATEGY_OPTIONS },
382
+ contentTemplateData: { required: true, channels: CHANNELS },
383
+ deliverySettingsData: {},
384
+ },
385
+ initialData: {
386
+ communicationStrategy: SINGLE_TEMPLATE,
387
+ contentItems: [{ channel: 'RCS', templateData: {} }],
388
+ deliverySetting: { channelSetting: { RCS: { rcsSender: '+rcsB', senderMobNum: '+rcsB' } } },
389
+ },
390
+ });
391
+ expect(screen.getByRole('button', { name: /^save$/i })).not.toBeDisabled();
392
+ });
393
+
394
+ it('blocks Save while the RCS template account is unresolved, even with a saved RCS sender', async () => {
395
+ getDomainProperties.mockResolvedValue({
396
+ entity: {
397
+ RCS: [{
398
+ domainProperties: {
399
+ id: 12,
400
+ domainName: 'RCS acc-B',
401
+ connectionProperties: { sourceAccountIdentifier: 'acc-B' },
402
+ contactInfo: [{
403
+ type: 'gsm_sender_id', value: '+rcsB', valid: true, default: true,
404
+ }],
405
+ },
406
+ }],
407
+ },
408
+ });
409
+ let resolveAccounts;
410
+ fetchWeCrmAccounts.mockReturnValue(new Promise((resolve) => { resolveAccounts = resolve; }));
411
+
412
+ renderWithFlow({
413
+ features: {
414
+ communicationStrategyData: { required: true, options: STRATEGY_OPTIONS },
415
+ contentTemplateData: { required: true, channels: CHANNELS },
416
+ deliverySettingsData: {},
417
+ },
418
+ initialData: {
419
+ communicationStrategy: SINGLE_TEMPLATE,
420
+ contentItems: [{ channel: 'RCS', templateData: { accountId: 13751 } }],
421
+ deliverySetting: { channelSetting: { RCS: { rcsSender: '+rcsA', senderMobNum: '+rcsA' } } },
422
+ },
423
+ });
424
+ // Saved sender exists, but account 13751 is not resolved yet → Save stays disabled.
425
+ await waitFor(() => expect(fetchWeCrmAccounts).toHaveBeenCalledWith('RCS'));
426
+ expect(screen.getByRole('button', { name: /^save$/i })).toBeDisabled();
427
+
428
+ await act(async () => {
429
+ resolveAccounts({ response: [{ id: 13751, sourceAccountIdentifier: 'acc-B' }] });
430
+ });
431
+ await waitFor(() => expect(screen.getByRole('button', { name: /^save$/i })).not.toBeDisabled());
432
+ });
433
+
359
434
  it('skips delivery check for CHANNELS_WITHOUT_DELIVERY (e.g. MOBILEPUSH)', () => {
360
435
  renderWithFlow({
361
436
  features: {
@@ -369,6 +369,18 @@ export default {
369
369
  id: `${prefix}.domainGatewayError`,
370
370
  defaultMessage: 'Domain gateway id is not found for the selected channel. Please contact the gateway team to register them with Capillary.',
371
371
  },
372
+ rcsAccountLookupFailedError: {
373
+ id: `${prefix}.rcsAccountLookupFailedError`,
374
+ defaultMessage: 'Could not load the RCS account of this template.',
375
+ },
376
+ retry: {
377
+ id: `${prefix}.retry`,
378
+ defaultMessage: 'Retry',
379
+ },
380
+ rcsAccountNotConfiguredError: {
381
+ id: `${prefix}.rcsAccountNotConfiguredError`,
382
+ defaultMessage: 'RCS account is not configured. Please contact your Customer Success Manager to fix the issue.',
383
+ },
372
384
  senderNotConfiguredError: {
373
385
  id: `${prefix}.senderNotConfiguredError`,
374
386
  defaultMessage: 'Selected domain gateway id is not correct. Please change the domain id or contact the gateway team to register them with Capillary.',
@@ -51,6 +51,7 @@ const ChannelSelectionStep = ({
51
51
  selectedOfferDetails = [],
52
52
  incentivesData,
53
53
  deliverySettingsData,
54
+ onRcsAccountPendingChange,
54
55
  error,
55
56
  intl,
56
57
  capData, // From Redux - contains user/org info needed by CouponsWrapper
@@ -490,6 +491,7 @@ const ChannelSelectionStep = ({
490
491
  deliverySetting={value?.deliverySetting}
491
492
  onDeliverySettingChange={(deliverySetting) => onChange({ deliverySetting })}
492
493
  onDomainPropertiesLoaded={setDomainPropertiesData}
494
+ onRcsAccountPendingChange={onRcsAccountPendingChange}
493
495
  orgUnitId={config?.context?.ouId}
494
496
  domainPropertiesPriority={config?.context?.domainPropertiesPriority}
495
497
  intl={intl}
@@ -585,6 +587,8 @@ ChannelSelectionStep.propTypes = {
585
587
  enabled: PropTypes.bool,
586
588
  }),
587
589
  deliverySettingsData: PropTypes.object,
590
+ /** Reports whether the RCS template's account lookup is pending / failed (Save is blocked meanwhile). */
591
+ onRcsAccountPendingChange: PropTypes.func,
588
592
  error: PropTypes.string,
589
593
  intl: PropTypes.object.isRequired,
590
594
  capData: PropTypes.object, // Cap data from Redux (user/org info)
@@ -594,6 +598,7 @@ ChannelSelectionStep.propTypes = {
594
598
 
595
599
  ChannelSelectionStep.defaultProps = {
596
600
  value: null,
601
+ onRcsAccountPendingChange: undefined,
597
602
  channels: [],
598
603
  communicationStrategy: null,
599
604
  error: null,