@capillarytech/creatives-library 8.0.297 → 8.0.299-alpha.0

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 (35) hide show
  1. package/constants/unified.js +1 -0
  2. package/package.json +1 -1
  3. package/services/api.js +17 -0
  4. package/services/tests/api.test.js +85 -0
  5. package/utils/common.js +12 -5
  6. package/utils/commonUtils.js +10 -0
  7. package/utils/tests/commonUtil.test.js +169 -0
  8. package/v2Components/CapDeviceContent/index.js +10 -7
  9. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +42 -0
  10. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +284 -0
  11. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +72 -0
  12. package/v2Components/CommonTestAndPreview/SendTestMessage.js +78 -49
  13. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +189 -4
  14. package/v2Components/CommonTestAndPreview/actions.js +10 -0
  15. package/v2Components/CommonTestAndPreview/constants.js +18 -1
  16. package/v2Components/CommonTestAndPreview/index.js +259 -14
  17. package/v2Components/CommonTestAndPreview/messages.js +94 -0
  18. package/v2Components/CommonTestAndPreview/reducer.js +10 -0
  19. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +66 -0
  20. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +653 -0
  21. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +316 -0
  22. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -1
  23. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +114 -0
  24. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +53 -0
  25. package/v2Components/CommonTestAndPreview/tests/constants.test.js +25 -2
  26. package/v2Components/CommonTestAndPreview/tests/index.test.js +7 -0
  27. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +71 -0
  28. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +17 -0
  29. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +320 -0
  30. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
  31. package/v2Containers/CreativesContainer/SlideBoxContent.js +35 -3
  32. package/v2Containers/InApp/index.js +182 -13
  33. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1408 -1276
  34. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +321 -288
  35. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +5246 -4872
@@ -8,10 +8,72 @@ 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
+ },
11
72
  testAndPreviewHeader: {
12
73
  id: `${scope}.testAndPreviewHeader`,
13
74
  defaultMessage: 'Preview and Test',
14
75
  },
76
+
15
77
  customerSearchTitle: {
16
78
  id: `${scope}.customerSearchTitle`,
17
79
  defaultMessage: 'Customer',
@@ -32,6 +94,34 @@ export default defineMessages({
32
94
  id: `${scope}.showJSON`,
33
95
  defaultMessage: 'Show JSON',
34
96
  },
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
+ },
35
125
  discardCustomValues: {
36
126
  id: `${scope}.discardCustomValues`,
37
127
  defaultMessage: 'Discard custom values',
@@ -120,6 +210,10 @@ export default defineMessages({
120
210
  id: `${scope}.testCustomersPlaceholder`,
121
211
  defaultMessage: 'Search and select a group or individual test customers',
122
212
  },
213
+ noMatchingOptions: {
214
+ id: `${scope}.noMatchingOptions`,
215
+ defaultMessage: 'No matching options',
216
+ },
123
217
  updatingPreview: {
124
218
  id: `${scope}.updatingPreview`,
125
219
  defaultMessage: 'Updating preview with the latest changes',
@@ -20,6 +20,7 @@ import {
20
20
  GET_TEST_CUSTOMERS_REQUESTED,
21
21
  GET_TEST_CUSTOMERS_SUCCESS,
22
22
  GET_TEST_CUSTOMERS_FAILURE,
23
+ ADD_TEST_CUSTOMER,
23
24
  GET_TEST_GROUPS_REQUESTED,
24
25
  GET_TEST_GROUPS_SUCCESS,
25
26
  GET_TEST_GROUPS_FAILURE,
@@ -216,6 +217,15 @@ const previewAndTestReducer = (state = initialState, action) => {
216
217
  return state.set('isFetchingTestCustomers', false)
217
218
  .set('fetchTestCustomersError', action.payload.error);
218
219
 
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
+
219
229
  // Test Groups
220
230
  case GET_TEST_GROUPS_REQUESTED:
221
231
  return state.set('isFetchingTestGroups', true)
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Tests for AddTestCustomerButton Component
3
+ *
4
+ * The parent (index.js) only renders this button when channel is EMAIL/SMS and value is valid.
5
+ * This component always renders the button when mounted; visibility is the parent's responsibility.
6
+ */
7
+
8
+ import React from 'react';
9
+ import { render, screen, fireEvent } from '@testing-library/react';
10
+ import { IntlProvider } from 'react-intl';
11
+ import AddTestCustomerButton from '../AddTestCustomer';
12
+
13
+ const mockMessages = {
14
+ 'app.v2Components.TestAndPreviewSlidebox.addTestCustomerWithValue': 'Add {searchValue} as Test Customer',
15
+ };
16
+
17
+ const TestWrapper = ({ children }) => (
18
+ <IntlProvider locale="en" messages={mockMessages}>
19
+ {children}
20
+ </IntlProvider>
21
+ );
22
+
23
+ describe('AddTestCustomerButton', () => {
24
+ const defaultProps = {
25
+ searchValue: 'user@example.com',
26
+ handleAddTestCustomer: jest.fn(),
27
+ };
28
+
29
+ beforeEach(() => {
30
+ jest.clearAllMocks();
31
+ });
32
+
33
+ it('should render button with searchValue in message', () => {
34
+ render(
35
+ <TestWrapper>
36
+ <AddTestCustomerButton {...defaultProps} />
37
+ </TestWrapper>
38
+ );
39
+ const button = screen.getByRole('button', { name: /add.*test customer/i });
40
+ expect(button).toBeTruthy();
41
+ });
42
+
43
+ it('should show searchValue in button text', () => {
44
+ render(
45
+ <TestWrapper>
46
+ <AddTestCustomerButton {...defaultProps} searchValue="user@example.com" />
47
+ </TestWrapper>
48
+ );
49
+ expect(screen.getByRole('button', { name: /user@example.com/i })).toBeTruthy();
50
+ });
51
+
52
+ it('should call handleAddTestCustomer when button is clicked', () => {
53
+ const handleAddTestCustomer = jest.fn();
54
+ render(
55
+ <TestWrapper>
56
+ <AddTestCustomerButton
57
+ searchValue="user@example.com"
58
+ handleAddTestCustomer={handleAddTestCustomer}
59
+ />
60
+ </TestWrapper>
61
+ );
62
+ const button = screen.getByRole('button', { name: /add.*test customer/i });
63
+ fireEvent.click(button);
64
+ expect(handleAddTestCustomer).toHaveBeenCalledTimes(1);
65
+ });
66
+ });