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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
call, put, takeLatest, all,
|
|
8
|
+
call, put, takeLatest, takeEvery, all,
|
|
9
9
|
} from 'redux-saga/effects';
|
|
10
10
|
import {
|
|
11
11
|
searchCustomersSaga,
|
|
@@ -25,9 +25,17 @@ import {
|
|
|
25
25
|
watchFetchTestGroups,
|
|
26
26
|
watchCreateMessageMeta,
|
|
27
27
|
watchGetPrefilledValues,
|
|
28
|
+
getSenderDetailsSaga,
|
|
29
|
+
getWeCrmAccountsSaga,
|
|
30
|
+
watchGetSenderDetails,
|
|
31
|
+
watchGetWeCrmAccounts,
|
|
28
32
|
commonTestAndPreviewSaga,
|
|
29
33
|
} from '../sagas';
|
|
30
34
|
import * as Api from '../../../services/api';
|
|
35
|
+
jest.mock('../DeliverySettings/utils/parseSenderDetailsResponse', () => ({
|
|
36
|
+
parseSenderDetailsResponse: jest.fn((channel, response) => ({ domains: response?.entity?.[channel] || [] })),
|
|
37
|
+
}));
|
|
38
|
+
import { parseSenderDetailsResponse } from '../DeliverySettings/utils/parseSenderDetailsResponse';
|
|
31
39
|
import {
|
|
32
40
|
SEARCH_CUSTOMERS_SUCCESS,
|
|
33
41
|
SEARCH_CUSTOMERS_FAILURE,
|
|
@@ -45,6 +53,10 @@ import {
|
|
|
45
53
|
CREATE_MESSAGE_META_FAILURE,
|
|
46
54
|
GET_PREFILLED_VALUES_SUCCESS,
|
|
47
55
|
GET_PREFILLED_VALUES_FAILURE,
|
|
56
|
+
GET_SENDER_DETAILS_SUCCESS,
|
|
57
|
+
GET_SENDER_DETAILS_FAILURE,
|
|
58
|
+
GET_WECRM_ACCOUNTS_SUCCESS,
|
|
59
|
+
GET_WECRM_ACCOUNTS_FAILURE,
|
|
48
60
|
} from '../constants';
|
|
49
61
|
|
|
50
62
|
describe('CommonTestAndPreview Sagas', () => {
|
|
@@ -735,383 +747,6 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
735
747
|
});
|
|
736
748
|
});
|
|
737
749
|
|
|
738
|
-
describe('getBulkCustomerDetails', () => {
|
|
739
|
-
it('should transform customer data successfully', () => {
|
|
740
|
-
const fetchedUserIds = ['1', '2'];
|
|
741
|
-
const bulkResponse = {
|
|
742
|
-
result: {
|
|
743
|
-
data: [
|
|
744
|
-
{
|
|
745
|
-
entity: {
|
|
746
|
-
id: '1',
|
|
747
|
-
profiles: [
|
|
748
|
-
{
|
|
749
|
-
firstName: 'John',
|
|
750
|
-
lastName: 'Doe',
|
|
751
|
-
identifiers: [
|
|
752
|
-
{ type: 'mobile', value: '1234567890' },
|
|
753
|
-
{ type: 'email', value: 'john@example.com' },
|
|
754
|
-
],
|
|
755
|
-
},
|
|
756
|
-
],
|
|
757
|
-
},
|
|
758
|
-
},
|
|
759
|
-
{
|
|
760
|
-
entity: {
|
|
761
|
-
id: '2',
|
|
762
|
-
profiles: [
|
|
763
|
-
{
|
|
764
|
-
firstName: 'Jane',
|
|
765
|
-
lastName: 'Doe',
|
|
766
|
-
identifiers: [
|
|
767
|
-
{ type: 'mobile', value: '0987654321' },
|
|
768
|
-
{ type: 'email', value: 'jane@example.com' },
|
|
769
|
-
],
|
|
770
|
-
},
|
|
771
|
-
],
|
|
772
|
-
},
|
|
773
|
-
},
|
|
774
|
-
],
|
|
775
|
-
},
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
779
|
-
|
|
780
|
-
expect(generator.next().value).toEqual(
|
|
781
|
-
call(Api.getBulkCustomerDetails, { userIds: fetchedUserIds })
|
|
782
|
-
);
|
|
783
|
-
|
|
784
|
-
const transformedData = [
|
|
785
|
-
{
|
|
786
|
-
userId: '1',
|
|
787
|
-
name: 'John Doe',
|
|
788
|
-
mobile: '1234567890',
|
|
789
|
-
email: 'john@example.com',
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
userId: '2',
|
|
793
|
-
name: 'Jane Doe',
|
|
794
|
-
mobile: '0987654321',
|
|
795
|
-
email: 'jane@example.com',
|
|
796
|
-
},
|
|
797
|
-
];
|
|
798
|
-
|
|
799
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
800
|
-
put({
|
|
801
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
802
|
-
payload: { customers: transformedData },
|
|
803
|
-
})
|
|
804
|
-
);
|
|
805
|
-
|
|
806
|
-
expect(generator.next().done).toBe(true);
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
it('should handle customer without mobile identifier', () => {
|
|
810
|
-
const fetchedUserIds = ['1'];
|
|
811
|
-
const bulkResponse = {
|
|
812
|
-
result: {
|
|
813
|
-
data: [
|
|
814
|
-
{
|
|
815
|
-
entity: {
|
|
816
|
-
id: '1',
|
|
817
|
-
profiles: [
|
|
818
|
-
{
|
|
819
|
-
firstName: 'John',
|
|
820
|
-
lastName: 'Doe',
|
|
821
|
-
identifiers: [
|
|
822
|
-
{ type: 'email', value: 'john@example.com' },
|
|
823
|
-
],
|
|
824
|
-
},
|
|
825
|
-
],
|
|
826
|
-
},
|
|
827
|
-
},
|
|
828
|
-
],
|
|
829
|
-
},
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
833
|
-
|
|
834
|
-
generator.next();
|
|
835
|
-
const transformedData = [
|
|
836
|
-
{
|
|
837
|
-
userId: '1',
|
|
838
|
-
name: 'John Doe',
|
|
839
|
-
mobile: undefined,
|
|
840
|
-
email: 'john@example.com',
|
|
841
|
-
},
|
|
842
|
-
];
|
|
843
|
-
|
|
844
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
845
|
-
put({
|
|
846
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
847
|
-
payload: { customers: transformedData },
|
|
848
|
-
})
|
|
849
|
-
);
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
it('should handle customer without email identifier', () => {
|
|
853
|
-
const fetchedUserIds = ['1'];
|
|
854
|
-
const bulkResponse = {
|
|
855
|
-
result: {
|
|
856
|
-
data: [
|
|
857
|
-
{
|
|
858
|
-
entity: {
|
|
859
|
-
id: '1',
|
|
860
|
-
profiles: [
|
|
861
|
-
{
|
|
862
|
-
firstName: 'John',
|
|
863
|
-
lastName: 'Doe',
|
|
864
|
-
identifiers: [
|
|
865
|
-
{ type: 'mobile', value: '1234567890' },
|
|
866
|
-
],
|
|
867
|
-
},
|
|
868
|
-
],
|
|
869
|
-
},
|
|
870
|
-
},
|
|
871
|
-
],
|
|
872
|
-
},
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
876
|
-
|
|
877
|
-
generator.next();
|
|
878
|
-
const transformedData = [
|
|
879
|
-
{
|
|
880
|
-
userId: '1',
|
|
881
|
-
name: 'John Doe',
|
|
882
|
-
mobile: '1234567890',
|
|
883
|
-
email: undefined,
|
|
884
|
-
},
|
|
885
|
-
];
|
|
886
|
-
|
|
887
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
888
|
-
put({
|
|
889
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
890
|
-
payload: { customers: transformedData },
|
|
891
|
-
})
|
|
892
|
-
);
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
it('should handle customer without identifiers', () => {
|
|
896
|
-
const fetchedUserIds = ['1'];
|
|
897
|
-
const bulkResponse = {
|
|
898
|
-
result: {
|
|
899
|
-
data: [
|
|
900
|
-
{
|
|
901
|
-
entity: {
|
|
902
|
-
id: '1',
|
|
903
|
-
profiles: [
|
|
904
|
-
{
|
|
905
|
-
firstName: 'John',
|
|
906
|
-
lastName: 'Doe',
|
|
907
|
-
identifiers: [],
|
|
908
|
-
},
|
|
909
|
-
],
|
|
910
|
-
},
|
|
911
|
-
},
|
|
912
|
-
],
|
|
913
|
-
},
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
917
|
-
|
|
918
|
-
generator.next();
|
|
919
|
-
const transformedData = [
|
|
920
|
-
{
|
|
921
|
-
userId: '1',
|
|
922
|
-
name: 'John Doe',
|
|
923
|
-
mobile: undefined,
|
|
924
|
-
email: undefined,
|
|
925
|
-
},
|
|
926
|
-
];
|
|
927
|
-
|
|
928
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
929
|
-
put({
|
|
930
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
931
|
-
payload: { customers: transformedData },
|
|
932
|
-
})
|
|
933
|
-
);
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
it('should handle empty profile', () => {
|
|
937
|
-
const fetchedUserIds = ['1'];
|
|
938
|
-
const bulkResponse = {
|
|
939
|
-
result: {
|
|
940
|
-
data: [
|
|
941
|
-
{
|
|
942
|
-
entity: {
|
|
943
|
-
id: '1',
|
|
944
|
-
profiles: [],
|
|
945
|
-
},
|
|
946
|
-
errors: [{ message: 'Profile not found' }],
|
|
947
|
-
},
|
|
948
|
-
],
|
|
949
|
-
},
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
953
|
-
|
|
954
|
-
generator.next();
|
|
955
|
-
// The error is caught and put into failure action
|
|
956
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
957
|
-
put({
|
|
958
|
-
type: GET_TEST_CUSTOMERS_FAILURE,
|
|
959
|
-
payload: { error: expect.objectContaining({ message: 'Profile not found' }) },
|
|
960
|
-
})
|
|
961
|
-
);
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
it('should handle profile with error message', () => {
|
|
965
|
-
const fetchedUserIds = ['1'];
|
|
966
|
-
const bulkResponse = {
|
|
967
|
-
result: {
|
|
968
|
-
data: [
|
|
969
|
-
{
|
|
970
|
-
entity: {
|
|
971
|
-
id: '1',
|
|
972
|
-
profiles: [],
|
|
973
|
-
},
|
|
974
|
-
errors: [{ message: 'Custom error' }],
|
|
975
|
-
},
|
|
976
|
-
],
|
|
977
|
-
},
|
|
978
|
-
};
|
|
979
|
-
|
|
980
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
981
|
-
|
|
982
|
-
generator.next();
|
|
983
|
-
// The error is caught and put into failure action
|
|
984
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
985
|
-
put({
|
|
986
|
-
type: GET_TEST_CUSTOMERS_FAILURE,
|
|
987
|
-
payload: { error: expect.objectContaining({ message: 'Custom error' }) },
|
|
988
|
-
})
|
|
989
|
-
);
|
|
990
|
-
});
|
|
991
|
-
|
|
992
|
-
it('should handle profile without error message', () => {
|
|
993
|
-
const fetchedUserIds = ['1'];
|
|
994
|
-
const bulkResponse = {
|
|
995
|
-
result: {
|
|
996
|
-
data: [
|
|
997
|
-
{
|
|
998
|
-
entity: {
|
|
999
|
-
id: '1',
|
|
1000
|
-
profiles: [],
|
|
1001
|
-
},
|
|
1002
|
-
},
|
|
1003
|
-
],
|
|
1004
|
-
},
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
1008
|
-
|
|
1009
|
-
generator.next();
|
|
1010
|
-
// The error is caught and put into failure action
|
|
1011
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
1012
|
-
put({
|
|
1013
|
-
type: GET_TEST_CUSTOMERS_FAILURE,
|
|
1014
|
-
payload: { error: expect.objectContaining({ message: 'Profile is empty' }) },
|
|
1015
|
-
})
|
|
1016
|
-
);
|
|
1017
|
-
});
|
|
1018
|
-
|
|
1019
|
-
it('should handle network error', () => {
|
|
1020
|
-
const fetchedUserIds = ['1'];
|
|
1021
|
-
const error = new Error('Network error');
|
|
1022
|
-
|
|
1023
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
1024
|
-
|
|
1025
|
-
generator.next();
|
|
1026
|
-
expect(generator.throw(error).value).toEqual(
|
|
1027
|
-
put({
|
|
1028
|
-
type: GET_TEST_CUSTOMERS_FAILURE,
|
|
1029
|
-
payload: { error },
|
|
1030
|
-
})
|
|
1031
|
-
);
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
it('should handle customer with missing firstName', () => {
|
|
1035
|
-
const fetchedUserIds = ['1'];
|
|
1036
|
-
const bulkResponse = {
|
|
1037
|
-
result: {
|
|
1038
|
-
data: [
|
|
1039
|
-
{
|
|
1040
|
-
entity: {
|
|
1041
|
-
id: '1',
|
|
1042
|
-
profiles: [
|
|
1043
|
-
{
|
|
1044
|
-
lastName: 'Doe',
|
|
1045
|
-
identifiers: [],
|
|
1046
|
-
},
|
|
1047
|
-
],
|
|
1048
|
-
},
|
|
1049
|
-
},
|
|
1050
|
-
],
|
|
1051
|
-
},
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
1055
|
-
|
|
1056
|
-
generator.next();
|
|
1057
|
-
const transformedData = [
|
|
1058
|
-
{
|
|
1059
|
-
userId: '1',
|
|
1060
|
-
name: 'undefined Doe',
|
|
1061
|
-
mobile: undefined,
|
|
1062
|
-
email: undefined,
|
|
1063
|
-
},
|
|
1064
|
-
];
|
|
1065
|
-
|
|
1066
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
1067
|
-
put({
|
|
1068
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
1069
|
-
payload: { customers: transformedData },
|
|
1070
|
-
})
|
|
1071
|
-
);
|
|
1072
|
-
});
|
|
1073
|
-
|
|
1074
|
-
it('should handle customer with missing lastName', () => {
|
|
1075
|
-
const fetchedUserIds = ['1'];
|
|
1076
|
-
const bulkResponse = {
|
|
1077
|
-
result: {
|
|
1078
|
-
data: [
|
|
1079
|
-
{
|
|
1080
|
-
entity: {
|
|
1081
|
-
id: '1',
|
|
1082
|
-
profiles: [
|
|
1083
|
-
{
|
|
1084
|
-
firstName: 'John',
|
|
1085
|
-
identifiers: [],
|
|
1086
|
-
},
|
|
1087
|
-
],
|
|
1088
|
-
},
|
|
1089
|
-
},
|
|
1090
|
-
],
|
|
1091
|
-
},
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
const generator = getBulkCustomerDetails({ fetchedUserIds });
|
|
1095
|
-
|
|
1096
|
-
generator.next();
|
|
1097
|
-
const transformedData = [
|
|
1098
|
-
{
|
|
1099
|
-
userId: '1',
|
|
1100
|
-
name: 'John undefined',
|
|
1101
|
-
mobile: undefined,
|
|
1102
|
-
email: undefined,
|
|
1103
|
-
},
|
|
1104
|
-
];
|
|
1105
|
-
|
|
1106
|
-
expect(generator.next(bulkResponse).value).toEqual(
|
|
1107
|
-
put({
|
|
1108
|
-
type: GET_TEST_CUSTOMERS_SUCCESS,
|
|
1109
|
-
payload: { customers: transformedData },
|
|
1110
|
-
})
|
|
1111
|
-
);
|
|
1112
|
-
});
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
750
|
describe('fetchTestCustomersSaga', () => {
|
|
1116
751
|
it('should fetch test customers successfully', () => {
|
|
1117
752
|
const response = {
|
|
@@ -1694,6 +1329,137 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
1694
1329
|
);
|
|
1695
1330
|
expect(generator.next().done).toBe(true);
|
|
1696
1331
|
});
|
|
1332
|
+
|
|
1333
|
+
it('should watch for GET_SENDER_DETAILS_REQUESTED', () => {
|
|
1334
|
+
const generator = watchGetSenderDetails();
|
|
1335
|
+
expect(generator.next().value).toEqual(
|
|
1336
|
+
takeEvery('app/CommonTestAndPreview/GET_SENDER_DETAILS_REQUESTED', getSenderDetailsSaga)
|
|
1337
|
+
);
|
|
1338
|
+
expect(generator.next().done).toBe(true);
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
it('should watch for GET_WECRM_ACCOUNTS_REQUESTED', () => {
|
|
1342
|
+
const generator = watchGetWeCrmAccounts();
|
|
1343
|
+
expect(generator.next().value).toEqual(
|
|
1344
|
+
takeLatest('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_REQUESTED', getWeCrmAccountsSaga)
|
|
1345
|
+
);
|
|
1346
|
+
expect(generator.next().done).toBe(true);
|
|
1347
|
+
});
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
describe('getSenderDetailsSaga', () => {
|
|
1351
|
+
it('should fetch sender details and put SUCCESS with parsed domains', () => {
|
|
1352
|
+
const action = { payload: { channel: 'SMS', orgUnitId: 100 } };
|
|
1353
|
+
const apiResponse = { entity: { SMS: [{ id: 1, domainProperties: {} }] } };
|
|
1354
|
+
parseSenderDetailsResponse.mockReturnValue({ domains: [{ domainId: 1 }] });
|
|
1355
|
+
|
|
1356
|
+
const generator = getSenderDetailsSaga(action);
|
|
1357
|
+
|
|
1358
|
+
expect(generator.next().value).toEqual(call(Api.getSenderDetails, 'SMS', 100));
|
|
1359
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
1360
|
+
put({ type: GET_SENDER_DETAILS_SUCCESS, payload: { channel: 'SMS', domains: [{ domainId: 1 }] } })
|
|
1361
|
+
);
|
|
1362
|
+
expect(generator.next().done).toBe(true);
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
it('should use orgUnitId -1 when not provided', () => {
|
|
1366
|
+
const action = { payload: { channel: 'EMAIL' } };
|
|
1367
|
+
const apiResponse = { entity: { EMAIL: [] } };
|
|
1368
|
+
parseSenderDetailsResponse.mockReturnValue({ domains: [] });
|
|
1369
|
+
|
|
1370
|
+
const generator = getSenderDetailsSaga(action);
|
|
1371
|
+
|
|
1372
|
+
expect(generator.next().value).toEqual(call(Api.getSenderDetails, 'EMAIL', -1));
|
|
1373
|
+
generator.next(apiResponse);
|
|
1374
|
+
expect(generator.next().done).toBe(true);
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
it('should return early when channel is missing', () => {
|
|
1378
|
+
const action = { payload: {} };
|
|
1379
|
+
const generator = getSenderDetailsSaga(action);
|
|
1380
|
+
expect(generator.next().done).toBe(true);
|
|
1381
|
+
});
|
|
1382
|
+
|
|
1383
|
+
it('should put FAILURE when response has errors', () => {
|
|
1384
|
+
const action = { payload: { channel: 'SMS' } };
|
|
1385
|
+
const apiResponse = { errors: [{ message: 'Forbidden' }] };
|
|
1386
|
+
|
|
1387
|
+
const generator = getSenderDetailsSaga(action);
|
|
1388
|
+
generator.next();
|
|
1389
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
1390
|
+
put({
|
|
1391
|
+
type: GET_SENDER_DETAILS_FAILURE,
|
|
1392
|
+
payload: { channel: 'SMS', error: [{ message: 'Forbidden' }] },
|
|
1393
|
+
})
|
|
1394
|
+
);
|
|
1395
|
+
expect(generator.next().done).toBe(true);
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1398
|
+
it('should put FAILURE on throw', () => {
|
|
1399
|
+
const action = { payload: { channel: 'WHATSAPP' } };
|
|
1400
|
+
const generator = getSenderDetailsSaga(action);
|
|
1401
|
+
generator.next();
|
|
1402
|
+
const err = generator.throw(new Error('Network error'));
|
|
1403
|
+
expect(err.value).toEqual(
|
|
1404
|
+
put({
|
|
1405
|
+
type: GET_SENDER_DETAILS_FAILURE,
|
|
1406
|
+
payload: { channel: 'WHATSAPP', error: 'Network error' },
|
|
1407
|
+
})
|
|
1408
|
+
);
|
|
1409
|
+
expect(generator.next().done).toBe(true);
|
|
1410
|
+
});
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
describe('getWeCrmAccountsSaga', () => {
|
|
1414
|
+
it('should fetch wecrm accounts and put SUCCESS with list from response', () => {
|
|
1415
|
+
const action = { payload: { sourceName: 'WHATSAPP' } };
|
|
1416
|
+
const apiResult = { response: [{ name: 'WABA1', sourceAccountIdentifier: 'waba-1' }] };
|
|
1417
|
+
|
|
1418
|
+
const generator = getWeCrmAccountsSaga(action);
|
|
1419
|
+
|
|
1420
|
+
expect(generator.next().value).toEqual(call(Api.fetchWeCrmAccounts, 'WHATSAPP'));
|
|
1421
|
+
expect(generator.next(apiResult).value).toEqual(
|
|
1422
|
+
put({ type: GET_WECRM_ACCOUNTS_SUCCESS, payload: { accounts: [{ name: 'WABA1', sourceAccountIdentifier: 'waba-1' }] } })
|
|
1423
|
+
);
|
|
1424
|
+
expect(generator.next().done).toBe(true);
|
|
1425
|
+
});
|
|
1426
|
+
|
|
1427
|
+
it('should use WHATSAPP when sourceName not provided', () => {
|
|
1428
|
+
const action = { payload: {} };
|
|
1429
|
+
const generator = getWeCrmAccountsSaga(action);
|
|
1430
|
+
expect(generator.next().value).toEqual(call(Api.fetchWeCrmAccounts, 'WHATSAPP'));
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
it('should use entity when response not present', () => {
|
|
1434
|
+
const action = { payload: {} };
|
|
1435
|
+
const apiResult = { entity: [{ name: 'Acc1' }] };
|
|
1436
|
+
|
|
1437
|
+
const generator = getWeCrmAccountsSaga(action);
|
|
1438
|
+
generator.next();
|
|
1439
|
+
expect(generator.next(apiResult).value).toEqual(
|
|
1440
|
+
put({ type: GET_WECRM_ACCOUNTS_SUCCESS, payload: { accounts: [{ name: 'Acc1' }] } })
|
|
1441
|
+
);
|
|
1442
|
+
});
|
|
1443
|
+
|
|
1444
|
+
it('should put empty array when result has no list', () => {
|
|
1445
|
+
const action = { payload: {} };
|
|
1446
|
+
const generator = getWeCrmAccountsSaga(action);
|
|
1447
|
+
generator.next();
|
|
1448
|
+
expect(generator.next({}).value).toEqual(
|
|
1449
|
+
put({ type: GET_WECRM_ACCOUNTS_SUCCESS, payload: { accounts: [] } })
|
|
1450
|
+
);
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
it('should put FAILURE on throw', () => {
|
|
1454
|
+
const action = { payload: {} };
|
|
1455
|
+
const generator = getWeCrmAccountsSaga(action);
|
|
1456
|
+
generator.next();
|
|
1457
|
+
const err = generator.throw(new Error('API failed'));
|
|
1458
|
+
expect(err.value).toEqual(
|
|
1459
|
+
put({ type: GET_WECRM_ACCOUNTS_FAILURE, payload: { error: 'API failed' } })
|
|
1460
|
+
);
|
|
1461
|
+
expect(generator.next().done).toBe(true);
|
|
1462
|
+
});
|
|
1697
1463
|
});
|
|
1698
1464
|
|
|
1699
1465
|
describe('commonTestAndPreviewSaga', () => {
|
|
@@ -1710,6 +1476,8 @@ describe('CommonTestAndPreview Sagas', () => {
|
|
|
1710
1476
|
watchFetchTestGroups(),
|
|
1711
1477
|
watchCreateMessageMeta(),
|
|
1712
1478
|
watchGetPrefilledValues(),
|
|
1479
|
+
watchGetSenderDetails(),
|
|
1480
|
+
watchGetWeCrmAccounts(),
|
|
1713
1481
|
])
|
|
1714
1482
|
);
|
|
1715
1483
|
|