cap-creatives-ui 8.0.280 → 8.0.321
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/.github/workflows/pr-title-check.yml +88 -0
- package/app/constants/unified.js +21 -1
- package/app/containers/App/constants.js +0 -1
- package/app/containers/Login/test/index.test.js +123 -0
- package/app/containers/Login/test/selectors.test.js +165 -0
- package/app/initialState.js +0 -2
- package/app/services/api.js +6 -0
- package/app/services/tests/api.test.js +7 -0
- package/app/services/tests/getSchema.test.js +95 -0
- package/app/utils/common.js +23 -9
- package/app/utils/commonUtils.js +64 -93
- package/app/utils/tagValidations.js +83 -219
- package/app/utils/templateVarUtils.js +172 -0
- package/app/utils/tests/common.test.js +265 -323
- package/app/utils/tests/commonUtil.test.js +461 -118
- package/app/utils/tests/commonUtils.test.js +581 -0
- package/app/utils/tests/messageUtils.test.js +95 -0
- package/app/utils/tests/smsCharCount.test.js +304 -0
- package/app/utils/tests/smsCharCountV2.test.js +213 -10
- package/app/utils/tests/tagValidations.test.js +474 -357
- package/app/utils/tests/templateVarUtils.test.js +160 -0
- package/app/v2Components/CapDeviceContent/index.js +10 -7
- package/app/v2Components/CapTagList/index.js +32 -24
- package/app/v2Components/CapTagList/style.scss +48 -0
- package/app/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
- package/app/v2Components/CapTagListWithInput/index.js +8 -0
- package/app/v2Components/CapWhatsappCTA/index.js +2 -0
- package/app/v2Components/CapWhatsappCarouselButton/index.js +32 -14
- package/app/v2Components/CapWhatsappCarouselButton/tests/index.test.js +120 -2
- package/app/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +39 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +606 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +36 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +79 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/index.js +314 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +141 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +156 -0
- package/app/v2Components/CommonTestAndPreview/SendTestMessage.js +57 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +20 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
- package/app/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +210 -4
- package/app/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/app/v2Components/CommonTestAndPreview/constants.js +57 -1
- package/app/v2Components/CommonTestAndPreview/index.js +878 -156
- package/app/v2Components/CommonTestAndPreview/messages.js +41 -3
- package/app/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/app/v2Components/CommonTestAndPreview/reducer.js +47 -0
- package/app/v2Components/CommonTestAndPreview/sagas.js +75 -5
- package/app/v2Components/CommonTestAndPreview/selectors.js +51 -0
- package/app/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +352 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +1156 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +334 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +576 -0
- package/app/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +156 -0
- package/app/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
- package/app/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
- package/app/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -7
- package/app/v2Components/CommonTestAndPreview/tests/index.test.js +914 -5
- package/app/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/app/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
- package/app/v2Components/CommonTestAndPreview/tests/sagas.test.js +146 -378
- package/app/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
- package/app/v2Components/ErrorInfoNote/index.js +24 -26
- package/app/v2Components/FormBuilder/index.js +182 -204
- package/app/v2Components/FormBuilder/messages.js +4 -8
- package/app/v2Components/HtmlEditor/HTMLEditor.js +7 -6
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -1
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +928 -17
- package/app/v2Components/HtmlEditor/components/CodeEditorPane/index.js +4 -2
- package/app/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +452 -3
- package/app/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
- package/app/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
- package/app/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
- package/app/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
- package/app/v2Components/SmsFallback/constants.js +73 -0
- package/app/v2Components/SmsFallback/index.js +956 -0
- package/app/v2Components/SmsFallback/index.scss +265 -0
- package/app/v2Components/SmsFallback/messages.js +78 -0
- package/app/v2Components/SmsFallback/smsFallbackUtils.js +107 -0
- package/app/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/app/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +261 -0
- package/app/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/app/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
- package/app/v2Components/TestAndPreviewSlidebox/index.js +22 -1
- package/app/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/app/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/app/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/app/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/app/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/app/v2Containers/BeeEditor/index.js +3 -0
- package/app/v2Containers/BeePopupEditor/index.js +9 -2
- package/app/v2Containers/Cap/mockData.js +0 -14
- package/app/v2Containers/Cap/reducer.js +3 -55
- package/app/v2Containers/Cap/tests/reducer.test.js +0 -102
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.js +291 -0
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.scss +25 -0
- package/app/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +255 -0
- package/app/v2Containers/CommunicationFlow/constants.js +200 -0
- package/app/v2Containers/CommunicationFlow/index.js +102 -0
- package/app/v2Containers/CommunicationFlow/messages.js +346 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +522 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +170 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +796 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +95 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/Tests/CommunicationStrategyStep.test.js +133 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +289 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.scss +70 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +319 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.scss +69 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +616 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +577 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +1111 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +696 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/index.js +7 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.js +102 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.scss +36 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/Tests/DynamicControlsStep.test.js +91 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/MessageTypeStep.js +86 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/Tests/MessageTypeStep.test.js +100 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +30 -0
- package/app/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/app/v2Containers/CreativesContainer/SlideBoxContent.js +127 -11
- package/app/v2Containers/CreativesContainer/SlideBoxFooter.js +62 -9
- package/app/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/app/v2Containers/CreativesContainer/constants.js +24 -0
- package/app/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
- package/app/v2Containers/CreativesContainer/index.js +346 -71
- package/app/v2Containers/CreativesContainer/index.scss +51 -1
- package/app/v2Containers/CreativesContainer/messages.js +12 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +69 -1
- package/app/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +443 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +110 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -4
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +363 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +57 -10
- package/app/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/app/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/app/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/app/v2Containers/Email/index.js +2 -5
- package/app/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +58 -77
- package/app/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +158 -89
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
- package/app/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +17 -12
- package/app/v2Containers/EmailWrapper/index.js +4 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +133 -0
- package/app/v2Containers/FTP/index.js +2 -51
- package/app/v2Containers/FTP/messages.js +0 -4
- package/app/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +110 -155
- package/app/v2Containers/InApp/index.js +297 -118
- package/app/v2Containers/InApp/tests/index.test.js +17 -6
- package/app/v2Containers/InApp/tests/mockData.js +1 -1
- package/app/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +19 -0
- package/app/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +3 -0
- package/app/v2Containers/InAppWrapper/index.js +3 -0
- package/app/v2Containers/InappAdvance/index.js +5 -104
- package/app/v2Containers/InappAdvance/tests/index.test.js +2 -0
- package/app/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +24 -3
- package/app/v2Containers/Line/Container/Text/index.js +0 -1
- package/app/v2Containers/MobilePush/Create/index.js +105 -28
- package/app/v2Containers/MobilePush/Create/messages.js +4 -0
- package/app/v2Containers/MobilePush/Edit/index.js +250 -68
- package/app/v2Containers/MobilePush/Edit/messages.js +4 -0
- package/app/v2Containers/MobilePushNew/components/PlatformContentFields.js +36 -12
- package/app/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +68 -27
- package/app/v2Containers/MobilePushNew/index.js +78 -35
- package/app/v2Containers/MobilePushNew/messages.js +8 -0
- package/app/v2Containers/MobilepushWrapper/index.js +11 -1
- package/app/v2Containers/Rcs/constants.js +32 -1
- package/app/v2Containers/Rcs/index.js +963 -916
- package/app/v2Containers/Rcs/index.scss +85 -6
- package/app/v2Containers/Rcs/messages.js +10 -1
- package/app/v2Containers/Rcs/rcsLibraryHydrationUtils.js +205 -0
- package/app/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +41136 -1566
- package/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/app/v2Containers/Rcs/tests/index.test.js +41 -38
- package/app/v2Containers/Rcs/tests/mockData.js +38 -0
- package/app/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +251 -0
- package/app/v2Containers/Rcs/tests/utils.test.js +379 -1
- package/app/v2Containers/Rcs/utils.js +358 -10
- package/app/v2Containers/Sms/Create/index.js +122 -39
- package/app/v2Containers/Sms/Create/messages.js +4 -0
- package/app/v2Containers/Sms/Edit/index.js +37 -3
- package/app/v2Containers/Sms/commonMethods.js +3 -6
- package/app/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/app/v2Containers/Sms/tests/commonMethods.test.js +122 -0
- package/app/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/app/v2Containers/SmsTrai/Create/index.js +9 -4
- package/app/v2Containers/SmsTrai/Create/index.scss +1 -1
- package/app/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/app/v2Containers/SmsTrai/Edit/index.js +667 -160
- package/app/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/app/v2Containers/SmsTrai/Edit/messages.js +9 -4
- package/app/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4590 -2436
- package/app/v2Containers/SmsWrapper/index.js +41 -8
- package/app/v2Containers/TagList/index.js +63 -2
- package/app/v2Containers/TagList/messages.js +8 -0
- package/app/v2Containers/TagList/tests/TagList.test.js +122 -20
- package/app/v2Containers/TagList/tests/mockdata.js +17 -0
- package/app/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/app/v2Containers/Templates/_templates.scss +61 -2
- package/app/v2Containers/Templates/actions.js +11 -0
- package/app/v2Containers/Templates/constants.js +2 -0
- package/app/v2Containers/Templates/index.js +90 -40
- package/app/v2Containers/Templates/reducer.js +3 -1
- package/app/v2Containers/Templates/sagas.js +57 -12
- package/app/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/app/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1043 -1079
- package/app/v2Containers/Templates/tests/reducer.test.js +12 -0
- package/app/v2Containers/Templates/tests/sagas.test.js +193 -12
- package/app/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/app/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/app/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/app/v2Containers/TemplatesV2/index.js +147 -49
- package/app/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/app/v2Containers/Viber/index.js +9 -10
- package/app/v2Containers/Viber/index.scss +1 -1
- package/app/v2Containers/WebPush/Create/components/BrandIconSection.test.js +264 -0
- package/app/v2Containers/WebPush/Create/components/MessageSection.js +78 -19
- package/app/v2Containers/WebPush/Create/components/MessageSection.test.js +82 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/BrandIconSection.test.js.snap +187 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +25 -17
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.js +80 -0
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.test.js +210 -0
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -5
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
- package/app/v2Containers/WebPush/Create/index.js +36 -6
- package/app/v2Containers/WebPush/Create/index.scss +5 -0
- package/app/v2Containers/WebPush/Create/messages.js +8 -1
- package/app/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +269 -0
- package/app/v2Containers/WebPush/Create/utils/validation.js +31 -15
- package/app/v2Containers/WebPush/Create/utils/validation.test.js +72 -24
- package/app/v2Containers/Whatsapp/index.js +28 -53
- package/app/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26939 -3982
- package/app/v2Containers/Whatsapp/tests/index.test.js +172 -0
- package/app/v2Containers/Zalo/index.js +5 -11
- package/package.json +2 -2
- package/version +9 -0
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import { render, screen } from '../../../utils/test-utils';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getRCSContent,
|
|
6
|
+
getRcsStatusType,
|
|
7
|
+
getTemplateStatusType,
|
|
8
|
+
normalizeCardVarMapped,
|
|
9
|
+
coalesceCardVarMappedToTemplate,
|
|
10
|
+
resolveCardVarMappedSlotValue,
|
|
11
|
+
isRcsTextOnlyCardMediaType,
|
|
12
|
+
mapRcsCardContentForConsumerWithResolvedTags,
|
|
13
|
+
resolveRcsCardPreviewStrings,
|
|
14
|
+
sanitizeCardVarMappedValue,
|
|
15
|
+
areAllRcsSmsFallbackVarSlotsFilled,
|
|
16
|
+
buildRcsNumericMustachePlaceholderRegex,
|
|
17
|
+
} from '../utils';
|
|
18
|
+
import { rcsVarRegex } from '../constants';
|
|
5
19
|
import { RCS, RCS_BUTTON_TYPES, STATUS_OPTIONS, RCS_STATUSES } from '../constants';
|
|
6
20
|
import { mockData } from './mockData';
|
|
7
21
|
|
|
@@ -59,6 +73,25 @@ describe('RCS utils - renderRcsSuggestionsPreview', () => {
|
|
|
59
73
|
expect(labels.length).toBe(1);
|
|
60
74
|
expect(labels[0].textContent).toContain('Call');
|
|
61
75
|
});
|
|
76
|
+
|
|
77
|
+
it('renders only divider for unknown suggestion type', () => {
|
|
78
|
+
const template = JSON.parse(JSON.stringify(templateBase));
|
|
79
|
+
template.versions.base.content[RCS].rcsContent.cardContent[0].suggestions = [
|
|
80
|
+
{ type: RCS_BUTTON_TYPES.NONE, text: 'Ignored' },
|
|
81
|
+
];
|
|
82
|
+
render(getRCSContent(template));
|
|
83
|
+
expect(document.querySelectorAll('.rcs-cta-preview').length).toBe(0);
|
|
84
|
+
expect(document.querySelectorAll('.whatsapp-divider').length).toBeGreaterThan(0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('prefers thumbnailUrl over mediaUrl for preview image', () => {
|
|
88
|
+
const template = JSON.parse(JSON.stringify(templateBase));
|
|
89
|
+
const card = template.versions.base.content[RCS].rcsContent.cardContent[0];
|
|
90
|
+
card.media = { thumbnailUrl: 'thumb.jpg', mediaUrl: 'full.jpg' };
|
|
91
|
+
render(getRCSContent(template));
|
|
92
|
+
const img = document.querySelector('.rcs-listing-image');
|
|
93
|
+
expect(img?.getAttribute('src')).toBe('thumb.jpg');
|
|
94
|
+
});
|
|
62
95
|
});
|
|
63
96
|
|
|
64
97
|
describe('RCS utils', () => {
|
|
@@ -136,4 +169,349 @@ describe('RCS utils', () => {
|
|
|
136
169
|
expect(getTemplateStatusType('some_unknown_status')).toBe('warning');
|
|
137
170
|
});
|
|
138
171
|
});
|
|
172
|
+
|
|
173
|
+
describe('normalizeCardVarMapped', () => {
|
|
174
|
+
it('maps numeric key + placeholder value to tag name', () => {
|
|
175
|
+
expect(normalizeCardVarMapped({ 1: '{{user_id_b64}}' })).toEqual({ user_id_b64: '' });
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('maps numeric key + literal value when orderedTagNames is provided', () => {
|
|
179
|
+
expect(
|
|
180
|
+
normalizeCardVarMapped({ 1: 'hello' }, ['user_id_b64']),
|
|
181
|
+
).toEqual({ user_id_b64: 'hello' });
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('keeps numeric key when no orderedTagNames for literal value', () => {
|
|
185
|
+
expect(normalizeCardVarMapped({ 1: 'hello' })).toEqual({ 1: 'hello' });
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('keeps semantic key + different tag token (TagList value)', () => {
|
|
189
|
+
expect(normalizeCardVarMapped({ myKey: '{{tag}}' })).toEqual({ myKey: '{{tag}}' });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('maps numeric slot + chosen tag onto template token when ordered names provided', () => {
|
|
193
|
+
expect(
|
|
194
|
+
normalizeCardVarMapped({ 1: '{{FirstName}}' }, ['user_name']),
|
|
195
|
+
).toEqual({ user_name: '{{FirstName}}' });
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('returns {} for null, undefined, or non-object raw', () => {
|
|
199
|
+
expect(normalizeCardVarMapped(null)).toEqual({});
|
|
200
|
+
expect(normalizeCardVarMapped(undefined)).toEqual({});
|
|
201
|
+
expect(normalizeCardVarMapped('not-object')).toEqual({});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('maps numeric key to order slot only when index is within orderedTagNames', () => {
|
|
205
|
+
expect(normalizeCardVarMapped({ 3: 'z' }, ['a', 'b'])).toEqual({ 3: 'z' });
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('does not overwrite a literal slot value with a duplicate semantic placeholder entry', () => {
|
|
209
|
+
expect(
|
|
210
|
+
normalizeCardVarMapped(
|
|
211
|
+
{ 1: 'hello', user_id_b64: '{{user_id_b64}}' },
|
|
212
|
+
['user_id_b64'],
|
|
213
|
+
),
|
|
214
|
+
).toEqual({ user_id_b64: 'hello' });
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('coalesceCardVarMappedToTemplate', () => {
|
|
219
|
+
it('maps slot 1 to first token name from title', () => {
|
|
220
|
+
expect(
|
|
221
|
+
coalesceCardVarMappedToTemplate(
|
|
222
|
+
{ 1: 'abc' },
|
|
223
|
+
'Hi {{user_name}}',
|
|
224
|
+
'',
|
|
225
|
+
rcsVarRegex,
|
|
226
|
+
),
|
|
227
|
+
).toEqual({ 1: 'abc', user_name: 'abc' });
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('keeps {{1}} style token as key 1', () => {
|
|
231
|
+
expect(
|
|
232
|
+
coalesceCardVarMappedToTemplate(
|
|
233
|
+
{ 1: '' },
|
|
234
|
+
'Hi {{1}}',
|
|
235
|
+
'',
|
|
236
|
+
rcsVarRegex,
|
|
237
|
+
),
|
|
238
|
+
).toEqual({ 1: '' });
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('returns clone when no tokens', () => {
|
|
242
|
+
const raw = { 1: 'x' };
|
|
243
|
+
const out = coalesceCardVarMappedToTemplate(raw, 'no vars', '', rcsVarRegex);
|
|
244
|
+
expect(out).toEqual({ 1: 'x' });
|
|
245
|
+
expect(out).not.toBe(raw);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('merges tokens from title and description', () => {
|
|
249
|
+
const out = coalesceCardVarMappedToTemplate(
|
|
250
|
+
{ a: '1', b: '2' },
|
|
251
|
+
'T {{a}}',
|
|
252
|
+
'D {{b}}',
|
|
253
|
+
rcsVarRegex,
|
|
254
|
+
);
|
|
255
|
+
expect(out).toEqual({ a: '1', b: '2', 1: '1', 2: '2' });
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('returns {} when there are no tokens and raw is null or not an object', () => {
|
|
259
|
+
expect(coalesceCardVarMappedToTemplate(null, 'plain', '', rcsVarRegex)).toEqual({});
|
|
260
|
+
expect(coalesceCardVarMappedToTemplate(undefined, 'plain', '', rcsVarRegex)).toEqual({});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('fills token values from legacy numeric slots when named key is missing', () => {
|
|
264
|
+
expect(
|
|
265
|
+
coalesceCardVarMappedToTemplate(
|
|
266
|
+
{ 1: 'legacy-val' },
|
|
267
|
+
'Hello {{name}}',
|
|
268
|
+
'',
|
|
269
|
+
rcsVarRegex,
|
|
270
|
+
),
|
|
271
|
+
).toEqual({ 1: 'legacy-val', name: 'legacy-val' });
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('maps values when raw is non-null but missing named keys', () => {
|
|
275
|
+
expect(
|
|
276
|
+
coalesceCardVarMappedToTemplate(
|
|
277
|
+
{},
|
|
278
|
+
'X {{a}}',
|
|
279
|
+
'',
|
|
280
|
+
rcsVarRegex,
|
|
281
|
+
),
|
|
282
|
+
).toEqual({ 1: '', a: '' });
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
describe('resolveCardVarMappedSlotValue', () => {
|
|
287
|
+
it('prefers per-slot numeric key when both semantic and numeric are present', () => {
|
|
288
|
+
expect(
|
|
289
|
+
resolveCardVarMappedSlotValue({ user_name: 'A', 1: 'B' }, 'user_name', 0),
|
|
290
|
+
).toBe('B');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('falls back to slot 1 when name missing', () => {
|
|
294
|
+
expect(resolveCardVarMappedSlotValue({ 1: 'legacy' }, 'user_name', 0)).toBe('legacy');
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('uses global slot index for second variable', () => {
|
|
298
|
+
expect(resolveCardVarMappedSlotValue({ 2: 'second' }, 'b', 1)).toBe('second');
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('reads slot from string slot key when varName has no direct mapping', () => {
|
|
302
|
+
expect(resolveCardVarMappedSlotValue({ 1: 'only-slot' }, 'missing', 0)).toBe('only-slot');
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('reads numeric object key for slot when string slot key is absent', () => {
|
|
306
|
+
expect(resolveCardVarMappedSlotValue({ 2: 'n2' }, 'x', 1)).toBe('n2');
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('returns empty when named key is cleared, not numeric slot fallback', () => {
|
|
310
|
+
expect(
|
|
311
|
+
resolveCardVarMappedSlotValue({ user_name: '', 1: 'old value' }, 'user_name', 0),
|
|
312
|
+
).toBe('');
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('library mode: semantic empty does not hide non-empty numeric slot (campaign / journey payload)', () => {
|
|
316
|
+
expect(
|
|
317
|
+
resolveCardVarMappedSlotValue(
|
|
318
|
+
{ user_id_b64: '', 1: 'selected-from-library' },
|
|
319
|
+
'user_id_b64',
|
|
320
|
+
0,
|
|
321
|
+
true,
|
|
322
|
+
),
|
|
323
|
+
).toBe('selected-from-library');
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('empty numeric slot falls back to semantic tag (preview after hydration leaves 1:"")', () => {
|
|
327
|
+
expect(
|
|
328
|
+
resolveCardVarMappedSlotValue(
|
|
329
|
+
{ promotion_points: '{{loyalty_points}}', 1: '' },
|
|
330
|
+
'promotion_points',
|
|
331
|
+
0,
|
|
332
|
+
),
|
|
333
|
+
).toBe('{{loyalty_points}}');
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
describe('mapRcsCardContentForConsumerWithResolvedTags', () => {
|
|
338
|
+
it('sets title and description to resolved tag strings on each card', () => {
|
|
339
|
+
const out = mapRcsCardContentForConsumerWithResolvedTags(
|
|
340
|
+
[
|
|
341
|
+
{
|
|
342
|
+
title: '',
|
|
343
|
+
description: 'Visit {{gt}} discount',
|
|
344
|
+
mediaType: 'NONE',
|
|
345
|
+
cardVarMapped: { gt: '{{loyalty_points}}', 1: '{{loyalty_points}}' },
|
|
346
|
+
},
|
|
347
|
+
],
|
|
348
|
+
{},
|
|
349
|
+
false,
|
|
350
|
+
);
|
|
351
|
+
expect(out[0].title).toBe('');
|
|
352
|
+
expect(out[0].description).toBe('Visit {{loyalty_points}} discount');
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('merges root rcsCardVarMapped with nested cardVarMapped', () => {
|
|
356
|
+
const out = mapRcsCardContentForConsumerWithResolvedTags(
|
|
357
|
+
[
|
|
358
|
+
{
|
|
359
|
+
title: 'Hi {{first_name}}',
|
|
360
|
+
description: 'Pts {{promotion_points}}',
|
|
361
|
+
mediaType: 'IMAGE',
|
|
362
|
+
cardVarMapped: {
|
|
363
|
+
promotion_points: '{{loyalty_points}}',
|
|
364
|
+
2: '{{loyalty_points}}',
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
{
|
|
369
|
+
first_name: '{{customer_name}}',
|
|
370
|
+
1: '{{customer_name}}',
|
|
371
|
+
},
|
|
372
|
+
false,
|
|
373
|
+
);
|
|
374
|
+
expect(out[0].title).toBe('Hi {{customer_name}}');
|
|
375
|
+
expect(out[0].description).toBe('Pts {{loyalty_points}}');
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe('isRcsTextOnlyCardMediaType', () => {
|
|
380
|
+
it('returns true for NONE and TEXT (text message card)', () => {
|
|
381
|
+
expect(isRcsTextOnlyCardMediaType('NONE')).toBe(true);
|
|
382
|
+
expect(isRcsTextOnlyCardMediaType('TEXT')).toBe(true);
|
|
383
|
+
expect(isRcsTextOnlyCardMediaType('text')).toBe(true);
|
|
384
|
+
});
|
|
385
|
+
it('returns false for rich card media', () => {
|
|
386
|
+
expect(isRcsTextOnlyCardMediaType('IMAGE')).toBe(false);
|
|
387
|
+
expect(isRcsTextOnlyCardMediaType('VIDEO')).toBe(false);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe('resolveRcsCardPreviewStrings', () => {
|
|
392
|
+
it('substitutes mapped tags for title and description (campaign preview parity)', () => {
|
|
393
|
+
const { rcsTitle, rcsDesc } = resolveRcsCardPreviewStrings(
|
|
394
|
+
'Hi {{first_name}}',
|
|
395
|
+
'Pts {{promotion_points}}',
|
|
396
|
+
{
|
|
397
|
+
first_name: '{{customer_name}}',
|
|
398
|
+
promotion_points: '{{loyalty_points}}',
|
|
399
|
+
1: '{{customer_name}}',
|
|
400
|
+
2: '{{loyalty_points}}',
|
|
401
|
+
},
|
|
402
|
+
true,
|
|
403
|
+
);
|
|
404
|
+
expect(rcsTitle).toBe('Hi {{customer_name}}');
|
|
405
|
+
expect(rcsDesc).toBe('Pts {{loyalty_points}}');
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('leaves placeholders when map has no value', () => {
|
|
409
|
+
const { rcsTitle, rcsDesc } = resolveRcsCardPreviewStrings(
|
|
410
|
+
'{{a}}',
|
|
411
|
+
'{{b}}',
|
|
412
|
+
{},
|
|
413
|
+
false,
|
|
414
|
+
);
|
|
415
|
+
expect(rcsTitle).toBe('{{a}}');
|
|
416
|
+
expect(rcsDesc).toBe('{{b}}');
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('text-only card: ignores stale title and resolves description from global slot 0', () => {
|
|
420
|
+
const { rcsTitle, rcsDesc } = resolveRcsCardPreviewStrings(
|
|
421
|
+
'Stale {{old_tag}} title',
|
|
422
|
+
'Visit Store for {{gt}} discount',
|
|
423
|
+
{ gt: '{{loyalty_points}}', 1: '{{loyalty_points}}' },
|
|
424
|
+
true,
|
|
425
|
+
true,
|
|
426
|
+
);
|
|
427
|
+
expect(rcsTitle).toBe('');
|
|
428
|
+
expect(rcsDesc).toBe('Visit Store for {{loyalty_points}} discount');
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
describe('sanitizeCardVarMappedValue', () => {
|
|
433
|
+
it('returns empty for null', () => {
|
|
434
|
+
expect(sanitizeCardVarMappedValue(null)).toBe('');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('strips numeric-only self-placeholder stored as value', () => {
|
|
438
|
+
expect(sanitizeCardVarMappedValue('{{1}}')).toBe('');
|
|
439
|
+
expect(sanitizeCardVarMappedValue('{{12}}')).toBe('');
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('keeps semantic mustache values from TagList', () => {
|
|
443
|
+
expect(sanitizeCardVarMappedValue('{{FirstName}}')).toBe('{{FirstName}}');
|
|
444
|
+
expect(sanitizeCardVarMappedValue('{{user_name}}')).toBe('{{user_name}}');
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('returns original string for non-placeholder values', () => {
|
|
448
|
+
expect(sanitizeCardVarMappedValue(' literal ')).toBe(' literal ');
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
describe('areAllRcsSmsFallbackVarSlotsFilled', () => {
|
|
453
|
+
it('returns true when template empty', () => {
|
|
454
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('', { '{{a}}_0': 'x' })).toBe(true);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('returns false when a mustache slot is only whitespace (parity with RCS title/desc vars)', () => {
|
|
458
|
+
expect(
|
|
459
|
+
areAllRcsSmsFallbackVarSlotsFilled('Hello {{name}}', { '{{name}}_1': ' ' }),
|
|
460
|
+
).toBe(false);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it('returns false when a mustache slot is missing or empty string', () => {
|
|
464
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('Hello {{name}}', {})).toBe(false);
|
|
465
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('Hello {{name}}', { '{{name}}_1': '' })).toBe(
|
|
466
|
+
false,
|
|
467
|
+
);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('returns false when a DLT {#var#} slot is empty', () => {
|
|
471
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('Hi {#x#}', { '{#x#}_1': ' ' })).toBe(false);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
it('requires mapping for {{optout}} token like any other variable', () => {
|
|
475
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('test {{optout}}', {})).toBe(false);
|
|
476
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('test {{ optout }}', {})).toBe(false);
|
|
477
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('test {{optout}}', { '{{optout}}_1': '{{optout}}' })).toBe(true);
|
|
478
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('test {{optout}}', { '{{optout}}_1': '' })).toBe(false);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it('returns true when template is missing or not a string', () => {
|
|
482
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled(null, {})).toBe(true);
|
|
483
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled(undefined, {})).toBe(true);
|
|
484
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled(123, {})).toBe(true);
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it('returns true when all variable slots have non-whitespace values', () => {
|
|
488
|
+
expect(
|
|
489
|
+
areAllRcsSmsFallbackVarSlotsFilled('Hello {{name}}', { '{{name}}_1': 'Ann' }),
|
|
490
|
+
).toBe(true);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('coerces non-string slot values with String() so DLT/hydration payloads still count as filled', () => {
|
|
494
|
+
expect(
|
|
495
|
+
areAllRcsSmsFallbackVarSlotsFilled('Hello {{name}}', { '{{name}}_1': 42 }),
|
|
496
|
+
).toBe(true);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it('accepts legacy 1-based ordinal keys when the only token is at segment index 0 (DLT / API parity)', () => {
|
|
500
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('{#shop#}', { '{#shop#}_1': 'Mart' })).toBe(true);
|
|
501
|
+
expect(areAllRcsSmsFallbackVarSlotsFilled('{#shop#}', { '{#shop#}_1': '' })).toBe(false);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
describe('buildRcsNumericMustachePlaceholderRegex', () => {
|
|
506
|
+
it('escapes regex metacharacters in numeric name', () => {
|
|
507
|
+
const re = buildRcsNumericMustachePlaceholderRegex('1.5');
|
|
508
|
+
expect(re.test('{{1.5}}')).toBe(true);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('matches simple numeric placeholder', () => {
|
|
512
|
+
const re = buildRcsNumericMustachePlaceholderRegex('2');
|
|
513
|
+
expect(re.test('{{2}}')).toBe(true);
|
|
514
|
+
expect(re.test('{{3}}')).toBe(false);
|
|
515
|
+
});
|
|
516
|
+
});
|
|
139
517
|
});
|