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
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for DeliverySettings component (sender ID / delivery settings summary + slidebox)
|
|
3
|
+
* @jest-environment jsdom
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
8
|
+
import { IntlProvider } from 'react-intl';
|
|
9
|
+
import DeliverySettings from '../../DeliverySettings';
|
|
10
|
+
import { CHANNELS } from '../../constants';
|
|
11
|
+
|
|
12
|
+
jest.mock('../../DeliverySettings/DeliverySettings.scss', () => ({}));
|
|
13
|
+
|
|
14
|
+
// Mock subpath imports (used by DeliverySettings/index.js and ModifyDeliverySettings.js)
|
|
15
|
+
jest.mock('@capillarytech/cap-ui-library/CapRow', () => ({ children, className, ...rest }) => <div className={className} data-testid="cap-row" {...rest}>{children}</div>);
|
|
16
|
+
jest.mock('@capillarytech/cap-ui-library/CapHeading', () => ({ children }) => <div data-testid="cap-heading">{children}</div>);
|
|
17
|
+
jest.mock('@capillarytech/cap-ui-library/CapIcon', () => ({ onClick, className, 'data-testid': testId }) => <button type="button" onClick={onClick} className={className} data-testid={testId || 'cap-icon'} aria-label="edit" />);
|
|
18
|
+
jest.mock('@capillarytech/cap-ui-library/CapLabel', () => ({ children, type }) => <span data-type={type}>{children}</span>);
|
|
19
|
+
jest.mock('@capillarytech/cap-ui-library/CapSlideBox', () => ({ show, content, handleClose }) => (show ? (
|
|
20
|
+
<div data-testid="cap-slidebox">
|
|
21
|
+
<button type="button" onClick={handleClose} data-testid="slidebox-close">Close</button>
|
|
22
|
+
{content}
|
|
23
|
+
</div>
|
|
24
|
+
) : null));
|
|
25
|
+
|
|
26
|
+
const mockModifyDeliverySettings = jest.fn();
|
|
27
|
+
jest.mock('../../DeliverySettings/ModifyDeliverySettings', () => function MockModifyDeliverySettings(props) {
|
|
28
|
+
mockModifyDeliverySettings(props);
|
|
29
|
+
return (
|
|
30
|
+
<div data-testid="modify-delivery-settings">
|
|
31
|
+
<button type="button" onClick={() => props.onSaveDeliverySettings({ domainId: 1 })} data-testid="modify-done">Done</button>
|
|
32
|
+
<button type="button" onClick={props.onClose} data-testid="modify-close">Cancel</button>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const defaultFormatMessage = (msg) => msg?.defaultMessage || msg?.id || '';
|
|
38
|
+
|
|
39
|
+
describe('DeliverySettings', () => {
|
|
40
|
+
const defaultProps = {
|
|
41
|
+
channel: CHANNELS.SMS,
|
|
42
|
+
deliverySettings: {},
|
|
43
|
+
senderDetailsByChannel: {},
|
|
44
|
+
wecrmAccounts: [],
|
|
45
|
+
onSaveDeliverySettings: jest.fn(),
|
|
46
|
+
isLoadingSenderDetails: false,
|
|
47
|
+
formatMessage: defaultFormatMessage,
|
|
48
|
+
smsTraiDltEnabled: false,
|
|
49
|
+
registeredSenderIds: [],
|
|
50
|
+
whatsappAccountFromForm: undefined,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
jest.clearAllMocks();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('channel visibility', () => {
|
|
58
|
+
it('should return null when channel is not in CHANNELS_WITH_DELIVERY_SETTINGS', () => {
|
|
59
|
+
const { container } = render(
|
|
60
|
+
<DeliverySettings {...defaultProps} channel="INAPP" />
|
|
61
|
+
);
|
|
62
|
+
expect(container.firstChild).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should render when channel is SMS', () => {
|
|
66
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.SMS} />);
|
|
67
|
+
expect(screen.getByTestId('cap-heading')).toBeTruthy();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should render when channel is EMAIL', () => {
|
|
71
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.EMAIL} />);
|
|
72
|
+
expect(screen.getByTestId('cap-heading')).toBeTruthy();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should render when channel is WHATSAPP', () => {
|
|
76
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.WHATSAPP} />);
|
|
77
|
+
expect(screen.getByTestId('cap-heading')).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('summary display', () => {
|
|
82
|
+
it('should show not configured when no delivery values for SMS', () => {
|
|
83
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.SMS} />);
|
|
84
|
+
expect(screen.getByText('Not configured')).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should show summary values for SMS when deliverySettings and senderDetailsOptions match', () => {
|
|
88
|
+
const senderDetailsByChannel = { [CHANNELS.SMS]: [{ domainId: 1, domainName: 'SMS Domain' }] };
|
|
89
|
+
const deliverySettings = { domainId: 1, gsmSenderId: 'SENDER1' };
|
|
90
|
+
render(
|
|
91
|
+
<DeliverySettings
|
|
92
|
+
{...defaultProps}
|
|
93
|
+
channel={CHANNELS.SMS}
|
|
94
|
+
deliverySettings={deliverySettings}
|
|
95
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
expect(screen.getAllByText(/SMS Domain/).length).toBeGreaterThan(0);
|
|
99
|
+
expect(screen.getAllByText(/SENDER1/).length).toBeGreaterThan(0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should show not configured for EMAIL when empty', () => {
|
|
103
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.EMAIL} />);
|
|
104
|
+
expect(screen.getByText('Not configured')).toBeTruthy();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should show summary for EMAIL when has domain and sender', () => {
|
|
108
|
+
const senderDetailsByChannel = { [CHANNELS.EMAIL]: [{ domainId: 2, domainName: 'Email Domain' }] };
|
|
109
|
+
const deliverySettings = {
|
|
110
|
+
domainId: 2,
|
|
111
|
+
senderEmail: 'noreply@test.com',
|
|
112
|
+
senderLabel: 'Test',
|
|
113
|
+
senderReplyTo: 'reply@test.com',
|
|
114
|
+
};
|
|
115
|
+
render(
|
|
116
|
+
<DeliverySettings
|
|
117
|
+
{...defaultProps}
|
|
118
|
+
channel={CHANNELS.EMAIL}
|
|
119
|
+
deliverySettings={deliverySettings}
|
|
120
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
expect(screen.getAllByText(/Email Domain/).length).toBeGreaterThan(0);
|
|
124
|
+
expect(screen.getAllByText(/noreply@test\.com/).length).toBeGreaterThan(0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should show summary for WHATSAPP when has account and sender', () => {
|
|
128
|
+
const wecrmAccounts = [{ name: 'WABA One', sourceAccountIdentifier: 'waba-1' }];
|
|
129
|
+
const deliverySettings = {
|
|
130
|
+
sourceAccountIdentifier: 'waba-1',
|
|
131
|
+
senderMobNum: '+1234567890',
|
|
132
|
+
};
|
|
133
|
+
render(
|
|
134
|
+
<DeliverySettings
|
|
135
|
+
{...defaultProps}
|
|
136
|
+
channel={CHANNELS.WHATSAPP}
|
|
137
|
+
deliverySettings={deliverySettings}
|
|
138
|
+
wecrmAccounts={wecrmAccounts}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
expect(screen.getAllByText(/WABA One/).length).toBeGreaterThan(0);
|
|
142
|
+
expect(screen.getAllByText(/\+1234567890/).length).toBeGreaterThan(0);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('RCS: when isChannelSmsFallbackPreviewEnabled is false, summary omits fallback SMS sender even if cdma is set', () => {
|
|
146
|
+
const rcsDomain = {
|
|
147
|
+
domainId: 10,
|
|
148
|
+
domainName: 'RCS D',
|
|
149
|
+
gsmSenders: [{ value: 'R1', default: true }],
|
|
150
|
+
};
|
|
151
|
+
const smsDomain = {
|
|
152
|
+
domainId: 20,
|
|
153
|
+
domainName: 'SMS D',
|
|
154
|
+
gsmSenders: [{ value: 'F1', default: true }],
|
|
155
|
+
};
|
|
156
|
+
const senderDetailsByChannel = {
|
|
157
|
+
[CHANNELS.RCS]: [rcsDomain],
|
|
158
|
+
[CHANNELS.SMS]: [smsDomain],
|
|
159
|
+
};
|
|
160
|
+
const deliverySettings = {
|
|
161
|
+
gsmSenderId: '10|R1',
|
|
162
|
+
cdmaSenderId: '20|F1',
|
|
163
|
+
};
|
|
164
|
+
render(
|
|
165
|
+
<IntlProvider locale="en" messages={{}}>
|
|
166
|
+
<DeliverySettings
|
|
167
|
+
{...defaultProps}
|
|
168
|
+
channel={CHANNELS.RCS}
|
|
169
|
+
deliverySettings={deliverySettings}
|
|
170
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
171
|
+
isChannelSmsFallbackPreviewEnabled={false}
|
|
172
|
+
formatMessage={(m) => m?.defaultMessage || m?.id || ''}
|
|
173
|
+
/>
|
|
174
|
+
</IntlProvider>,
|
|
175
|
+
);
|
|
176
|
+
expect(screen.getAllByText(/R1/).length).toBeGreaterThan(0);
|
|
177
|
+
expect(screen.queryByText(/F1/)).toBeNull();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('RCS: when isChannelSmsFallbackPreviewEnabled is true, summary includes fallback SMS sender', () => {
|
|
181
|
+
const rcsDomain = {
|
|
182
|
+
domainId: 10,
|
|
183
|
+
domainName: 'RCS D',
|
|
184
|
+
gsmSenders: [{ value: 'R1', default: true }],
|
|
185
|
+
};
|
|
186
|
+
const smsDomain = {
|
|
187
|
+
domainId: 20,
|
|
188
|
+
domainName: 'SMS D',
|
|
189
|
+
gsmSenders: [{ value: 'F1', default: true }],
|
|
190
|
+
};
|
|
191
|
+
const senderDetailsByChannel = {
|
|
192
|
+
[CHANNELS.RCS]: [rcsDomain],
|
|
193
|
+
[CHANNELS.SMS]: [smsDomain],
|
|
194
|
+
};
|
|
195
|
+
const deliverySettings = {
|
|
196
|
+
gsmSenderId: '10|R1',
|
|
197
|
+
cdmaSenderId: '20|F1',
|
|
198
|
+
};
|
|
199
|
+
render(
|
|
200
|
+
<IntlProvider locale="en" messages={{}}>
|
|
201
|
+
<DeliverySettings
|
|
202
|
+
{...defaultProps}
|
|
203
|
+
channel={CHANNELS.RCS}
|
|
204
|
+
deliverySettings={deliverySettings}
|
|
205
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
206
|
+
isChannelSmsFallbackPreviewEnabled
|
|
207
|
+
formatMessage={(m) => m?.defaultMessage || m?.id || ''}
|
|
208
|
+
/>
|
|
209
|
+
</IntlProvider>,
|
|
210
|
+
);
|
|
211
|
+
expect(screen.getAllByText(/R1/).length).toBeGreaterThan(0);
|
|
212
|
+
expect(screen.getAllByText(/F1/).length).toBeGreaterThan(0);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('edit and slidebox', () => {
|
|
217
|
+
it('should open slidebox when edit icon is clicked', () => {
|
|
218
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.SMS} />);
|
|
219
|
+
expect(screen.queryByTestId('cap-slidebox')).toBeNull();
|
|
220
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
221
|
+
expect(screen.getByTestId('cap-slidebox')).toBeTruthy();
|
|
222
|
+
expect(screen.getByTestId('modify-delivery-settings')).toBeTruthy();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should pass correct props to ModifyDeliverySettings', () => {
|
|
226
|
+
render(<DeliverySettings {...defaultProps} channel={CHANNELS.SMS} />);
|
|
227
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
228
|
+
expect(mockModifyDeliverySettings).toHaveBeenCalledWith(
|
|
229
|
+
expect.objectContaining({
|
|
230
|
+
channel: CHANNELS.SMS,
|
|
231
|
+
deliverySettings: {},
|
|
232
|
+
senderDetailsOptions: [],
|
|
233
|
+
wecrmAccounts: [],
|
|
234
|
+
isLoading: false,
|
|
235
|
+
smsTraiDltEnabled: false,
|
|
236
|
+
registeredSenderIds: [],
|
|
237
|
+
whatsappAccountFromForm: undefined,
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('RCS: should not pass smsFallbackSenderDetailsOptions when isChannelSmsFallbackPreviewEnabled is false', () => {
|
|
243
|
+
render(
|
|
244
|
+
<DeliverySettings
|
|
245
|
+
{...defaultProps}
|
|
246
|
+
channel={CHANNELS.RCS}
|
|
247
|
+
senderDetailsByChannel={{
|
|
248
|
+
[CHANNELS.RCS]: [{ domainId: 1, domainName: 'R', gsmSenders: [] }],
|
|
249
|
+
[CHANNELS.SMS]: [{ domainId: 2, domainName: 'S', gsmSenders: [] }],
|
|
250
|
+
}}
|
|
251
|
+
isChannelSmsFallbackPreviewEnabled={false}
|
|
252
|
+
/>,
|
|
253
|
+
);
|
|
254
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
255
|
+
expect(mockModifyDeliverySettings).toHaveBeenCalledWith(
|
|
256
|
+
expect.objectContaining({
|
|
257
|
+
channel: CHANNELS.RCS,
|
|
258
|
+
smsFallbackSenderDetailsOptions: undefined,
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('RCS: should pass smsFallbackSenderDetailsOptions when isChannelSmsFallbackPreviewEnabled is true', () => {
|
|
264
|
+
const smsDomains = [{ domainId: 2, domainName: 'S', gsmSenders: [] }];
|
|
265
|
+
render(
|
|
266
|
+
<DeliverySettings
|
|
267
|
+
{...defaultProps}
|
|
268
|
+
channel={CHANNELS.RCS}
|
|
269
|
+
senderDetailsByChannel={{
|
|
270
|
+
[CHANNELS.RCS]: [{ domainId: 1, domainName: 'R', gsmSenders: [] }],
|
|
271
|
+
[CHANNELS.SMS]: smsDomains,
|
|
272
|
+
}}
|
|
273
|
+
isChannelSmsFallbackPreviewEnabled
|
|
274
|
+
/>,
|
|
275
|
+
);
|
|
276
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
277
|
+
expect(mockModifyDeliverySettings).toHaveBeenCalledWith(
|
|
278
|
+
expect.objectContaining({
|
|
279
|
+
channel: CHANNELS.RCS,
|
|
280
|
+
smsFallbackSenderDetailsOptions: smsDomains,
|
|
281
|
+
}),
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('should call onSaveDeliverySettings and close slidebox when Done is clicked', () => {
|
|
286
|
+
const onSave = jest.fn();
|
|
287
|
+
render(
|
|
288
|
+
<DeliverySettings
|
|
289
|
+
{...defaultProps}
|
|
290
|
+
channel={CHANNELS.SMS}
|
|
291
|
+
onSaveDeliverySettings={onSave}
|
|
292
|
+
/>
|
|
293
|
+
);
|
|
294
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
295
|
+
fireEvent.click(screen.getByTestId('modify-done'));
|
|
296
|
+
expect(onSave).toHaveBeenCalledWith({ domainId: 1 });
|
|
297
|
+
expect(screen.queryByTestId('cap-slidebox')).toBeNull();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('should pass whatsappAccountFromForm to ModifyDeliverySettings', () => {
|
|
301
|
+
render(
|
|
302
|
+
<DeliverySettings
|
|
303
|
+
{...defaultProps}
|
|
304
|
+
channel={CHANNELS.WHATSAPP}
|
|
305
|
+
whatsappAccountFromForm={{ accountName: 'My WABA' }}
|
|
306
|
+
/>
|
|
307
|
+
);
|
|
308
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
309
|
+
expect(mockModifyDeliverySettings).toHaveBeenCalledWith(
|
|
310
|
+
expect.objectContaining({
|
|
311
|
+
whatsappAccountFromForm: { accountName: 'My WABA' },
|
|
312
|
+
})
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should pass SMS TRAI props to ModifyDeliverySettings', () => {
|
|
317
|
+
render(
|
|
318
|
+
<DeliverySettings
|
|
319
|
+
{...defaultProps}
|
|
320
|
+
channel={CHANNELS.SMS}
|
|
321
|
+
smsTraiDltEnabled
|
|
322
|
+
registeredSenderIds={['HPCLTD']}
|
|
323
|
+
/>
|
|
324
|
+
);
|
|
325
|
+
fireEvent.click(screen.getByTestId('delivery-settings-edit'));
|
|
326
|
+
expect(mockModifyDeliverySettings).toHaveBeenCalledWith(
|
|
327
|
+
expect.objectContaining({
|
|
328
|
+
smsTraiDltEnabled: true,
|
|
329
|
+
registeredSenderIds: ['HPCLTD'],
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|