@capillarytech/creatives-library 8.0.309 → 8.0.310

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 (79) hide show
  1. package/constants/unified.js +1 -5
  2. package/initialState.js +2 -0
  3. package/package.json +1 -1
  4. package/services/api.js +0 -17
  5. package/services/tests/api.test.js +0 -85
  6. package/utils/common.js +8 -5
  7. package/utils/commonUtils.js +93 -46
  8. package/utils/tagValidations.js +223 -83
  9. package/utils/tests/commonUtil.test.js +124 -316
  10. package/utils/tests/tagValidations.test.js +358 -441
  11. package/v2Components/CommonTestAndPreview/SendTestMessage.js +49 -78
  12. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -134
  13. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  14. package/v2Components/CommonTestAndPreview/constants.js +1 -15
  15. package/v2Components/CommonTestAndPreview/index.js +19 -80
  16. package/v2Components/CommonTestAndPreview/messages.js +0 -94
  17. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  18. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -53
  19. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  20. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -36
  21. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  22. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -377
  23. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  24. package/v2Components/ErrorInfoNote/index.js +5 -2
  25. package/v2Components/FormBuilder/index.js +203 -137
  26. package/v2Components/FormBuilder/messages.js +8 -0
  27. package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
  28. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
  30. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
  31. package/v2Containers/Cap/mockData.js +14 -0
  32. package/v2Containers/Cap/reducer.js +55 -3
  33. package/v2Containers/Cap/tests/reducer.test.js +102 -0
  34. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
  35. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
  36. package/v2Containers/CreativesContainer/constants.js +0 -6
  37. package/v2Containers/CreativesContainer/index.js +7 -47
  38. package/v2Containers/Email/index.js +5 -1
  39. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
  40. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +120 -20
  41. package/v2Containers/FTP/index.js +51 -2
  42. package/v2Containers/FTP/messages.js +4 -0
  43. package/v2Containers/InApp/index.js +107 -35
  44. package/v2Containers/InApp/tests/index.test.js +6 -17
  45. package/v2Containers/InappAdvance/index.js +112 -4
  46. package/v2Containers/InappAdvance/tests/index.test.js +0 -2
  47. package/v2Containers/Line/Container/Text/index.js +1 -0
  48. package/v2Containers/MobilePush/Create/index.js +19 -59
  49. package/v2Containers/MobilePush/Edit/index.js +20 -48
  50. package/v2Containers/MobilePushNew/index.js +32 -12
  51. package/v2Containers/MobilepushWrapper/index.js +1 -3
  52. package/v2Containers/Rcs/index.js +37 -12
  53. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1276 -1408
  54. package/v2Containers/Sms/Create/index.js +3 -39
  55. package/v2Containers/Sms/Create/messages.js +0 -4
  56. package/v2Containers/Sms/Edit/index.js +3 -35
  57. package/v2Containers/Sms/commonMethods.js +6 -3
  58. package/v2Containers/SmsTrai/Edit/index.js +47 -11
  59. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +294 -327
  60. package/v2Containers/SmsWrapper/index.js +0 -2
  61. package/v2Containers/TemplatesV2/index.js +13 -28
  62. package/v2Containers/Viber/index.js +1 -0
  63. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
  64. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
  65. package/v2Containers/WebPush/Create/index.js +2 -2
  66. package/v2Containers/WebPush/Create/utils/validation.js +8 -17
  67. package/v2Containers/WebPush/Create/utils/validation.test.js +24 -44
  68. package/v2Containers/Whatsapp/index.js +17 -9
  69. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5246
  70. package/v2Containers/Zalo/index.js +11 -3
  71. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  72. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -284
  73. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -72
  74. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  75. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -657
  76. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +0 -172
  77. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -466
  78. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  79. package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
@@ -17,9 +17,6 @@ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
17
17
  import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
18
18
  import CapDivider from '@capillarytech/cap-ui-library/CapDivider';
19
19
  import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
20
- import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
21
- import CustomerCreationModal from './CustomerCreationModal';
22
- import { createTestCustomer } from '../../services/api';
23
20
 
24
21
  // Import messages and styles
25
22
  import messages from './messages';
@@ -30,16 +27,10 @@ import LeftPanelContent from './LeftPanelContent';
30
27
  import CustomValuesEditor from './CustomValuesEditor';
31
28
  import SendTestMessage from './SendTestMessage';
32
29
  import PreviewSection from './PreviewSection';
33
- import AddTestCustomerButton from './AddTestCustomer';
34
- import ExistingCustomerModal from './ExistingCustomerModal';
30
+
35
31
  // Import constants
36
32
  import {
37
33
  CHANNELS,
38
- CUSTOMER_MODAL_NEW,
39
- CUSTOMER_MODAL_EXISTING,
40
- IDENTIFIER_TYPE_EMAIL,
41
- IDENTIFIER_TYPE_MOBILE,
42
- IDENTIFIER_TYPE_PHONE,
43
34
  TEST,
44
35
  DESKTOP,
45
36
  ANDROID,
@@ -83,8 +74,6 @@ import {
83
74
 
84
75
  // Import utilities
85
76
  import { getCdnUrl } from '../../utils/cdnTransformation';
86
- import { isValidEmail, isValidMobile } from '../../utils/commonUtils';
87
- import { getMembersLookup } from '../../services/api';
88
77
 
89
78
  /**
90
79
  * Preview Component Factory - REMOVED IN PHASE 5
@@ -141,11 +130,6 @@ const CommonTestAndPreview = (props) => {
141
130
  const [customValues, setCustomValues] = useState({});
142
131
  const [showJSON, setShowJSON] = useState(false);
143
132
  const [tagsExtracted, setTagsExtracted] = useState(false);
144
- const [searchValue, setSearchValue] = useState("");
145
- const [customerModal, setCustomerModal] = useState([false, ""]);
146
- const [isCustomerDataLoading, setIsCustomerDataLoading] = useState(false);
147
- const [customerData, setCustomerData] = useState({ name: '', email: '', mobile: '', customerId: '' });
148
-
149
133
  // Initialize device based on channel: SMS uses Android/iOS, others use Desktop/Mobile
150
134
  // Initialize device based on channel: SMS, WhatsApp, RCS, InApp, MobilePush, and Viber use Android/iOS, others use Desktop/Mobile
151
135
  const initialDevice = (channel === CHANNELS.SMS || channel === CHANNELS.WHATSAPP || channel === CHANNELS.RCS || channel === CHANNELS.INAPP || channel === CHANNELS.MOBILEPUSH || channel === CHANNELS.VIBER) ? ANDROID : DESKTOP;
@@ -364,7 +348,7 @@ const CommonTestAndPreview = (props) => {
364
348
  return content || '';
365
349
  }, [channel, formData, currentTab, beeContent, content, beeInstance]);
366
350
 
367
- // Build test entities tree data from testCustomers prop (includes customers added via addTestCustomer action)
351
+ // Build test entities tree data
368
352
  const testEntitiesTreeData = useMemo(() => {
369
353
  const groupsNode = {
370
354
  title: 'Groups',
@@ -377,10 +361,7 @@ const CommonTestAndPreview = (props) => {
377
361
  title: 'Individuals',
378
362
  value: 'customers-node',
379
363
  selectable: false,
380
- children: testCustomers?.map((customer) => ({
381
- title: customer?.name?.trim() || customer?.email?.trim() || customer?.mobile?.trim() || customer?.userId || customer?.customerId,
382
- value: customer?.userId ?? customer?.customerId,
383
- })) || [],
364
+ children: testCustomers?.map((customer) => ({ title: customer.name, value: customer?.userId })),
384
365
  };
385
366
 
386
367
  return [groupsNode, customersNode];
@@ -410,13 +391,15 @@ const CommonTestAndPreview = (props) => {
410
391
  /**
411
392
  * Common handler for saving test customers (both new and existing)
412
393
  */
413
- const handleSaveTestCustomer = async (validationErrors = {},setIsLoading = () => {}) => {
394
+ const handleSaveTestCustomer = async (validationErrors = {},setIsLoading) => {
414
395
  // Check for validation errors before saving (for new customers)
415
396
  if (customerModal[1] === CUSTOMER_MODAL_NEW && (validationErrors.email || validationErrors.mobile)) {
416
397
  return;
417
398
  }
418
399
 
419
- setIsLoading(true);
400
+ if (typeof setIsLoading === 'function') {
401
+ setIsLoading(true);
402
+ }
420
403
 
421
404
  try {
422
405
  let payload;
@@ -2576,6 +2559,7 @@ const CommonTestAndPreview = (props) => {
2576
2559
  * Handle extract tags
2577
2560
  */
2578
2561
  const handleExtractTags = () => {
2562
+ // Get content based on channel
2579
2563
  let contentToExtract = getCurrentContent;
2580
2564
 
2581
2565
  if (channel === CHANNELS.EMAIL && formData) {
@@ -2676,10 +2660,7 @@ const CommonTestAndPreview = (props) => {
2676
2660
 
2677
2661
  if (!success) {
2678
2662
  const errorMessage = response?.message || response?.status?.message || formatMessage(messages.memberLookupError);
2679
- CapNotification.error({
2680
- message: formatMessage(messages.memberLookupError),
2681
- description: errorMessage,
2682
- });
2663
+ CapNotification.error({ title: formatMessage(messages.errorTitle), message: errorMessage });
2683
2664
  return;
2684
2665
  }
2685
2666
 
@@ -2713,7 +2694,6 @@ const CommonTestAndPreview = (props) => {
2713
2694
  } catch {
2714
2695
  CapNotification.error({
2715
2696
  message: formatMessage(messages.memberLookupError),
2716
- description: formatMessage(messages.memberLookupError),
2717
2697
  });
2718
2698
  } finally {
2719
2699
  setIsCustomerDataLoading(false);
@@ -2838,7 +2818,6 @@ const CommonTestAndPreview = (props) => {
2838
2818
  content={getCurrentContent}
2839
2819
  channel={channel}
2840
2820
  isSendingTestMessage={isSendingTestMessage}
2841
- renderAddTestCustomerButton={renderAddTestCustomerButton}
2842
2821
  formatMessage={formatMessage}
2843
2822
  deliverySettings={testPreviewDeliverySettings[channel]}
2844
2823
  senderDetailsOptions={senderDetailsByChannel[channel]}
@@ -2847,8 +2826,6 @@ const CommonTestAndPreview = (props) => {
2847
2826
  isLoadingSenderDetails={isLoadingSenderDetails}
2848
2827
  smsTraiDltEnabled={smsTraiDltEnabled}
2849
2828
  registeredSenderIds={registeredSenderIds}
2850
- searchValue={searchValue}
2851
- setSearchValue={setSearchValue}
2852
2829
  />
2853
2830
  );
2854
2831
 
@@ -2858,20 +2835,6 @@ const CommonTestAndPreview = (props) => {
2858
2835
  />
2859
2836
  );
2860
2837
 
2861
- const renderAddTestCustomerButton = () => {
2862
- const value = searchValue || "";
2863
- const showAddButton =
2864
- [CHANNELS.EMAIL, CHANNELS.SMS].includes(channel) &&
2865
- (channel === CHANNELS.EMAIL ? isValidEmail(value) : isValidMobile(value));
2866
- if (!showAddButton) return null;
2867
- return (
2868
- <AddTestCustomerButton
2869
- searchValue={value}
2870
- handleAddTestCustomer={handleAddTestCustomer}
2871
- />
2872
- );
2873
- };
2874
-
2875
2838
  // Header content for the slidebox
2876
2839
  const slideboxHeader = (
2877
2840
  <CapRow className="test-preview-header">
@@ -2891,18 +2854,14 @@ const CommonTestAndPreview = (props) => {
2891
2854
  show={show}
2892
2855
  size="size-xl"
2893
2856
  content={(
2894
- <CapSpin
2895
- spinning={isCustomerDataLoading}
2896
- className={`common-test-preview-lookup-spin ${isCustomerDataLoading ? 'common-test-preview-customer-loading' : ''}`}
2897
- >
2898
- <CapRow className="test-preview-container">
2899
- <CapRow className="test-and-preview-panels">
2900
- {/* Left Panel */}
2901
- <CapRow className="left-panel">
2902
- {channel === CHANNELS.ZALO ? null : renderLeftPanelContent()}
2903
- <CapDivider className="panel-divider" />
2904
-
2905
- {/* Send Test Message Section */}
2857
+ <CapRow className="test-preview-container">
2858
+ <CapRow className="test-and-preview-panels">
2859
+ {/* Left Panel */}
2860
+ <CapRow className="left-panel">
2861
+ {channel === CHANNELS.ZALO ? null : renderLeftPanelContent()}
2862
+ <CapDivider className="panel-divider" />
2863
+
2864
+ {/* Send Test Message Section */}
2906
2865
  {config.enableTestMessage !== false && (
2907
2866
  <CapRow className="panel-section send-test-section">
2908
2867
  {renderSendTestMessage()}
@@ -2916,27 +2875,7 @@ const CommonTestAndPreview = (props) => {
2916
2875
  {renderPreview()}
2917
2876
  </CapRow>
2918
2877
  </CapRow>
2919
- {customerModal[0] && customerModal[1] === CUSTOMER_MODAL_EXISTING && (
2920
- <ExistingCustomerModal
2921
- customerData={customerData}
2922
- setCustomerModal={setCustomerModal}
2923
- customerModal={customerModal}
2924
- channel={channel}
2925
- onSave={handleSaveTestCustomer}
2926
- />
2927
- )}
2928
- {customerModal[0] && customerModal[1] === CUSTOMER_MODAL_NEW && (
2929
- <CustomerCreationModal
2930
- customerData={customerData}
2931
- setCustomerData={setCustomerData}
2932
- setCustomerModal={setCustomerModal}
2933
- customerModal={customerModal}
2934
- onSave={handleSaveTestCustomer}
2935
- channel={channel}
2936
- />
2937
- )}
2938
- </CapRow>
2939
- </CapSpin>
2878
+ </CapRow>
2940
2879
  )}
2941
2880
  />
2942
2881
  );
@@ -3038,4 +2977,4 @@ CommonTestAndPreview.defaultProps = {
3038
2977
  // Note: Redux connection is handled by the wrapper components (e.g., TestAndPreviewSlidebox)
3039
2978
  // This component receives all Redux props (including intl) from its parent
3040
2979
 
3041
- export default CommonTestAndPreview;
2980
+ export default CommonTestAndPreview;
@@ -8,72 +8,10 @@ import { defineMessages } from 'react-intl';
8
8
  export const scope = 'app.v2Components.TestAndPreviewSlidebox';
9
9
 
10
10
  export default defineMessages({
11
- mobileAlreadyExists: {
12
- id: `${scope}.mobileAlreadyExists`,
13
- defaultMessage: 'This phone number matches with already existing user profile. Please remove or use a different number.',
14
- },
15
- customerNamePlaceholder: {
16
- id: `${scope}.customerNamePlaceholder`,
17
- defaultMessage: 'Enter the name',
18
- },
19
- customerEmailPlaceholder: {
20
- id: `${scope}.customerEmailPlaceholder`,
21
- defaultMessage: 'Enter the Email',
22
- },
23
- customerMobilePlaceholder: {
24
- id: `${scope}.customerMobilePlaceholder`,
25
- defaultMessage: 'Enter the Mobile Number',
26
- },
27
- customerAlreadyInTestList: {
28
- id: `${scope}.customerAlreadyInTestList`,
29
- defaultMessage: 'This customer is already in the test customers list.',
30
- },
31
- emailAlreadyExists: {
32
- id: `${scope}.emailAlreadyExists`,
33
- defaultMessage: 'This email matches with already existing user profile. Please remove or use a different email.',
34
- },
35
- customerName: {
36
- id: `${scope}.customerName`,
37
- defaultMessage: 'Name',
38
- },
39
- customerEmail: {
40
- id: `${scope}.customerEmail`,
41
- defaultMessage: 'Email',
42
- },
43
- customerMobile: {
44
- id: `${scope}.customerMobileNumber`,
45
- defaultMessage: 'Mobile Number',
46
- },
47
- saveButton: {
48
- id: `${scope}.saveButton`,
49
- defaultMessage: 'Save',
50
- },
51
- cancelButton: {
52
- id: `${scope}.cancelButton`,
53
- defaultMessage: 'Cancel',
54
- },
55
- customerID: {
56
- id: `${scope}.customerID`,
57
- defaultMessage: 'Customer ID',
58
- },
59
- existingCustomerModalDescription: {
60
- id: `${scope}.existingCustomerModalDescription`,
61
- defaultMessage: 'This user profile already exists in the system. Would you like to add them to Test Customer list?'
62
- },
63
-
64
- customerCreationModalTitle: {
65
- id: `${scope}.customerCreationModalTitle`,
66
- defaultMessage: 'Add new test customer',
67
- },
68
- customerCreationModalDescription: {
69
- id: `${scope}.customerCreationModalDescription`,
70
- defaultMessage: 'This customer profile will be available for testing across multiple communication channels.',
71
- },
72
11
  testAndPreviewHeader: {
73
12
  id: `${scope}.testAndPreviewHeader`,
74
13
  defaultMessage: 'Preview and Test',
75
14
  },
76
-
77
15
  customerSearchTitle: {
78
16
  id: `${scope}.customerSearchTitle`,
79
17
  defaultMessage: 'Customer',
@@ -94,34 +32,6 @@ export default defineMessages({
94
32
  id: `${scope}.showJSON`,
95
33
  defaultMessage: 'Show JSON',
96
34
  },
97
- addTestCustomer: {
98
- id: `${scope}.addTestCustomer`,
99
- defaultMessage: 'Add as Test Customer',
100
- },
101
- addTestCustomerWithValue: {
102
- id: `${scope}.addTestCustomerWithValue`,
103
- defaultMessage: 'Add {searchValue} as Test Customer',
104
- },
105
- memberLookupError: {
106
- id: `${scope}.memberLookupError`,
107
- defaultMessage: 'Unable to look up customer. Please try again.',
108
- },
109
- newTestCustomerAddedSuccess: {
110
- id: `${scope}.newTestCustomerAddedSuccess`,
111
- defaultMessage: 'New test customer added successfully!',
112
- },
113
- errorTitle: {
114
- id: `${scope}.errorTitle`,
115
- defaultMessage: 'Error',
116
- },
117
- failedToAddTestCustomer: {
118
- id: `${scope}.failedToAddTestCustomer`,
119
- defaultMessage: 'Failed to add test customer',
120
- },
121
- errorAddingTestCustomer: {
122
- id: `${scope}.errorAddingTestCustomer`,
123
- defaultMessage: 'An error occurred while adding test customer',
124
- },
125
35
  discardCustomValues: {
126
36
  id: `${scope}.discardCustomValues`,
127
37
  defaultMessage: 'Discard custom values',
@@ -210,10 +120,6 @@ export default defineMessages({
210
120
  id: `${scope}.testCustomersPlaceholder`,
211
121
  defaultMessage: 'Search and select a group or individual test customers',
212
122
  },
213
- noMatchingOptions: {
214
- id: `${scope}.noMatchingOptions`,
215
- defaultMessage: 'No matching options',
216
- },
217
123
  updatingPreview: {
218
124
  id: `${scope}.updatingPreview`,
219
125
  defaultMessage: 'Updating preview with the latest changes',
@@ -20,7 +20,6 @@ import {
20
20
  GET_TEST_CUSTOMERS_REQUESTED,
21
21
  GET_TEST_CUSTOMERS_SUCCESS,
22
22
  GET_TEST_CUSTOMERS_FAILURE,
23
- ADD_TEST_CUSTOMER,
24
23
  GET_TEST_GROUPS_REQUESTED,
25
24
  GET_TEST_GROUPS_SUCCESS,
26
25
  GET_TEST_GROUPS_FAILURE,
@@ -217,15 +216,6 @@ const previewAndTestReducer = (state = initialState, action) => {
217
216
  return state.set('isFetchingTestCustomers', false)
218
217
  .set('fetchTestCustomersError', action.payload.error);
219
218
 
220
- case ADD_TEST_CUSTOMER: {
221
- const raw = state.get('testCustomers');
222
- const list = Array.isArray(raw) ? raw : (raw && raw.toArray ? raw.toArray().map((i) => (i && i.toJS ? i.toJS() : i)) : []);
223
- const customer = action.payload.customer;
224
- const newId = customer.userId || customer.customerId;
225
- if (list.some((c) => (c.userId || c.customerId) === newId)) return state;
226
- return state.set('testCustomers', list.concat([customer]));
227
- }
228
-
229
219
  // Test Groups
230
220
  case GET_TEST_GROUPS_REQUESTED:
231
221
  return state.set('isFetchingTestGroups', true)
@@ -135,10 +135,6 @@ describe('SendTestMessage', () => {
135
135
  isLoadingSenderDetails: false,
136
136
  smsTraiDltEnabled: false,
137
137
  registeredSenderIds: [],
138
- channel: 'EMAIL',
139
- renderAddTestCustomerButton: jest.fn(() => null),
140
- searchValue: '',
141
- setSearchValue: jest.fn(),
142
138
  };
143
139
 
144
140
  beforeEach(() => {
@@ -637,53 +633,4 @@ describe('SendTestMessage', () => {
637
633
  consoleSpy.mockRestore();
638
634
  });
639
635
  });
640
-
641
- describe('notFoundContent (Add as test customer)', () => {
642
- it('should call renderAddTestCustomerButton and use result as notFoundContent', () => {
643
- const renderAddTestCustomerButton = jest.fn(() => (
644
- <button type="button" data-testid="add-test-customer-btn">
645
- Add as test customer
646
- </button>
647
- ));
648
- const props = {
649
- ...defaultProps,
650
- renderAddTestCustomerButton,
651
- };
652
- render(
653
- <TestWrapper>
654
- <SendTestMessage {...props} />
655
- </TestWrapper>
656
- );
657
- expect(renderAddTestCustomerButton).toHaveBeenCalled();
658
- });
659
-
660
- it('should render notFoundContent as a clickable button when provided', () => {
661
- const onAddClick = jest.fn();
662
- const renderAddTestCustomerButton = jest.fn(() => (
663
- <button type="button" data-testid="add-test-customer-btn" onClick={onAddClick}>
664
- Add as test customer
665
- </button>
666
- ));
667
- const props = {
668
- ...defaultProps,
669
- renderAddTestCustomerButton,
670
- };
671
- const { container } = render(
672
- <TestWrapper>
673
- <SendTestMessage {...props} />
674
- </TestWrapper>
675
- );
676
- // notFoundContent is passed to TreeSelect and shown when dropdown is open with no match.
677
- // We assert the render function returns a button that can be clicked.
678
- const notFoundContent = renderAddTestCustomerButton.mock.results[0]?.value;
679
- expect(notFoundContent).toBeTruthy();
680
- expect(notFoundContent.props['data-testid']).toBe('add-test-customer-btn');
681
- expect(notFoundContent.type).toBe('button');
682
- // Simulate click on the returned element's onClick
683
- if (notFoundContent.props.onClick) {
684
- notFoundContent.props.onClick();
685
- expect(onAddClick).toHaveBeenCalled();
686
- }
687
- });
688
- });
689
636
  });
@@ -54,13 +54,8 @@ import {
54
54
  // API Channel Constants
55
55
  API_CHANNEL_PUSH,
56
56
  // Identifier Type Constants
57
- IDENTIFIER_TYPE_EMAIL,
58
57
  IDENTIFIER_TYPE_MOBILE,
59
- IDENTIFIER_TYPE_PHONE,
60
- INPUT_HAS_ERROR_CLASS,
61
- // Validation Regex
62
- EMAIL_REGEX,
63
- PHONE_REGEX,
58
+ IDENTIFIER_TYPE_EMAIL,
64
59
  // Channel Name Constants
65
60
  CHANNEL_NAME_INAPP,
66
61
  // Channel Mapping Constants
@@ -211,31 +206,6 @@ describe('CommonTestAndPreview Constants', () => {
211
206
  });
212
207
  });
213
208
 
214
- describe('Identifier Type Constants', () => {
215
- it('should export identifier type constants', () => {
216
- expect(IDENTIFIER_TYPE_EMAIL).toBe('email');
217
- expect(IDENTIFIER_TYPE_MOBILE).toBe('mobile');
218
- expect(IDENTIFIER_TYPE_PHONE).toBe('phone');
219
- });
220
- });
221
-
222
- describe('Validation Regex', () => {
223
- it('should export EMAIL_REGEX that validates email format', () => {
224
- expect(EMAIL_REGEX.test('user@example.com')).toBe(true);
225
- expect(EMAIL_REGEX.test('invalid')).toBe(false);
226
- });
227
- it('should export PHONE_REGEX that validates phone format', () => {
228
- expect(PHONE_REGEX.test('9123456789')).toBe(true);
229
- expect(PHONE_REGEX.test('123')).toBe(false);
230
- });
231
- });
232
-
233
- describe('Input has error class', () => {
234
- it('should export INPUT_HAS_ERROR_CLASS', () => {
235
- expect(INPUT_HAS_ERROR_CLASS).toBe(' has-input-error');
236
- });
237
- });
238
-
239
209
  describe('Channel Name Constants', () => {
240
210
  it('should export channel name constants', () => {
241
211
  expect(CHANNEL_NAME_INAPP).toBe('INAPP');
@@ -81,12 +81,6 @@ jest.mock('../../../utils/cdnTransformation', () => ({
81
81
  getCdnUrl: jest.fn(({ url }) => `cdn_${url}`),
82
82
  }));
83
83
 
84
- // Mock services/api for add test customer flow
85
- jest.mock('../../../services/api', () => ({
86
- getMembersLookup: jest.fn(),
87
- createTestCustomer: jest.fn(),
88
- }));
89
-
90
84
  // Mock messages - using actual message IDs from messages.js
91
85
  const mockMessages = {
92
86
  'app.v2Components.TestAndPreviewSlidebox.testAndPreviewHeader': { defaultMessage: 'Preview and Test' },
@@ -132,7 +126,6 @@ describe('CommonTestAndPreview', () => {
132
126
  clearPreviewErrors: jest.fn(),
133
127
  getSenderDetailsRequested: jest.fn(),
134
128
  getWeCrmAccountsRequested: jest.fn(),
135
- addTestCustomer: jest.fn(),
136
129
  };
137
130
 
138
131
  const defaultProps = {
@@ -1585,35 +1578,6 @@ describe('CommonTestAndPreview', () => {
1585
1578
 
1586
1579
  expect(screen.getByTestId('send-test-message')).toBeTruthy();
1587
1580
  });
1588
-
1589
- it('should show error notification when sendTestMessageRequested callback receives false', async () => {
1590
- const CapNotification = require('@capillarytech/cap-ui-library/CapNotification');
1591
- mockActions.createMessageMetaRequested.mockImplementation((payload, metaId, cb) => {
1592
- if (cb) cb({ entity: 'meta-123' });
1593
- });
1594
- mockActions.sendTestMessageRequested.mockImplementation((payload, cb) => {
1595
- if (cb) cb(false);
1596
- });
1597
- const props = {
1598
- ...defaultProps,
1599
- selectedTestEntities: ['user-1'],
1600
- testGroups: [],
1601
- };
1602
-
1603
- render(
1604
- <TestWrapper>
1605
- <CommonTestAndPreview {...props} />
1606
- </TestWrapper>
1607
- );
1608
-
1609
- expect(lastSendTestMessageProps).toBeTruthy();
1610
- expect(lastSendTestMessageProps.handleSendTestMessage).toBeDefined();
1611
- lastSendTestMessageProps.handleSendTestMessage();
1612
-
1613
- await waitFor(() => {
1614
- expect(CapNotification.error).toHaveBeenCalled();
1615
- });
1616
- });
1617
1581
  });
1618
1582
 
1619
1583
  describe('Content Extraction', () => {
@@ -24,7 +24,6 @@ import {
24
24
  GET_TEST_CUSTOMERS_REQUESTED,
25
25
  GET_TEST_CUSTOMERS_SUCCESS,
26
26
  GET_TEST_CUSTOMERS_FAILURE,
27
- ADD_TEST_CUSTOMER,
28
27
  GET_TEST_GROUPS_REQUESTED,
29
28
  GET_TEST_GROUPS_SUCCESS,
30
29
  GET_TEST_GROUPS_FAILURE,
@@ -612,76 +611,6 @@ describe('previewAndTestReducer', () => {
612
611
  });
613
612
  });
614
613
 
615
- describe('ADD_TEST_CUSTOMER', () => {
616
- it('should add new customer to testCustomers list', () => {
617
- const customer = {
618
- userId: 'cust-1',
619
- customerId: 'cust-1',
620
- name: 'John',
621
- email: 'john@example.com',
622
- mobile: '',
623
- };
624
- const action = {
625
- type: ADD_TEST_CUSTOMER,
626
- payload: { customer },
627
- };
628
- const result = previewAndTestReducer(initialState, action);
629
-
630
- const list = result.get('testCustomers');
631
- expect(Array.isArray(list) ? list.length : list.size).toBe(1);
632
- const first = Array.isArray(list) ? list[0] : list.get(0);
633
- const id = first.userId != null ? first.userId : first.get('userId');
634
- const name = first.name != null ? first.name : first.get('name');
635
- expect(id).toBe('cust-1');
636
- expect(name).toBe('John');
637
- });
638
-
639
- it('should not add duplicate customer when userId already in list', () => {
640
- const existing = fromJS([
641
- { userId: 'cust-1', customerId: 'cust-1', name: 'John', email: 'john@example.com', mobile: '' },
642
- ]);
643
- const stateWithCustomer = initialState.set('testCustomers', existing);
644
- const customer = {
645
- userId: 'cust-1',
646
- customerId: 'cust-1',
647
- name: 'John Updated',
648
- email: 'john@example.com',
649
- mobile: '',
650
- };
651
- const action = {
652
- type: ADD_TEST_CUSTOMER,
653
- payload: { customer },
654
- };
655
- const result = previewAndTestReducer(stateWithCustomer, action);
656
-
657
- const list = result.get('testCustomers');
658
- expect(Array.isArray(list) ? list.length : list.size).toBe(1);
659
- const first = Array.isArray(list) ? list[0] : list.get(0);
660
- const name = first.name != null ? first.name : first.get('name');
661
- expect(name).toBe('John');
662
- });
663
-
664
- it('should use customerId when userId is missing', () => {
665
- const customer = {
666
- customerId: 'cust-2',
667
- name: 'Jane',
668
- email: 'jane@example.com',
669
- mobile: '',
670
- };
671
- const action = {
672
- type: ADD_TEST_CUSTOMER,
673
- payload: { customer },
674
- };
675
- const result = previewAndTestReducer(initialState, action);
676
-
677
- const list = result.get('testCustomers');
678
- expect(Array.isArray(list) ? list.length : list.size).toBe(1);
679
- const first = Array.isArray(list) ? list[0] : list.get(0);
680
- const id = first.customerId != null ? first.customerId : first.get('customerId');
681
- expect(id).toBe('cust-2');
682
- });
683
- });
684
-
685
614
  describe('GET_TEST_GROUPS_REQUESTED', () => {
686
615
  it('should set fetching flag and clear error', () => {
687
616
  const action = { type: GET_TEST_GROUPS_REQUESTED };