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.
Files changed (247) hide show
  1. package/.github/workflows/pr-title-check.yml +88 -0
  2. package/app/constants/unified.js +21 -1
  3. package/app/containers/App/constants.js +0 -1
  4. package/app/containers/Login/test/index.test.js +123 -0
  5. package/app/containers/Login/test/selectors.test.js +165 -0
  6. package/app/initialState.js +0 -2
  7. package/app/services/api.js +6 -0
  8. package/app/services/tests/api.test.js +7 -0
  9. package/app/services/tests/getSchema.test.js +95 -0
  10. package/app/utils/common.js +23 -9
  11. package/app/utils/commonUtils.js +64 -93
  12. package/app/utils/tagValidations.js +83 -219
  13. package/app/utils/templateVarUtils.js +172 -0
  14. package/app/utils/tests/common.test.js +265 -323
  15. package/app/utils/tests/commonUtil.test.js +461 -118
  16. package/app/utils/tests/commonUtils.test.js +581 -0
  17. package/app/utils/tests/messageUtils.test.js +95 -0
  18. package/app/utils/tests/smsCharCount.test.js +304 -0
  19. package/app/utils/tests/smsCharCountV2.test.js +213 -10
  20. package/app/utils/tests/tagValidations.test.js +474 -357
  21. package/app/utils/tests/templateVarUtils.test.js +160 -0
  22. package/app/v2Components/CapDeviceContent/index.js +10 -7
  23. package/app/v2Components/CapTagList/index.js +32 -24
  24. package/app/v2Components/CapTagList/style.scss +48 -0
  25. package/app/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
  26. package/app/v2Components/CapTagListWithInput/index.js +8 -0
  27. package/app/v2Components/CapWhatsappCTA/index.js +2 -0
  28. package/app/v2Components/CapWhatsappCarouselButton/index.js +32 -14
  29. package/app/v2Components/CapWhatsappCarouselButton/tests/index.test.js +120 -2
  30. package/app/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
  31. package/app/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +39 -0
  32. package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +606 -0
  33. package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +36 -0
  34. package/app/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +79 -0
  35. package/app/v2Components/CommonTestAndPreview/DeliverySettings/index.js +314 -0
  36. package/app/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +141 -0
  37. package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +156 -0
  38. package/app/v2Components/CommonTestAndPreview/SendTestMessage.js +57 -1
  39. package/app/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +20 -1
  40. package/app/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
  41. package/app/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +210 -4
  42. package/app/v2Components/CommonTestAndPreview/actions.js +20 -0
  43. package/app/v2Components/CommonTestAndPreview/constants.js +57 -1
  44. package/app/v2Components/CommonTestAndPreview/index.js +878 -156
  45. package/app/v2Components/CommonTestAndPreview/messages.js +41 -3
  46. package/app/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
  47. package/app/v2Components/CommonTestAndPreview/reducer.js +47 -0
  48. package/app/v2Components/CommonTestAndPreview/sagas.js +75 -5
  49. package/app/v2Components/CommonTestAndPreview/selectors.js +51 -0
  50. package/app/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +352 -0
  51. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +1156 -0
  52. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +334 -0
  53. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +576 -0
  54. package/app/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +156 -0
  55. package/app/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
  56. package/app/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
  57. package/app/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -7
  58. package/app/v2Components/CommonTestAndPreview/tests/index.test.js +914 -5
  59. package/app/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
  60. package/app/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
  61. package/app/v2Components/CommonTestAndPreview/tests/sagas.test.js +146 -378
  62. package/app/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
  63. package/app/v2Components/ErrorInfoNote/index.js +24 -26
  64. package/app/v2Components/FormBuilder/index.js +182 -204
  65. package/app/v2Components/FormBuilder/messages.js +4 -8
  66. package/app/v2Components/HtmlEditor/HTMLEditor.js +7 -6
  67. package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -1
  68. package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +928 -17
  69. package/app/v2Components/HtmlEditor/components/CodeEditorPane/index.js +4 -2
  70. package/app/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +452 -3
  71. package/app/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
  72. package/app/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
  73. package/app/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
  74. package/app/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
  75. package/app/v2Components/SmsFallback/constants.js +73 -0
  76. package/app/v2Components/SmsFallback/index.js +956 -0
  77. package/app/v2Components/SmsFallback/index.scss +265 -0
  78. package/app/v2Components/SmsFallback/messages.js +78 -0
  79. package/app/v2Components/SmsFallback/smsFallbackUtils.js +107 -0
  80. package/app/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
  81. package/app/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
  82. package/app/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
  83. package/app/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
  84. package/app/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +261 -0
  85. package/app/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
  86. package/app/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
  87. package/app/v2Components/TestAndPreviewSlidebox/index.js +22 -1
  88. package/app/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
  89. package/app/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
  90. package/app/v2Components/VarSegmentMessageEditor/constants.js +2 -0
  91. package/app/v2Components/VarSegmentMessageEditor/index.js +125 -0
  92. package/app/v2Components/VarSegmentMessageEditor/index.scss +46 -0
  93. package/app/v2Containers/BeeEditor/index.js +3 -0
  94. package/app/v2Containers/BeePopupEditor/index.js +9 -2
  95. package/app/v2Containers/Cap/mockData.js +0 -14
  96. package/app/v2Containers/Cap/reducer.js +3 -55
  97. package/app/v2Containers/Cap/tests/reducer.test.js +0 -102
  98. package/app/v2Containers/CommunicationFlow/CommunicationFlow.js +291 -0
  99. package/app/v2Containers/CommunicationFlow/CommunicationFlow.scss +25 -0
  100. package/app/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +255 -0
  101. package/app/v2Containers/CommunicationFlow/constants.js +200 -0
  102. package/app/v2Containers/CommunicationFlow/index.js +102 -0
  103. package/app/v2Containers/CommunicationFlow/messages.js +346 -0
  104. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +522 -0
  105. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +170 -0
  106. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +796 -0
  107. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/index.js +5 -0
  108. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +95 -0
  109. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/Tests/CommunicationStrategyStep.test.js +133 -0
  110. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/index.js +5 -0
  111. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +289 -0
  112. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.scss +70 -0
  113. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +319 -0
  114. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.scss +69 -0
  115. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +616 -0
  116. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +577 -0
  117. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +1111 -0
  118. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +696 -0
  119. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/index.js +7 -0
  120. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.js +102 -0
  121. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.scss +36 -0
  122. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/Tests/DynamicControlsStep.test.js +91 -0
  123. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/index.js +5 -0
  124. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/MessageTypeStep.js +86 -0
  125. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/Tests/MessageTypeStep.test.js +100 -0
  126. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/index.js +5 -0
  127. package/app/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +30 -0
  128. package/app/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
  129. package/app/v2Containers/CreativesContainer/SlideBoxContent.js +127 -11
  130. package/app/v2Containers/CreativesContainer/SlideBoxFooter.js +62 -9
  131. package/app/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
  132. package/app/v2Containers/CreativesContainer/constants.js +24 -0
  133. package/app/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
  134. package/app/v2Containers/CreativesContainer/index.js +346 -71
  135. package/app/v2Containers/CreativesContainer/index.scss +51 -1
  136. package/app/v2Containers/CreativesContainer/messages.js +12 -0
  137. package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
  138. package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +69 -1
  139. package/app/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +443 -0
  140. package/app/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +110 -0
  141. package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -4
  142. package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +363 -0
  143. package/app/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +57 -10
  144. package/app/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
  145. package/app/v2Containers/CreativesContainer/tests/index.test.js +71 -9
  146. package/app/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
  147. package/app/v2Containers/Email/index.js +2 -5
  148. package/app/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +58 -77
  149. package/app/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
  150. package/app/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +158 -89
  151. package/app/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
  152. package/app/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +17 -12
  153. package/app/v2Containers/EmailWrapper/index.js +4 -0
  154. package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
  155. package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +133 -0
  156. package/app/v2Containers/FTP/index.js +2 -51
  157. package/app/v2Containers/FTP/messages.js +0 -4
  158. package/app/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +110 -155
  159. package/app/v2Containers/InApp/index.js +297 -118
  160. package/app/v2Containers/InApp/tests/index.test.js +17 -6
  161. package/app/v2Containers/InApp/tests/mockData.js +1 -1
  162. package/app/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +19 -0
  163. package/app/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +3 -0
  164. package/app/v2Containers/InAppWrapper/index.js +3 -0
  165. package/app/v2Containers/InappAdvance/index.js +5 -104
  166. package/app/v2Containers/InappAdvance/tests/index.test.js +2 -0
  167. package/app/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +24 -3
  168. package/app/v2Containers/Line/Container/Text/index.js +0 -1
  169. package/app/v2Containers/MobilePush/Create/index.js +105 -28
  170. package/app/v2Containers/MobilePush/Create/messages.js +4 -0
  171. package/app/v2Containers/MobilePush/Edit/index.js +250 -68
  172. package/app/v2Containers/MobilePush/Edit/messages.js +4 -0
  173. package/app/v2Containers/MobilePushNew/components/PlatformContentFields.js +36 -12
  174. package/app/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +68 -27
  175. package/app/v2Containers/MobilePushNew/index.js +78 -35
  176. package/app/v2Containers/MobilePushNew/messages.js +8 -0
  177. package/app/v2Containers/MobilepushWrapper/index.js +11 -1
  178. package/app/v2Containers/Rcs/constants.js +32 -1
  179. package/app/v2Containers/Rcs/index.js +963 -916
  180. package/app/v2Containers/Rcs/index.scss +85 -6
  181. package/app/v2Containers/Rcs/messages.js +10 -1
  182. package/app/v2Containers/Rcs/rcsLibraryHydrationUtils.js +205 -0
  183. package/app/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +41136 -1566
  184. package/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
  185. package/app/v2Containers/Rcs/tests/index.test.js +41 -38
  186. package/app/v2Containers/Rcs/tests/mockData.js +38 -0
  187. package/app/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +251 -0
  188. package/app/v2Containers/Rcs/tests/utils.test.js +379 -1
  189. package/app/v2Containers/Rcs/utils.js +358 -10
  190. package/app/v2Containers/Sms/Create/index.js +122 -39
  191. package/app/v2Containers/Sms/Create/messages.js +4 -0
  192. package/app/v2Containers/Sms/Edit/index.js +37 -3
  193. package/app/v2Containers/Sms/commonMethods.js +3 -6
  194. package/app/v2Containers/Sms/smsFormDataHelpers.js +67 -0
  195. package/app/v2Containers/Sms/tests/commonMethods.test.js +122 -0
  196. package/app/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
  197. package/app/v2Containers/SmsTrai/Create/index.js +9 -4
  198. package/app/v2Containers/SmsTrai/Create/index.scss +1 -1
  199. package/app/v2Containers/SmsTrai/Edit/constants.js +2 -0
  200. package/app/v2Containers/SmsTrai/Edit/index.js +667 -160
  201. package/app/v2Containers/SmsTrai/Edit/index.scss +121 -0
  202. package/app/v2Containers/SmsTrai/Edit/messages.js +9 -4
  203. package/app/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4590 -2436
  204. package/app/v2Containers/SmsWrapper/index.js +41 -8
  205. package/app/v2Containers/TagList/index.js +63 -2
  206. package/app/v2Containers/TagList/messages.js +8 -0
  207. package/app/v2Containers/TagList/tests/TagList.test.js +122 -20
  208. package/app/v2Containers/TagList/tests/mockdata.js +17 -0
  209. package/app/v2Containers/Templates/TemplatesActionBar.js +101 -0
  210. package/app/v2Containers/Templates/_templates.scss +61 -2
  211. package/app/v2Containers/Templates/actions.js +11 -0
  212. package/app/v2Containers/Templates/constants.js +2 -0
  213. package/app/v2Containers/Templates/index.js +90 -40
  214. package/app/v2Containers/Templates/reducer.js +3 -1
  215. package/app/v2Containers/Templates/sagas.js +57 -12
  216. package/app/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
  217. package/app/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1043 -1079
  218. package/app/v2Containers/Templates/tests/reducer.test.js +12 -0
  219. package/app/v2Containers/Templates/tests/sagas.test.js +193 -12
  220. package/app/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
  221. package/app/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
  222. package/app/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
  223. package/app/v2Containers/TemplatesV2/index.js +147 -49
  224. package/app/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
  225. package/app/v2Containers/Viber/index.js +9 -10
  226. package/app/v2Containers/Viber/index.scss +1 -1
  227. package/app/v2Containers/WebPush/Create/components/BrandIconSection.test.js +264 -0
  228. package/app/v2Containers/WebPush/Create/components/MessageSection.js +78 -19
  229. package/app/v2Containers/WebPush/Create/components/MessageSection.test.js +82 -0
  230. package/app/v2Containers/WebPush/Create/components/__snapshots__/BrandIconSection.test.js.snap +187 -0
  231. package/app/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +25 -17
  232. package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.js +80 -0
  233. package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.test.js +210 -0
  234. package/app/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -5
  235. package/app/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
  236. package/app/v2Containers/WebPush/Create/index.js +36 -6
  237. package/app/v2Containers/WebPush/Create/index.scss +5 -0
  238. package/app/v2Containers/WebPush/Create/messages.js +8 -1
  239. package/app/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +269 -0
  240. package/app/v2Containers/WebPush/Create/utils/validation.js +31 -15
  241. package/app/v2Containers/WebPush/Create/utils/validation.test.js +72 -24
  242. package/app/v2Containers/Whatsapp/index.js +28 -53
  243. package/app/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26939 -3982
  244. package/app/v2Containers/Whatsapp/tests/index.test.js +172 -0
  245. package/app/v2Containers/Zalo/index.js +5 -11
  246. package/package.json +2 -2
  247. 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