@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
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
3
3
 
4
4
  import { Templates } from '../index';
5
+ import ChannelTypeIllustration from '../ChannelTypeIllustration';
5
6
  import mockdata from '../../mockdata';
6
7
  import { rcsTemplates, senderDetailsRcs } from './mockData';
7
8
  import { exportEmailTemplateHtml } from '../../../utils/downloadFile';
@@ -454,6 +455,8 @@ describe('Test Templates container', () => {
454
455
  Global: { user: { accessiblePermissions: [PERMISSIONS.CREATIVE_EDIT] } },
455
456
  actions: { ...renderedComponent.props().actions, resetTemplateData: jest.fn() },
456
457
  });
458
+ // A configured account (its domain was found), so the RCS templates are listed.
459
+ renderedComponent.setState({ hostName: 'ics' });
457
460
  });
458
461
 
459
462
  it('does not render the Duplicate menu item for RCS', () => {
@@ -499,6 +502,115 @@ describe('Test Templates container', () => {
499
502
  });
500
503
  });
501
504
 
505
+ describe('RCS multi-account (same as WhatsApp)', () => {
506
+ const accountA = { id: 1, name: 'Brand A', sourceAccountIdentifier: 'acc-A', configs: { accessToken: 'token-A' } };
507
+ const accountB = { id: 2, name: 'Brand B', sourceAccountIdentifier: 'acc-B', configs: { accessToken: 'token-B' } };
508
+ const accountUnconfigured = { id: 3, name: 'Brand C', sourceAccountIdentifier: 'acc-C', configs: { accessToken: 'token-C' } };
509
+ const rcsDomain = (hostName, sourceAccountIdentifier) => ({
510
+ domainProperties: { hostName, domainName: `${hostName}-${sourceAccountIdentifier}`, connectionProperties: { sourceAccountIdentifier } },
511
+ });
512
+ const domainProperties = [rcsDomain('ics', 'acc-A'), rcsDomain('infobip', 'acc-B')];
513
+
514
+ const renderRcsWithAccounts = () => {
515
+ RenderFunctionFor('rcs', true);
516
+ renderedComponent.setProps({
517
+ Templates: {
518
+ ...rcsTemplates,
519
+ weCrmAccounts: [accountA, accountB, accountUnconfigured],
520
+ senderDetails: { domainProperties },
521
+ },
522
+ });
523
+ getAllTemplates.mockClear();
524
+ };
525
+
526
+ const findByType = (node, type, seen = new Set()) => {
527
+ if (!node || typeof node !== 'object' || seen.has(node)) return null;
528
+ seen.add(node);
529
+ if (Array.isArray(node)) {
530
+ for (let i = 0; i < node.length; i += 1) {
531
+ const found = findByType(node[i], type, seen);
532
+ if (found) return found;
533
+ }
534
+ return null;
535
+ }
536
+ if (node.type === type) return node;
537
+ return node.props ? findByType(node.props.children, type, seen) : null;
538
+ };
539
+ const getGrid = (templates) => renderedComponent.instance().getTemplateDataForGrid({
540
+ templates,
541
+ handlers: { handlePreviewClick: jest.fn(), handleEditClick: jest.fn() },
542
+ filterContent: null,
543
+ channel: 'rcs',
544
+ isLoading: false,
545
+ isInitialLoading: false,
546
+ loadingTip: '',
547
+ previewTemplateId: null,
548
+ });
549
+
550
+ it('selecting an account picks the domain whose connectionProperties hold its sourceAccountIdentifier and loads its templates', () => {
551
+ renderRcsWithAccounts();
552
+ renderedComponent.instance().onAccountSelect({ target: { value: 'Brand B' } });
553
+
554
+ expect(renderedComponent.state('hostName')).toBe('infobip');
555
+ expect(setChannelAccount).toHaveBeenCalledWith('RCS', expect.objectContaining({
556
+ name: 'Brand B',
557
+ hostName: 'infobip',
558
+ connectionProperties: { sourceAccountIdentifier: 'acc-B' },
559
+ }));
560
+ expect(getAllTemplates).toHaveBeenCalledWith(
561
+ 'Rcs',
562
+ expect.objectContaining({ accountId: 'acc-B', host: 'infobip', accessToken: 'token-B' }),
563
+ expect.anything(),
564
+ );
565
+ });
566
+
567
+ it('selecting an account with no matching domain makes no listing call and leaves hostName empty', () => {
568
+ renderRcsWithAccounts();
569
+ renderedComponent.instance().onAccountSelect({ target: { value: 'Brand C' } });
570
+
571
+ expect(renderedComponent.state('hostName')).toBe('');
572
+ expect(getAllTemplates).not.toHaveBeenCalled();
573
+ });
574
+
575
+ it('shows "RCS account is not configured" and hides any templates when hostName is empty', () => {
576
+ renderRcsWithAccounts();
577
+ renderedComponent.setState({ hostName: '' });
578
+ const approvedRcsTemplate = {
579
+ _id: 'rcs_1',
580
+ versions: { base: { content: { RCS: { rcsContent: { cardContent: [{ Status: 'approved' }] } } } } },
581
+ };
582
+ const grid = getGrid([approvedRcsTemplate]);
583
+ const illustration = findByType(grid, ChannelTypeIllustration);
584
+
585
+ expect(illustration).not.toBeNull();
586
+ expect(illustration.props.hostName).toBe('');
587
+ expect(illustration.props.currentChannel).toBe('RCS');
588
+ expect(findByClassName(grid, 'v2-pagination-container')).toBeNull();
589
+ });
590
+
591
+ it('still shows "RCS account is not configured" when a search term is carried over from another account', () => {
592
+ renderRcsWithAccounts();
593
+ renderedComponent.setState({ hostName: '', searchText: 'promo' });
594
+ const grid = getGrid([]);
595
+ const illustration = findByType(grid, ChannelTypeIllustration);
596
+
597
+ expect(illustration).not.toBeNull();
598
+ expect(illustration.props.hostName).toBe('');
599
+ expect(findByClassName(grid, 'v2-pagination-container')).toBeNull();
600
+ });
601
+
602
+ it('does not show the not-configured illustration when the account has a domain', () => {
603
+ renderRcsWithAccounts();
604
+ renderedComponent.setState({ hostName: 'ics' });
605
+ const approvedRcsTemplate = {
606
+ _id: 'rcs_1',
607
+ versions: { base: { content: { RCS: { rcsContent: { cardContent: [{ Status: 'approved' }] } } } } },
608
+ };
609
+
610
+ expect(findByType(getGrid([approvedRcsTemplate]), ChannelTypeIllustration)).toBeNull();
611
+ });
612
+ });
613
+
502
614
  describe('Mobile push grid tile buttons', () => {
503
615
  it('renders button labels as typed with index keys, so duplicate labels do not clash', () => {
504
616
  RenderFunctionFor('whatsapp', true);
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap
3
- size: 57295127 bytes
4
- sha256: 3ca4752bd0410b9d7f0e57070855228ef817cc04531f23794bf27e2647b4f7a2
3
+ size: 57314643 bytes
4
+ sha256: e123f90b6beb59289ba6f90039d32038f3a4b9b171fe72479d467ac657b3feba