@capillarytech/creatives-library 9.2.2 → 9.2.4-alpha.feature-rcs-multi-account.51
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +59 -14
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +158 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +16 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +7 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +44 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +21 -8
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +18 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +66 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/accountUtils.js +20 -0
- package/v2Containers/Rcs/index.js +18 -1
- package/v2Containers/Rcs/tests/accountUtils.test.js +24 -0
- package/v2Containers/Rcs/tests/index.test.js +23 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +94 -85
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +182 -0
|
@@ -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', () => {
|
|
@@ -498,4 +501,183 @@ describe('Test Templates container', () => {
|
|
|
498
501
|
expect(renderedComponent.instance().getCreativesParams()).not.toHaveProperty('openTestAndPreview');
|
|
499
502
|
});
|
|
500
503
|
});
|
|
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('does not show the not-configured illustration when the account has a domain', () => {
|
|
592
|
+
renderRcsWithAccounts();
|
|
593
|
+
renderedComponent.setState({ hostName: 'ics' });
|
|
594
|
+
const approvedRcsTemplate = {
|
|
595
|
+
_id: 'rcs_1',
|
|
596
|
+
versions: { base: { content: { RCS: { rcsContent: { cardContent: [{ Status: 'approved' }] } } } } },
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
expect(findByType(getGrid([approvedRcsTemplate]), ChannelTypeIllustration)).toBeNull();
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
describe('Mobile push grid tile buttons', () => {
|
|
604
|
+
it('renders button labels as typed with index keys, so duplicate labels do not clash', () => {
|
|
605
|
+
RenderFunctionFor('whatsapp', true);
|
|
606
|
+
|
|
607
|
+
const cardDataList = renderedComponent.instance().getTemplateDataForGrid({
|
|
608
|
+
templates: [{
|
|
609
|
+
_id: 'mpush_1',
|
|
610
|
+
name: 'Push Template',
|
|
611
|
+
versions: {
|
|
612
|
+
base: {
|
|
613
|
+
ANDROID: {
|
|
614
|
+
title: 'Title',
|
|
615
|
+
message: 'Body',
|
|
616
|
+
expandableDetails: { ctas: [{ actionText: 'Shop' }, { actionText: 'Shop' }] },
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
},
|
|
620
|
+
}],
|
|
621
|
+
handlers: { handlePreviewClick: jest.fn(), handleEditClick: jest.fn() },
|
|
622
|
+
filterContent: null,
|
|
623
|
+
channel: 'mobilepush',
|
|
624
|
+
isLoading: false,
|
|
625
|
+
isInitialLoading: false,
|
|
626
|
+
loadingTip: '',
|
|
627
|
+
previewTemplateId: null,
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const buttons = findByClassName(cardDataList, 'mobilepush-container').props.children
|
|
631
|
+
.find((child) => child?.props?.className === 'actions').props.children;
|
|
632
|
+
expect(buttons.map((button) => button.key)).toEqual(['action-0', 'action-1']);
|
|
633
|
+
expect(buttons.map((button) => button.props.children)).toEqual(['Shop', 'Shop']);
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
describe('Mobile push Test & Preview content from the list', () => {
|
|
638
|
+
it('maps each saved video to the { videoSrc, videoPreview } shape the preview reads', () => {
|
|
639
|
+
RenderFunctionFor('whatsapp', true);
|
|
640
|
+
|
|
641
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
642
|
+
versions: {
|
|
643
|
+
base: {
|
|
644
|
+
ANDROID: {
|
|
645
|
+
title: 'A',
|
|
646
|
+
expandableDetails: { media: [{ url: 'https://a.mp4', type: 'VIDEO', videoPreviewUrl: 'https://a.jpg' }] },
|
|
647
|
+
},
|
|
648
|
+
IOS: {
|
|
649
|
+
title: 'I',
|
|
650
|
+
expandableDetails: { media: [{ url: 'https://i.mp4', type: 'VIDEO' }] },
|
|
651
|
+
},
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
}, 'MOBILEPUSH');
|
|
655
|
+
|
|
656
|
+
expect(result.androidContent.bodyVideo).toEqual({ videoSrc: 'https://a.mp4', videoPreview: 'https://a.jpg' });
|
|
657
|
+
expect(result.iosContent.bodyVideo).toEqual({ videoSrc: 'https://i.mp4', videoPreview: '' });
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
it('gives no video for a text template', () => {
|
|
661
|
+
RenderFunctionFor('whatsapp', true);
|
|
662
|
+
|
|
663
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
664
|
+
versions: { base: { ANDROID: { title: 'A', expandableDetails: { style: 'BIG_TEXT' } } } },
|
|
665
|
+
}, 'MOBILEPUSH');
|
|
666
|
+
|
|
667
|
+
expect(result.androidContent.bodyVideo).toEqual({});
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it('passes each saved notification tap (cta) for the test send', () => {
|
|
671
|
+
RenderFunctionFor('whatsapp', true);
|
|
672
|
+
const androidCta = { type: 'DEEP_LINK', actionLink: 'app://home' };
|
|
673
|
+
const iosCta = { type: 'EXTERNAL_URL', actionLink: 'https://x.com' };
|
|
674
|
+
|
|
675
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
676
|
+
versions: { base: { ANDROID: { title: 'A', cta: androidCta }, IOS: { title: 'I', cta: iosCta } } },
|
|
677
|
+
}, 'MOBILEPUSH');
|
|
678
|
+
|
|
679
|
+
expect(result.androidContent.cta).toEqual(androidCta);
|
|
680
|
+
expect(result.iosContent.cta).toEqual(iosCta);
|
|
681
|
+
});
|
|
682
|
+
});
|
|
501
683
|
});
|