@capillarytech/creatives-library 8.0.328 → 8.0.330-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.
- package/constants/unified.js +4 -0
- package/package.json +1 -1
- package/services/api.js +17 -0
- package/services/tests/api.test.js +85 -0
- package/utils/commonUtils.js +28 -0
- package/utils/tagValidations.js +2 -3
- package/utils/templateVarUtils.js +35 -6
- package/utils/tests/commonUtil.test.js +169 -0
- package/utils/tests/tagValidations.test.js +1 -1
- package/utils/tests/templateVarUtils.test.js +44 -0
- package/v2Components/CommonTestAndPreview/AddTestCustomer.js +42 -0
- package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +155 -0
- package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +93 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +79 -51
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +134 -34
- package/v2Components/CommonTestAndPreview/actions.js +10 -0
- package/v2Components/CommonTestAndPreview/constants.js +15 -1
- package/v2Components/CommonTestAndPreview/index.js +364 -72
- package/v2Components/CommonTestAndPreview/messages.js +106 -0
- package/v2Components/CommonTestAndPreview/reducer.js +10 -0
- package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +66 -0
- package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +648 -0
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +24 -0
- package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +174 -0
- package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +114 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +52 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +31 -1
- package/v2Components/CommonTestAndPreview/tests/index.test.js +36 -0
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +71 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +17 -0
- package/v2Components/SmsFallback/smsFallbackUtils.js +14 -3
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +16 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +5 -0
- package/v2Containers/CreativesContainer/index.js +15 -10
- package/v2Containers/Rcs/constants.js +6 -2
- package/v2Containers/Rcs/index.js +219 -91
- package/v2Containers/Rcs/messages.js +2 -1
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +20 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +2370 -1758
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +67 -0
- package/v2Containers/Rcs/tests/utils.test.js +56 -0
- package/v2Containers/Rcs/utils.js +53 -6
- package/v2Containers/SmsTrai/Edit/index.js +27 -0
- package/v2Containers/SmsTrai/Edit/messages.js +5 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +357 -324
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +5586 -5212
|
@@ -8,10 +8,84 @@ 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
|
+
customerNameOptional: {
|
|
40
|
+
id: `${scope}.customerNameOptional`,
|
|
41
|
+
defaultMessage: '(Optional)',
|
|
42
|
+
},
|
|
43
|
+
customerCreationInvalidEmail: {
|
|
44
|
+
id: `${scope}.customerCreationInvalidEmail`,
|
|
45
|
+
defaultMessage: 'Please enter a valid email address',
|
|
46
|
+
},
|
|
47
|
+
customerCreationInvalidMobile: {
|
|
48
|
+
id: `${scope}.customerCreationInvalidMobile`,
|
|
49
|
+
defaultMessage: 'Please enter a valid mobile number',
|
|
50
|
+
},
|
|
51
|
+
customerEmail: {
|
|
52
|
+
id: `${scope}.customerEmail`,
|
|
53
|
+
defaultMessage: 'Email',
|
|
54
|
+
},
|
|
55
|
+
customerMobile: {
|
|
56
|
+
id: `${scope}.customerMobileNumber`,
|
|
57
|
+
defaultMessage: 'Mobile Number',
|
|
58
|
+
},
|
|
59
|
+
saveButton: {
|
|
60
|
+
id: `${scope}.saveButton`,
|
|
61
|
+
defaultMessage: 'Save',
|
|
62
|
+
},
|
|
63
|
+
cancelButton: {
|
|
64
|
+
id: `${scope}.cancelButton`,
|
|
65
|
+
defaultMessage: 'Cancel',
|
|
66
|
+
},
|
|
67
|
+
customerID: {
|
|
68
|
+
id: `${scope}.customerID`,
|
|
69
|
+
defaultMessage: 'Customer ID',
|
|
70
|
+
},
|
|
71
|
+
existingCustomerModalDescription: {
|
|
72
|
+
id: `${scope}.existingCustomerModalDescription`,
|
|
73
|
+
defaultMessage: 'This user profile already exists in the system. Would you like to add them to Test Customer list?'
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
customerCreationModalTitle: {
|
|
77
|
+
id: `${scope}.customerCreationModalTitle`,
|
|
78
|
+
defaultMessage: 'Add new test customer',
|
|
79
|
+
},
|
|
80
|
+
customerCreationModalDescription: {
|
|
81
|
+
id: `${scope}.customerCreationModalDescription`,
|
|
82
|
+
defaultMessage: 'This customer profile will be available for testing across multiple communication channels.',
|
|
83
|
+
},
|
|
11
84
|
testAndPreviewHeader: {
|
|
12
85
|
id: `${scope}.testAndPreviewHeader`,
|
|
13
86
|
defaultMessage: 'Preview and Test',
|
|
14
87
|
},
|
|
88
|
+
|
|
15
89
|
customerSearchTitle: {
|
|
16
90
|
id: `${scope}.customerSearchTitle`,
|
|
17
91
|
defaultMessage: 'Customer',
|
|
@@ -46,6 +120,34 @@ export default defineMessages({
|
|
|
46
120
|
id: `${scope}.showJSON`,
|
|
47
121
|
defaultMessage: 'Show JSON',
|
|
48
122
|
},
|
|
123
|
+
addTestCustomer: {
|
|
124
|
+
id: `${scope}.addTestCustomer`,
|
|
125
|
+
defaultMessage: 'Add as Test Customer',
|
|
126
|
+
},
|
|
127
|
+
addTestCustomerWithValue: {
|
|
128
|
+
id: `${scope}.addTestCustomerWithValue`,
|
|
129
|
+
defaultMessage: 'Add {searchValue} as Test Customer',
|
|
130
|
+
},
|
|
131
|
+
memberLookupError: {
|
|
132
|
+
id: `${scope}.memberLookupError`,
|
|
133
|
+
defaultMessage: 'Unable to look up customer. Please try again.',
|
|
134
|
+
},
|
|
135
|
+
newTestCustomerAddedSuccess: {
|
|
136
|
+
id: `${scope}.newTestCustomerAddedSuccess`,
|
|
137
|
+
defaultMessage: 'New test customer added successfully!',
|
|
138
|
+
},
|
|
139
|
+
errorTitle: {
|
|
140
|
+
id: `${scope}.errorTitle`,
|
|
141
|
+
defaultMessage: 'Error',
|
|
142
|
+
},
|
|
143
|
+
failedToAddTestCustomer: {
|
|
144
|
+
id: `${scope}.failedToAddTestCustomer`,
|
|
145
|
+
defaultMessage: 'Failed to add test customer',
|
|
146
|
+
},
|
|
147
|
+
errorAddingTestCustomer: {
|
|
148
|
+
id: `${scope}.errorAddingTestCustomer`,
|
|
149
|
+
defaultMessage: 'An error occurred while adding test customer',
|
|
150
|
+
},
|
|
49
151
|
discardCustomValues: {
|
|
50
152
|
id: `${scope}.discardCustomValues`,
|
|
51
153
|
defaultMessage: 'Discard custom values',
|
|
@@ -150,6 +252,10 @@ export default defineMessages({
|
|
|
150
252
|
id: `${scope}.testCustomersPlaceholder`,
|
|
151
253
|
defaultMessage: 'Search and select a group or individual test customers',
|
|
152
254
|
},
|
|
255
|
+
noMatchingOptions: {
|
|
256
|
+
id: `${scope}.noMatchingOptions`,
|
|
257
|
+
defaultMessage: 'No matching options',
|
|
258
|
+
},
|
|
153
259
|
updatingPreview: {
|
|
154
260
|
id: `${scope}.updatingPreview`,
|
|
155
261
|
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
|
+
});
|