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
|
@@ -3,9 +3,10 @@ import { injectIntl } from 'react-intl';
|
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
4
|
import { render, screen, fireEvent } from '../../../utils/test-utils';
|
|
5
5
|
import { CapWhatsappCarouselButton } from '../index';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
7
|
INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
|
|
8
|
-
INITIAL_CAROUSEL_URL_DATA
|
|
8
|
+
INITIAL_CAROUSEL_URL_DATA,
|
|
9
|
+
URL,
|
|
9
10
|
} from '../constant';
|
|
10
11
|
import { HOST_TWILIO } from "../../../v2Containers/Whatsapp/constants";
|
|
11
12
|
|
|
@@ -234,4 +235,121 @@ describe('CapWhatsappCarouselButton', () => {
|
|
|
234
235
|
})
|
|
235
236
|
]));
|
|
236
237
|
});
|
|
238
|
+
|
|
239
|
+
describe('carousel-scoped updates (only current card is updated)', () => {
|
|
240
|
+
it('handleButtonType only updates the carousel at carouselIndex', () => {
|
|
241
|
+
const card0 = {
|
|
242
|
+
bodyText: '',
|
|
243
|
+
buttons: [{ ...INITIAL_CAROUSEL_PHONE_NUMBER_DATA, text: 'Card 0' }],
|
|
244
|
+
};
|
|
245
|
+
const card1 = {
|
|
246
|
+
bodyText: '',
|
|
247
|
+
buttons: [{ ...INITIAL_CAROUSEL_PHONE_NUMBER_DATA, text: 'Card 1' }],
|
|
248
|
+
};
|
|
249
|
+
const carouselData = [card0, card1];
|
|
250
|
+
|
|
251
|
+
initializeComponent(carouselData, false, HOST_TWILIO, 0);
|
|
252
|
+
|
|
253
|
+
const radios = screen.getAllByRole('radio');
|
|
254
|
+
const urlRadio = radios.find((r) => r.value === URL) || radios[1];
|
|
255
|
+
if (urlRadio) fireEvent.click(urlRadio);
|
|
256
|
+
|
|
257
|
+
expect(setCarouselData).toHaveBeenCalledWith(expect.any(Array));
|
|
258
|
+
const updated = setCarouselData.mock.calls[0][0];
|
|
259
|
+
expect(updated).toHaveLength(2);
|
|
260
|
+
expect(updated[0].buttons[0]).toMatchObject(INITIAL_CAROUSEL_URL_DATA);
|
|
261
|
+
expect(updated[1]).toEqual(card1);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('handleDeleteButton only removes button from the carousel at carouselIndex', () => {
|
|
265
|
+
const card0 = {
|
|
266
|
+
bodyText: '',
|
|
267
|
+
buttons: [
|
|
268
|
+
{ ...INITIAL_CAROUSEL_PHONE_NUMBER_DATA, text: 'A', isSaved: true },
|
|
269
|
+
{ ...INITIAL_CAROUSEL_URL_DATA, text: 'B', isSaved: true },
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
const card1 = {
|
|
273
|
+
bodyText: '',
|
|
274
|
+
buttons: [
|
|
275
|
+
{ ...INITIAL_CAROUSEL_PHONE_NUMBER_DATA, text: 'C', isSaved: true },
|
|
276
|
+
{ ...INITIAL_CAROUSEL_URL_DATA, text: 'D', isSaved: true },
|
|
277
|
+
],
|
|
278
|
+
};
|
|
279
|
+
const carouselData = [card0, card1];
|
|
280
|
+
|
|
281
|
+
const { container } = initializeComponent(carouselData, false, HOST_TWILIO, 0);
|
|
282
|
+
|
|
283
|
+
const deleteIconBtns = container.querySelectorAll('.whatsapp-carousel-delete-icon-btn');
|
|
284
|
+
expect(deleteIconBtns.length).toBeGreaterThanOrEqual(2);
|
|
285
|
+
fireEvent.click(deleteIconBtns[1]);
|
|
286
|
+
|
|
287
|
+
expect(setCarouselData).toHaveBeenCalledTimes(1);
|
|
288
|
+
const setter = setCarouselData.mock.calls[0][0];
|
|
289
|
+
expect(typeof setter).toBe('function');
|
|
290
|
+
const result = setter(carouselData);
|
|
291
|
+
expect(result[0].buttons).toHaveLength(1);
|
|
292
|
+
expect(result[0].buttons[0].text).toBe('A');
|
|
293
|
+
expect(result[1].buttons).toHaveLength(2);
|
|
294
|
+
expect(result[1].buttons[0].text).toBe('C');
|
|
295
|
+
expect(result[1].buttons[1].text).toBe('D');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('addCarouselButton only adds button to the carousel at carouselIndex', () => {
|
|
299
|
+
const card0 = {
|
|
300
|
+
bodyText: '',
|
|
301
|
+
buttons: [{
|
|
302
|
+
...INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
|
|
303
|
+
text: 'Call us',
|
|
304
|
+
phone_number: '9112345678',
|
|
305
|
+
isSaved: true,
|
|
306
|
+
}],
|
|
307
|
+
};
|
|
308
|
+
const card1 = {
|
|
309
|
+
bodyText: '',
|
|
310
|
+
buttons: [{ ...INITIAL_CAROUSEL_PHONE_NUMBER_DATA, text: 'Other' }],
|
|
311
|
+
};
|
|
312
|
+
const carouselData = [card0, card1];
|
|
313
|
+
|
|
314
|
+
initializeComponent(carouselData, false, HOST_TWILIO, 0);
|
|
315
|
+
|
|
316
|
+
const addButton = screen.getByRole('button', { name: /add button/i });
|
|
317
|
+
fireEvent.click(addButton);
|
|
318
|
+
|
|
319
|
+
expect(setCarouselData).toHaveBeenCalledWith(expect.any(Array));
|
|
320
|
+
const updated = setCarouselData.mock.calls[0][0];
|
|
321
|
+
expect(updated).toHaveLength(2);
|
|
322
|
+
expect(updated[0].buttons).toHaveLength(2);
|
|
323
|
+
expect(updated[0].buttons[0].text).toBe('Call us');
|
|
324
|
+
expect(updated[0].buttons[1]).toMatchObject(INITIAL_CAROUSEL_PHONE_NUMBER_DATA);
|
|
325
|
+
expect(updated[0].buttons[1]).not.toBe(INITIAL_CAROUSEL_PHONE_NUMBER_DATA);
|
|
326
|
+
expect(updated[1]).toEqual(card1);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('addCarouselButton adds a new button object (clone) so state is not shared', () => {
|
|
330
|
+
const carouselData = [{
|
|
331
|
+
bodyText: '',
|
|
332
|
+
buttons: [{
|
|
333
|
+
...INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
|
|
334
|
+
text: 'Saved',
|
|
335
|
+
isSaved: true,
|
|
336
|
+
}],
|
|
337
|
+
}];
|
|
338
|
+
|
|
339
|
+
initializeComponent(carouselData, false, HOST_TWILIO, 0);
|
|
340
|
+
|
|
341
|
+
const addButton = screen.getByRole('button', { name: /add button/i });
|
|
342
|
+
fireEvent.click(addButton);
|
|
343
|
+
|
|
344
|
+
const updated = setCarouselData.mock.calls[0][0];
|
|
345
|
+
const addedButton = updated[0].buttons[1];
|
|
346
|
+
expect(addedButton).toMatchObject({
|
|
347
|
+
buttonType: 'PHONE_NUMBER',
|
|
348
|
+
text: '',
|
|
349
|
+
phone_number: '',
|
|
350
|
+
isSaved: false,
|
|
351
|
+
});
|
|
352
|
+
expect(addedButton).not.toBe(INITIAL_CAROUSEL_PHONE_NUMBER_DATA);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
237
355
|
});
|
|
@@ -8,6 +8,7 @@ import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
|
8
8
|
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
9
9
|
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
10
10
|
import messages from './messages';
|
|
11
|
+
import { CUSTOM_VALUES_EDITOR_SECTION_FALLBACK_KEY } from './constants';
|
|
11
12
|
|
|
12
13
|
const CustomValuesEditor = ({
|
|
13
14
|
isExtractingTags,
|
|
@@ -16,15 +17,16 @@ const CustomValuesEditor = ({
|
|
|
16
17
|
setShowJSON,
|
|
17
18
|
customValues,
|
|
18
19
|
handleJSONTextChange,
|
|
19
|
-
|
|
20
|
-
requiredTags,
|
|
21
|
-
optionalTags,
|
|
20
|
+
sections,
|
|
22
21
|
handleCustomValueChange,
|
|
23
22
|
handleDiscardCustomValues,
|
|
24
23
|
handleUpdatePreview,
|
|
25
24
|
isUpdatingPreview,
|
|
26
25
|
formatMessage,
|
|
27
26
|
}) => {
|
|
27
|
+
/** Same as SMS Test & Preview: show token path from extract-tags (fullPath or name). */
|
|
28
|
+
const getPersonalizationTagColumnLabel = (tagNode) => tagNode?.fullPath ?? tagNode?.name ?? '';
|
|
29
|
+
|
|
28
30
|
if (isExtractingTags) {
|
|
29
31
|
return (
|
|
30
32
|
<CapRow className="loading-container">
|
|
@@ -77,52 +79,68 @@ const CustomValuesEditor = ({
|
|
|
77
79
|
</CapRow>
|
|
78
80
|
) : (
|
|
79
81
|
<>
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<CapLabel type="label31" className="header-cell">
|
|
87
|
-
<FormattedMessage {...messages.customValues} />
|
|
82
|
+
{(sections || []).filter((tagsSection) =>
|
|
83
|
+
(tagsSection?.requiredTags?.length || 0) + (tagsSection?.optionalTags?.length || 0) > 0).map((section) => (
|
|
84
|
+
<React.Fragment key={section.key || section.title?.id || section.title || CUSTOM_VALUES_EDITOR_SECTION_FALLBACK_KEY}>
|
|
85
|
+
{section.title ? (
|
|
86
|
+
<CapLabel type="label2" className="tags-section-title">
|
|
87
|
+
{typeof section.title === 'string' ? section.title : <FormattedMessage {...section.title} />}
|
|
88
88
|
</CapLabel>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<CapRow
|
|
92
|
-
<
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
type="text"
|
|
99
|
-
isRequired
|
|
100
|
-
className="tag-input-field"
|
|
101
|
-
value={customValues[tag.fullPath] || ''}
|
|
102
|
-
onChange={(e) => handleCustomValueChange(tag.fullPath, e.target.value)}
|
|
103
|
-
placeholder={formatMessage(messages.enterValue)}
|
|
104
|
-
size="small"
|
|
105
|
-
/>
|
|
106
|
-
</CapRow>
|
|
89
|
+
) : null}
|
|
90
|
+
<CapRow className="values-table">
|
|
91
|
+
<CapRow className="table-header">
|
|
92
|
+
<CapLabel type="label31" className="header-cell">
|
|
93
|
+
<FormattedMessage {...messages.personalizationTags} />
|
|
94
|
+
</CapLabel>
|
|
95
|
+
<CapLabel type="label31" className="header-cell">
|
|
96
|
+
<FormattedMessage {...messages.customValues} />
|
|
97
|
+
</CapLabel>
|
|
107
98
|
</CapRow>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<CapRow className="
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
99
|
+
{(section?.requiredTags || []).map((tag, tagIndex) => {
|
|
100
|
+
const personalizationTagColumnText = getPersonalizationTagColumnLabel(tag);
|
|
101
|
+
return (
|
|
102
|
+
<CapRow key={tag?.fullPath ?? `required-${tagIndex}`} className="value-row">
|
|
103
|
+
<CapRow className="tag-name">
|
|
104
|
+
{personalizationTagColumnText}
|
|
105
|
+
<span className="required-tag-indicator">*</span>
|
|
106
|
+
</CapRow>
|
|
107
|
+
<CapRow className="tag-input">
|
|
108
|
+
<CapInput
|
|
109
|
+
type="text"
|
|
110
|
+
isRequired
|
|
111
|
+
className="tag-input-field"
|
|
112
|
+
value={customValues?.[tag?.fullPath] ?? ''}
|
|
113
|
+
onChange={(e) => handleCustomValueChange(tag?.fullPath, e.target.value)}
|
|
114
|
+
placeholder={formatMessage(messages.enterValue)}
|
|
115
|
+
size="small"
|
|
116
|
+
/>
|
|
117
|
+
</CapRow>
|
|
121
118
|
</CapRow>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
);
|
|
120
|
+
})}
|
|
121
|
+
{(section?.optionalTags || []).map((tag, tagIndex) => {
|
|
122
|
+
const personalizationTagColumnText = getPersonalizationTagColumnLabel(tag);
|
|
123
|
+
return (
|
|
124
|
+
<CapRow key={tag?.fullPath ?? `optional-${tagIndex}`} className="value-row">
|
|
125
|
+
<CapRow className="tag-name">
|
|
126
|
+
{personalizationTagColumnText}
|
|
127
|
+
</CapRow>
|
|
128
|
+
<CapRow className="tag-input">
|
|
129
|
+
<CapInput
|
|
130
|
+
type="text"
|
|
131
|
+
className="tag-input-field"
|
|
132
|
+
value={customValues?.[tag?.fullPath] ?? ''}
|
|
133
|
+
onChange={(e) => handleCustomValueChange(tag?.fullPath, e.target.value)}
|
|
134
|
+
placeholder={formatMessage(messages.enterValue)}
|
|
135
|
+
size="small"
|
|
136
|
+
/>
|
|
137
|
+
</CapRow>
|
|
138
|
+
</CapRow>
|
|
139
|
+
);
|
|
140
|
+
})}
|
|
141
|
+
</CapRow>
|
|
142
|
+
</React.Fragment>
|
|
143
|
+
))}
|
|
126
144
|
</>
|
|
127
145
|
)}
|
|
128
146
|
<CapRow className="editor-actions">
|
|
@@ -156,9 +174,12 @@ CustomValuesEditor.propTypes = {
|
|
|
156
174
|
setShowJSON: PropTypes.func.isRequired,
|
|
157
175
|
customValues: PropTypes.object.isRequired,
|
|
158
176
|
handleJSONTextChange: PropTypes.func.isRequired,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
sections: PropTypes.arrayOf(PropTypes.shape({
|
|
178
|
+
key: PropTypes.string,
|
|
179
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
180
|
+
requiredTags: PropTypes.array,
|
|
181
|
+
optionalTags: PropTypes.array,
|
|
182
|
+
})).isRequired,
|
|
162
183
|
handleCustomValueChange: PropTypes.func.isRequired,
|
|
163
184
|
handleDiscardCustomValues: PropTypes.func.isRequired,
|
|
164
185
|
handleUpdatePreview: PropTypes.func.isRequired,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings — summary row + edit icon for Test and Preview (SMS, Email, WhatsApp).
|
|
3
|
+
*/
|
|
4
|
+
@import '~@capillarytech/cap-ui-library/styles/_variables.scss';
|
|
5
|
+
|
|
6
|
+
.delivery-settings {
|
|
7
|
+
&__heading-row {
|
|
8
|
+
margin-bottom: $CAP_SPACE_08;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&__summary-row {
|
|
12
|
+
margin-bottom: $CAP_SPACE_04;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&__summary-inner {
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin-bottom: $CAP_SPACE_08;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__summary-entry {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: baseline;
|
|
23
|
+
gap: 0;
|
|
24
|
+
margin-right: $CAP_SPACE_18;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__summary-key,
|
|
28
|
+
&__summary-value {
|
|
29
|
+
line-height: 1.4;
|
|
30
|
+
margin-top: 0;
|
|
31
|
+
margin-bottom: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&__edit-icon {
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: 0;
|
|
38
|
+
}
|
|
39
|
+
}
|