@capillarytech/creatives-library 8.0.290 → 8.0.291
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/package.json +1 -1
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -33
- package/v2Components/CommonTestAndPreview/actions.js +0 -20
- package/v2Components/CommonTestAndPreview/constants.js +0 -10
- package/v2Components/CommonTestAndPreview/index.js +15 -133
- package/v2Components/CommonTestAndPreview/reducer.js +0 -47
- package/v2Components/CommonTestAndPreview/sagas.js +0 -60
- package/v2Components/CommonTestAndPreview/selectors.js +0 -51
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -127
- package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
- package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -214
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
- package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
- package/v2Containers/CreativesContainer/index.js +8 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -649
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -141
- package/v2Containers/Whatsapp/index.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26174
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -397
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
- package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +0 -725
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -243
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -91
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -782
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -200
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -235
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Tests for SendTestMessage Component
|
|
3
3
|
*
|
|
4
4
|
* Tests the component that handles sending test messages
|
|
5
|
-
* @jest-environment jsdom
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
import React from 'react';
|
|
@@ -12,32 +11,8 @@ import {
|
|
|
12
11
|
import { IntlProvider } from 'react-intl';
|
|
13
12
|
import PropTypes from 'prop-types';
|
|
14
13
|
import isEmpty from 'lodash/isEmpty';
|
|
15
|
-
// Mock cap-ui-library so SendTestMessage can load (Jest hoists mocks)
|
|
16
|
-
jest.mock('@capillarytech/cap-ui-library/CapRow', () => ({ children, ...rest }) => <div {...rest}>{children}</div>);
|
|
17
|
-
jest.mock('@capillarytech/cap-ui-library/CapButton', () => ({ children, ...rest }) => <button type="button" {...rest}>{children}</button>);
|
|
18
|
-
jest.mock('@capillarytech/cap-ui-library/CapHeader', () => ({ title, description }) => <div><span>{title}</span>{description}</div>);
|
|
19
|
-
jest.mock('@capillarytech/cap-ui-library/CapTreeSelect', () => ({ treeData, onChange, value, placeholder }) => (
|
|
20
|
-
<div data-testid="cap-tree-select"><input onChange={(e) => onChange && onChange(e.target.value)} placeholder={placeholder} /></div>
|
|
21
|
-
));
|
|
22
|
-
|
|
23
14
|
import SendTestMessage from '../SendTestMessage';
|
|
24
15
|
|
|
25
|
-
// Mock DeliverySettings to assert props
|
|
26
|
-
jest.mock('../DeliverySettings', () => function MockDeliverySettings(props) {
|
|
27
|
-
return (
|
|
28
|
-
<div data-testid="delivery-settings" data-props={JSON.stringify({
|
|
29
|
-
channel: props.channel,
|
|
30
|
-
hasDeliverySettings: !!props.deliverySettings,
|
|
31
|
-
senderDetailsLength: (props.senderDetailsOptions || []).length,
|
|
32
|
-
wecrmAccountsLength: (props.wecrmAccounts || []).length,
|
|
33
|
-
hasOnSave: typeof props.onSaveDeliverySettings === 'function',
|
|
34
|
-
isLoadingSenderDetails: props.isLoadingSenderDetails,
|
|
35
|
-
whatsappAccountFromForm: props.whatsappAccountFromForm,
|
|
36
|
-
})}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
16
|
// Mock CapStepsAccordian to always render content expanded
|
|
42
17
|
jest.mock('@capillarytech/cap-ui-library/CapStepsAccordian', () => {
|
|
43
18
|
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
@@ -125,12 +100,6 @@ describe('SendTestMessage', () => {
|
|
|
125
100
|
},
|
|
126
101
|
isSendingTestMessage: false,
|
|
127
102
|
formatMessage: jest.fn((msg) => msg.defaultMessage || msg.id),
|
|
128
|
-
channel: 'EMAIL',
|
|
129
|
-
deliverySettings: {},
|
|
130
|
-
senderDetailsOptions: [],
|
|
131
|
-
wecrmAccounts: [],
|
|
132
|
-
onSaveDeliverySettings: jest.fn(),
|
|
133
|
-
isLoadingSenderDetails: false,
|
|
134
103
|
};
|
|
135
104
|
|
|
136
105
|
beforeEach(() => {
|
|
@@ -193,102 +162,6 @@ describe('SendTestMessage', () => {
|
|
|
193
162
|
});
|
|
194
163
|
});
|
|
195
164
|
|
|
196
|
-
describe('DeliverySettings (sender ID / delivery settings)', () => {
|
|
197
|
-
it('should render DeliverySettings when channel is SMS', () => {
|
|
198
|
-
render(
|
|
199
|
-
<TestWrapper>
|
|
200
|
-
<SendTestMessage {...defaultProps} channel="SMS" />
|
|
201
|
-
</TestWrapper>
|
|
202
|
-
);
|
|
203
|
-
const el = screen.getByTestId('delivery-settings');
|
|
204
|
-
expect(el).toBeTruthy();
|
|
205
|
-
const data = JSON.parse(el.getAttribute('data-props'));
|
|
206
|
-
expect(data.channel).toBe('SMS');
|
|
207
|
-
expect(data.hasOnSave).toBe(true);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should render DeliverySettings when channel is EMAIL', () => {
|
|
211
|
-
render(
|
|
212
|
-
<TestWrapper>
|
|
213
|
-
<SendTestMessage {...defaultProps} channel="EMAIL" />
|
|
214
|
-
</TestWrapper>
|
|
215
|
-
);
|
|
216
|
-
expect(screen.getByTestId('delivery-settings')).toBeTruthy();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should render DeliverySettings when channel is WHATSAPP', () => {
|
|
220
|
-
render(
|
|
221
|
-
<TestWrapper>
|
|
222
|
-
<SendTestMessage {...defaultProps} channel="WHATSAPP" />
|
|
223
|
-
</TestWrapper>
|
|
224
|
-
);
|
|
225
|
-
expect(screen.getByTestId('delivery-settings')).toBeTruthy();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should not render DeliverySettings when channel is INAPP', () => {
|
|
229
|
-
render(
|
|
230
|
-
<TestWrapper>
|
|
231
|
-
<SendTestMessage {...defaultProps} channel="INAPP" />
|
|
232
|
-
</TestWrapper>
|
|
233
|
-
);
|
|
234
|
-
expect(screen.queryByTestId('delivery-settings')).toBeNull();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('should pass whatsappAccountFromForm when channel is WHATSAPP and formData has accountName', () => {
|
|
238
|
-
render(
|
|
239
|
-
<TestWrapper>
|
|
240
|
-
<SendTestMessage
|
|
241
|
-
{...defaultProps}
|
|
242
|
-
channel="WHATSAPP"
|
|
243
|
-
formData={{ ...defaultProps.formData, accountName: 'My WABA' }}
|
|
244
|
-
/>
|
|
245
|
-
</TestWrapper>
|
|
246
|
-
);
|
|
247
|
-
const el = screen.getByTestId('delivery-settings');
|
|
248
|
-
const data = JSON.parse(el.getAttribute('data-props'));
|
|
249
|
-
expect(data.whatsappAccountFromForm).toEqual({ accountName: 'My WABA' });
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should pass whatsappAccountFromForm undefined when channel is WHATSAPP and formData has no accountName', () => {
|
|
253
|
-
render(
|
|
254
|
-
<TestWrapper>
|
|
255
|
-
<SendTestMessage
|
|
256
|
-
{...defaultProps}
|
|
257
|
-
channel="WHATSAPP"
|
|
258
|
-
formData={{ ...defaultProps.formData, accountName: undefined }}
|
|
259
|
-
/>
|
|
260
|
-
</TestWrapper>
|
|
261
|
-
);
|
|
262
|
-
const el = screen.getByTestId('delivery-settings');
|
|
263
|
-
const data = JSON.parse(el.getAttribute('data-props'));
|
|
264
|
-
expect(data.whatsappAccountFromForm).toBeUndefined();
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('should pass delivery props to DeliverySettings', () => {
|
|
268
|
-
const onSave = jest.fn();
|
|
269
|
-
render(
|
|
270
|
-
<TestWrapper>
|
|
271
|
-
<SendTestMessage
|
|
272
|
-
{...defaultProps}
|
|
273
|
-
channel="SMS"
|
|
274
|
-
deliverySettings={{ domainId: 1 }}
|
|
275
|
-
senderDetailsOptions={[{ domainId: 1, domainName: 'SMS Dom' }]}
|
|
276
|
-
wecrmAccounts={[]}
|
|
277
|
-
onSaveDeliverySettings={onSave}
|
|
278
|
-
isLoadingSenderDetails={true}
|
|
279
|
-
/>
|
|
280
|
-
</TestWrapper>
|
|
281
|
-
);
|
|
282
|
-
const el = screen.getByTestId('delivery-settings');
|
|
283
|
-
const data = JSON.parse(el.getAttribute('data-props'));
|
|
284
|
-
expect(data.hasDeliverySettings).toBe(true);
|
|
285
|
-
expect(data.senderDetailsLength).toBe(1);
|
|
286
|
-
expect(data.wecrmAccountsLength).toBe(0);
|
|
287
|
-
expect(data.hasOnSave).toBe(true);
|
|
288
|
-
expect(data.isLoadingSenderDetails).toBe(true);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
165
|
describe('Loading States', () => {
|
|
293
166
|
it('should show loading when fetching test customers', () => {
|
|
294
167
|
const props = {
|
|
@@ -17,8 +17,6 @@ import {
|
|
|
17
17
|
getPrefilledValuesRequested,
|
|
18
18
|
clearPrefilledValues,
|
|
19
19
|
clearPreviewErrors,
|
|
20
|
-
getSenderDetailsRequested,
|
|
21
|
-
getWeCrmAccountsRequested,
|
|
22
20
|
} from '../actions';
|
|
23
21
|
|
|
24
22
|
import {
|
|
@@ -34,8 +32,6 @@ import {
|
|
|
34
32
|
GET_PREFILLED_VALUES_REQUESTED,
|
|
35
33
|
CLEAR_PREFILLED_VALUES,
|
|
36
34
|
CLEAR_PREVIEW_ERRORS,
|
|
37
|
-
GET_SENDER_DETAILS_REQUESTED,
|
|
38
|
-
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
39
35
|
} from '../constants';
|
|
40
36
|
|
|
41
37
|
describe('CommonTestAndPreview Actions', () => {
|
|
@@ -325,50 +321,4 @@ describe('CommonTestAndPreview Actions', () => {
|
|
|
325
321
|
expect(clearPreviewErrors()).toEqual(expectedAction);
|
|
326
322
|
});
|
|
327
323
|
});
|
|
328
|
-
|
|
329
|
-
describe('getSenderDetailsRequested', () => {
|
|
330
|
-
it('should create an action to request sender details with channel and orgUnitId', () => {
|
|
331
|
-
const payload = { channel: 'SMS', orgUnitId: 123 };
|
|
332
|
-
const expectedAction = {
|
|
333
|
-
type: GET_SENDER_DETAILS_REQUESTED,
|
|
334
|
-
payload,
|
|
335
|
-
};
|
|
336
|
-
expect(getSenderDetailsRequested(payload)).toEqual(expectedAction);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('should handle EMAIL channel', () => {
|
|
340
|
-
const payload = { channel: 'EMAIL', orgUnitId: -1 };
|
|
341
|
-
expect(getSenderDetailsRequested(payload)).toEqual({
|
|
342
|
-
type: GET_SENDER_DETAILS_REQUESTED,
|
|
343
|
-
payload,
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('should handle WHATSAPP channel', () => {
|
|
348
|
-
const payload = { channel: 'WHATSAPP', orgUnitId: 456 };
|
|
349
|
-
expect(getSenderDetailsRequested(payload)).toEqual({
|
|
350
|
-
type: GET_SENDER_DETAILS_REQUESTED,
|
|
351
|
-
payload,
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
describe('getWeCrmAccountsRequested', () => {
|
|
357
|
-
it('should create an action to request WeCRM accounts with sourceName', () => {
|
|
358
|
-
const payload = { sourceName: 'WHATSAPP' };
|
|
359
|
-
const expectedAction = {
|
|
360
|
-
type: GET_WECRM_ACCOUNTS_REQUESTED,
|
|
361
|
-
payload,
|
|
362
|
-
};
|
|
363
|
-
expect(getWeCrmAccountsRequested(payload)).toEqual(expectedAction);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('should handle empty payload', () => {
|
|
367
|
-
const payload = {};
|
|
368
|
-
expect(getWeCrmAccountsRequested(payload)).toEqual({
|
|
369
|
-
type: GET_WECRM_ACCOUNTS_REQUESTED,
|
|
370
|
-
payload: {},
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
324
|
});
|
|
@@ -30,12 +30,6 @@ import {
|
|
|
30
30
|
GET_PREFILLED_VALUES_REQUESTED,
|
|
31
31
|
GET_PREFILLED_VALUES_SUCCESS,
|
|
32
32
|
GET_PREFILLED_VALUES_FAILURE,
|
|
33
|
-
GET_SENDER_DETAILS_REQUESTED,
|
|
34
|
-
GET_SENDER_DETAILS_SUCCESS,
|
|
35
|
-
GET_SENDER_DETAILS_FAILURE,
|
|
36
|
-
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
37
|
-
GET_WECRM_ACCOUNTS_SUCCESS,
|
|
38
|
-
GET_WECRM_ACCOUNTS_FAILURE,
|
|
39
33
|
CLEAR_CUSTOMER_SEARCH_STATE,
|
|
40
34
|
CLEAR_SEARCH_RESULTS,
|
|
41
35
|
CLEAR_PREFILLED_VALUES,
|
|
@@ -143,18 +137,6 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
143
137
|
expect(GET_PREFILLED_VALUES_FAILURE).toBe('app/CommonTestAndPreview/GET_PREFILLED_VALUES_FAILURE');
|
|
144
138
|
});
|
|
145
139
|
|
|
146
|
-
it('should export all get sender details action types', () => {
|
|
147
|
-
expect(GET_SENDER_DETAILS_REQUESTED).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_REQUESTED');
|
|
148
|
-
expect(GET_SENDER_DETAILS_SUCCESS).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_SUCCESS');
|
|
149
|
-
expect(GET_SENDER_DETAILS_FAILURE).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_FAILURE');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should export all get wecrm accounts action types', () => {
|
|
153
|
-
expect(GET_WECRM_ACCOUNTS_REQUESTED).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_REQUESTED');
|
|
154
|
-
expect(GET_WECRM_ACCOUNTS_SUCCESS).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_SUCCESS');
|
|
155
|
-
expect(GET_WECRM_ACCOUNTS_FAILURE).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_FAILURE');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
140
|
it('should export all clear action types', () => {
|
|
159
141
|
expect(CLEAR_CUSTOMER_SEARCH_STATE).toBe('app/CommonTestAndPreview/CLEAR_CUSTOMER_SEARCH_STATE');
|
|
160
142
|
expect(CLEAR_SEARCH_RESULTS).toBe('app/CommonTestAndPreview/CLEAR_SEARCH_RESULTS');
|
|
@@ -52,14 +52,12 @@ jest.mock('../CustomValuesEditor', () => {
|
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
let lastSendTestMessageProps = null;
|
|
56
55
|
jest.mock('../SendTestMessage', () => {
|
|
57
56
|
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
58
57
|
const ReactLib = require('react');
|
|
59
58
|
return {
|
|
60
59
|
__esModule: true,
|
|
61
|
-
default: function MockSendTestMessage(
|
|
62
|
-
lastSendTestMessageProps = props;
|
|
60
|
+
default: function MockSendTestMessage() {
|
|
63
61
|
return ReactLib.createElement('div', { 'data-testid': 'send-test-message' }, 'Send Test Message');
|
|
64
62
|
},
|
|
65
63
|
};
|
|
@@ -124,8 +122,6 @@ describe('CommonTestAndPreview', () => {
|
|
|
124
122
|
getPrefilledValuesRequested: jest.fn(),
|
|
125
123
|
clearPrefilledValues: jest.fn(),
|
|
126
124
|
clearPreviewErrors: jest.fn(),
|
|
127
|
-
getSenderDetailsRequested: jest.fn(),
|
|
128
|
-
getWeCrmAccountsRequested: jest.fn(),
|
|
129
125
|
};
|
|
130
126
|
|
|
131
127
|
const defaultProps = {
|
|
@@ -175,15 +171,10 @@ describe('CommonTestAndPreview', () => {
|
|
|
175
171
|
fetchPrefilledValuesErrors: [],
|
|
176
172
|
isSendingTestMessage: false,
|
|
177
173
|
currentTab: 1,
|
|
178
|
-
senderDetailsByChannel: {},
|
|
179
|
-
wecrmAccounts: [],
|
|
180
|
-
isLoadingSenderDetails: false,
|
|
181
|
-
orgUnitId: -1,
|
|
182
174
|
};
|
|
183
175
|
|
|
184
176
|
beforeEach(() => {
|
|
185
177
|
jest.clearAllMocks();
|
|
186
|
-
lastSendTestMessageProps = null;
|
|
187
178
|
// Reset all mock function implementations
|
|
188
179
|
Object.values(mockActions).forEach((mockFn) => {
|
|
189
180
|
if (jest.isMockFunction(mockFn)) {
|
|
@@ -192,210 +183,6 @@ describe('CommonTestAndPreview', () => {
|
|
|
192
183
|
});
|
|
193
184
|
});
|
|
194
185
|
|
|
195
|
-
describe('Delivery settings / sender ID', () => {
|
|
196
|
-
it('should call getSenderDetailsRequested when show and channel is SMS', async () => {
|
|
197
|
-
render(
|
|
198
|
-
<TestWrapper>
|
|
199
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.SMS} />
|
|
200
|
-
</TestWrapper>
|
|
201
|
-
);
|
|
202
|
-
await waitFor(() => {
|
|
203
|
-
expect(mockActions.getSenderDetailsRequested).toHaveBeenCalledWith({
|
|
204
|
-
channel: CHANNELS.SMS,
|
|
205
|
-
orgUnitId: -1,
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should call getSenderDetailsRequested when show and channel is EMAIL', async () => {
|
|
211
|
-
render(
|
|
212
|
-
<TestWrapper>
|
|
213
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.EMAIL} />
|
|
214
|
-
</TestWrapper>
|
|
215
|
-
);
|
|
216
|
-
await waitFor(() => {
|
|
217
|
-
expect(mockActions.getSenderDetailsRequested).toHaveBeenCalledWith({
|
|
218
|
-
channel: CHANNELS.EMAIL,
|
|
219
|
-
orgUnitId: -1,
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('should call getSenderDetailsRequested and getWeCrmAccountsRequested when show and channel is WHATSAPP', async () => {
|
|
225
|
-
render(
|
|
226
|
-
<TestWrapper>
|
|
227
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.WHATSAPP} />
|
|
228
|
-
</TestWrapper>
|
|
229
|
-
);
|
|
230
|
-
await waitFor(() => {
|
|
231
|
-
expect(mockActions.getSenderDetailsRequested).toHaveBeenCalledWith({
|
|
232
|
-
channel: CHANNELS.WHATSAPP,
|
|
233
|
-
orgUnitId: -1,
|
|
234
|
-
});
|
|
235
|
-
expect(mockActions.getWeCrmAccountsRequested).toHaveBeenCalledWith({
|
|
236
|
-
sourceName: CHANNELS.WHATSAPP,
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('should not call getSenderDetailsRequested when channel is INAPP', async () => {
|
|
242
|
-
render(
|
|
243
|
-
<TestWrapper>
|
|
244
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.INAPP} />
|
|
245
|
-
</TestWrapper>
|
|
246
|
-
);
|
|
247
|
-
await waitFor(() => {
|
|
248
|
-
expect(screen.getByTestId('left-panel')).toBeTruthy();
|
|
249
|
-
});
|
|
250
|
-
expect(mockActions.getSenderDetailsRequested).not.toHaveBeenCalled();
|
|
251
|
-
expect(mockActions.getWeCrmAccountsRequested).not.toHaveBeenCalled();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should pass orgUnitId to getSenderDetailsRequested when provided', async () => {
|
|
255
|
-
render(
|
|
256
|
-
<TestWrapper>
|
|
257
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.SMS} orgUnitId={100} />
|
|
258
|
-
</TestWrapper>
|
|
259
|
-
);
|
|
260
|
-
await waitFor(() => {
|
|
261
|
-
expect(mockActions.getSenderDetailsRequested).toHaveBeenCalledWith({
|
|
262
|
-
channel: CHANNELS.SMS,
|
|
263
|
-
orgUnitId: 100,
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should not call getSenderDetailsRequested when show is false', async () => {
|
|
269
|
-
render(
|
|
270
|
-
<TestWrapper>
|
|
271
|
-
<CommonTestAndPreview {...defaultProps} show={false} channel={CHANNELS.SMS} />
|
|
272
|
-
</TestWrapper>
|
|
273
|
-
);
|
|
274
|
-
await waitFor(() => {
|
|
275
|
-
expect(screen.queryByTestId('left-panel')).toBeNull();
|
|
276
|
-
});
|
|
277
|
-
expect(mockActions.getSenderDetailsRequested).not.toHaveBeenCalled();
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it('should pass delivery-related props to SendTestMessage for SMS channel', async () => {
|
|
281
|
-
const senderDetailsByChannel = {
|
|
282
|
-
[CHANNELS.SMS]: [{ domainId: 1, domainName: 'SMS Dom', gsmSenders: [], cdmaSenders: [] }],
|
|
283
|
-
};
|
|
284
|
-
render(
|
|
285
|
-
<TestWrapper>
|
|
286
|
-
<CommonTestAndPreview
|
|
287
|
-
{...defaultProps}
|
|
288
|
-
channel={CHANNELS.SMS}
|
|
289
|
-
senderDetailsByChannel={senderDetailsByChannel}
|
|
290
|
-
wecrmAccounts={[]}
|
|
291
|
-
/>
|
|
292
|
-
</TestWrapper>
|
|
293
|
-
);
|
|
294
|
-
await waitFor(() => {
|
|
295
|
-
expect(screen.getByTestId('send-test-message')).toBeTruthy();
|
|
296
|
-
});
|
|
297
|
-
expect(lastSendTestMessageProps).toBeDefined();
|
|
298
|
-
expect(lastSendTestMessageProps.deliverySettings).toBeDefined();
|
|
299
|
-
expect(lastSendTestMessageProps.senderDetailsOptions).toEqual(senderDetailsByChannel[CHANNELS.SMS]);
|
|
300
|
-
expect(lastSendTestMessageProps.wecrmAccounts).toEqual([]);
|
|
301
|
-
expect(typeof lastSendTestMessageProps.onSaveDeliverySettings).toBe('function');
|
|
302
|
-
expect(lastSendTestMessageProps.isLoadingSenderDetails).toBe(false);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('should pass formDataForSendTest (formData when provided) to SendTestMessage', async () => {
|
|
306
|
-
render(
|
|
307
|
-
<TestWrapper>
|
|
308
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.EMAIL} />
|
|
309
|
-
</TestWrapper>
|
|
310
|
-
);
|
|
311
|
-
await waitFor(() => {
|
|
312
|
-
expect(lastSendTestMessageProps).toBeDefined();
|
|
313
|
-
});
|
|
314
|
-
expect(lastSendTestMessageProps.formData).toEqual(defaultProps.formData);
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
it('should auto-set WhatsApp delivery settings from formData accountName when matching account exists', async () => {
|
|
318
|
-
const senderDetailsByChannel = {
|
|
319
|
-
[CHANNELS.WHATSAPP]: [
|
|
320
|
-
{
|
|
321
|
-
domainId: 1,
|
|
322
|
-
sourceAccountIdentifier: 'waba-1',
|
|
323
|
-
gsmSenders: [{ value: '+1111111111' }],
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
domainId: 2,
|
|
327
|
-
sourceAccountIdentifier: 'waba-2',
|
|
328
|
-
gsmSenders: [{ value: '+2222222222' }],
|
|
329
|
-
},
|
|
330
|
-
],
|
|
331
|
-
};
|
|
332
|
-
const wecrmAccounts = [
|
|
333
|
-
{ name: 'Account One', sourceAccountIdentifier: 'waba-1' },
|
|
334
|
-
{ name: 'Account Two', sourceAccountIdentifier: 'waba-2' },
|
|
335
|
-
];
|
|
336
|
-
|
|
337
|
-
render(
|
|
338
|
-
<TestWrapper>
|
|
339
|
-
<CommonTestAndPreview
|
|
340
|
-
{...defaultProps}
|
|
341
|
-
channel={CHANNELS.WHATSAPP}
|
|
342
|
-
formData={{ accountName: 'Account Two', templateMsg: 'WhatsApp test' }}
|
|
343
|
-
senderDetailsByChannel={senderDetailsByChannel}
|
|
344
|
-
wecrmAccounts={wecrmAccounts}
|
|
345
|
-
/>
|
|
346
|
-
</TestWrapper>
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
await waitFor(() => {
|
|
350
|
-
expect(lastSendTestMessageProps).toBeDefined();
|
|
351
|
-
expect(lastSendTestMessageProps.deliverySettings).toEqual({
|
|
352
|
-
domainId: 2,
|
|
353
|
-
senderMobNum: '+2222222222',
|
|
354
|
-
sourceAccountIdentifier: 'waba-2',
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it('should include delivery settings in payload when handleSendTestMessage is called for EMAIL', async () => {
|
|
360
|
-
render(
|
|
361
|
-
<TestWrapper>
|
|
362
|
-
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.EMAIL} />
|
|
363
|
-
</TestWrapper>
|
|
364
|
-
);
|
|
365
|
-
await waitFor(() => {
|
|
366
|
-
expect(lastSendTestMessageProps).toBeDefined();
|
|
367
|
-
expect(typeof lastSendTestMessageProps.handleSendTestMessage).toBe('function');
|
|
368
|
-
});
|
|
369
|
-
lastSendTestMessageProps.handleSendTestMessage();
|
|
370
|
-
expect(mockActions.createMessageMetaRequested).toHaveBeenCalled();
|
|
371
|
-
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
372
|
-
expect(initialPayload.emailDeliverySettings).toBeDefined();
|
|
373
|
-
expect(initialPayload.emailDeliverySettings.channelSettings).toBeDefined();
|
|
374
|
-
expect(initialPayload.emailDeliverySettings.channelSettings.channel).toBe(CHANNELS.EMAIL);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('should include delivery settings in payload when handleSendTestMessage is called for SMS', async () => {
|
|
378
|
-
render(
|
|
379
|
-
<TestWrapper>
|
|
380
|
-
<CommonTestAndPreview
|
|
381
|
-
{...defaultProps}
|
|
382
|
-
channel={CHANNELS.SMS}
|
|
383
|
-
formData={{ 'sms-editor': 'Test SMS' }}
|
|
384
|
-
/>
|
|
385
|
-
</TestWrapper>
|
|
386
|
-
);
|
|
387
|
-
await waitFor(() => {
|
|
388
|
-
expect(lastSendTestMessageProps).toBeDefined();
|
|
389
|
-
});
|
|
390
|
-
lastSendTestMessageProps.handleSendTestMessage();
|
|
391
|
-
expect(mockActions.createMessageMetaRequested).toHaveBeenCalled();
|
|
392
|
-
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
393
|
-
expect(initialPayload.smsDeliverySettings).toBeDefined();
|
|
394
|
-
expect(initialPayload.smsDeliverySettings.channelSettings).toBeDefined();
|
|
395
|
-
expect(initialPayload.smsDeliverySettings.channelSettings.channel).toBe(CHANNELS.SMS);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
|
|
399
186
|
describe('Component Rendering', () => {
|
|
400
187
|
it('should render when show is true', async () => {
|
|
401
188
|
render(
|
|
@@ -35,13 +35,6 @@ import {
|
|
|
35
35
|
GET_PREFILLED_VALUES_FAILURE,
|
|
36
36
|
CLEAR_PREFILLED_VALUES,
|
|
37
37
|
CLEAR_PREVIEW_ERRORS,
|
|
38
|
-
GET_SENDER_DETAILS_REQUESTED,
|
|
39
|
-
GET_SENDER_DETAILS_SUCCESS,
|
|
40
|
-
GET_SENDER_DETAILS_FAILURE,
|
|
41
|
-
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
42
|
-
GET_WECRM_ACCOUNTS_SUCCESS,
|
|
43
|
-
GET_WECRM_ACCOUNTS_FAILURE,
|
|
44
|
-
CHANNELS,
|
|
45
38
|
} from '../constants';
|
|
46
39
|
|
|
47
40
|
describe('previewAndTestReducer', () => {
|
|
@@ -87,15 +80,6 @@ describe('previewAndTestReducer', () => {
|
|
|
87
80
|
isFetchingPrefilledValues: false,
|
|
88
81
|
fetchPrefilledValuesError: null,
|
|
89
82
|
fetchPrefilledValuesErrors: [],
|
|
90
|
-
senderDetailsByChannel: fromJS({
|
|
91
|
-
[CHANNELS.SMS]: [],
|
|
92
|
-
[CHANNELS.EMAIL]: [],
|
|
93
|
-
[CHANNELS.WHATSAPP]: [],
|
|
94
|
-
}),
|
|
95
|
-
wecrmAccounts: fromJS([]),
|
|
96
|
-
isLoadingSenderDetails: false,
|
|
97
|
-
fetchSenderDetailsError: null,
|
|
98
|
-
fetchWeCrmAccountsError: null,
|
|
99
83
|
});
|
|
100
84
|
});
|
|
101
85
|
|
|
@@ -789,108 +773,6 @@ describe('previewAndTestReducer', () => {
|
|
|
789
773
|
});
|
|
790
774
|
});
|
|
791
775
|
|
|
792
|
-
describe('GET_SENDER_DETAILS_REQUESTED', () => {
|
|
793
|
-
it('should set isLoadingSenderDetails to true and clear fetchSenderDetailsError', () => {
|
|
794
|
-
const action = {
|
|
795
|
-
type: GET_SENDER_DETAILS_REQUESTED,
|
|
796
|
-
payload: { channel: CHANNELS.SMS, orgUnitId: 123 },
|
|
797
|
-
};
|
|
798
|
-
const result = previewAndTestReducer(initialState, action);
|
|
799
|
-
|
|
800
|
-
expect(result.get('isLoadingSenderDetails')).toBe(true);
|
|
801
|
-
expect(result.get('fetchSenderDetailsError')).toBeNull();
|
|
802
|
-
});
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
describe('GET_SENDER_DETAILS_SUCCESS', () => {
|
|
806
|
-
it('should store domains for channel and set loading to false', () => {
|
|
807
|
-
const domains = [
|
|
808
|
-
{ domainId: 1, domainName: 'Domain 1', gsmSenders: [] },
|
|
809
|
-
];
|
|
810
|
-
const action = {
|
|
811
|
-
type: GET_SENDER_DETAILS_SUCCESS,
|
|
812
|
-
payload: { channel: CHANNELS.SMS, domains },
|
|
813
|
-
};
|
|
814
|
-
const result = previewAndTestReducer(initialState, action);
|
|
815
|
-
|
|
816
|
-
expect(result.getIn(['senderDetailsByChannel', CHANNELS.SMS])).toEqual(fromJS(domains));
|
|
817
|
-
expect(result.get('isLoadingSenderDetails')).toBe(false);
|
|
818
|
-
expect(result.get('fetchSenderDetailsError')).toBeNull();
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
it('should return state unchanged when channel is missing', () => {
|
|
822
|
-
const action = {
|
|
823
|
-
type: GET_SENDER_DETAILS_SUCCESS,
|
|
824
|
-
payload: { domains: [] },
|
|
825
|
-
};
|
|
826
|
-
const result = previewAndTestReducer(initialState, action);
|
|
827
|
-
|
|
828
|
-
expect(result).toEqual(initialState);
|
|
829
|
-
});
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
describe('GET_SENDER_DETAILS_FAILURE', () => {
|
|
833
|
-
it('should set loading to false and store error', () => {
|
|
834
|
-
const action = {
|
|
835
|
-
type: GET_SENDER_DETAILS_FAILURE,
|
|
836
|
-
payload: { channel: CHANNELS.EMAIL, error: 'Failed to fetch' },
|
|
837
|
-
};
|
|
838
|
-
const result = previewAndTestReducer(initialState, action);
|
|
839
|
-
|
|
840
|
-
expect(result.get('isLoadingSenderDetails')).toBe(false);
|
|
841
|
-
expect(result.get('fetchSenderDetailsError')).toBe('Failed to fetch');
|
|
842
|
-
});
|
|
843
|
-
});
|
|
844
|
-
|
|
845
|
-
describe('GET_WECRM_ACCOUNTS_REQUESTED', () => {
|
|
846
|
-
it('should clear fetchWeCrmAccountsError', () => {
|
|
847
|
-
const stateWithError = initialState.set('fetchWeCrmAccountsError', 'Error');
|
|
848
|
-
const action = {
|
|
849
|
-
type: GET_WECRM_ACCOUNTS_REQUESTED,
|
|
850
|
-
payload: { sourceName: 'WHATSAPP' },
|
|
851
|
-
};
|
|
852
|
-
const result = previewAndTestReducer(stateWithError, action);
|
|
853
|
-
|
|
854
|
-
expect(result.get('fetchWeCrmAccountsError')).toBeNull();
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
describe('GET_WECRM_ACCOUNTS_SUCCESS', () => {
|
|
859
|
-
it('should store wecrm accounts and clear error', () => {
|
|
860
|
-
const accounts = [{ name: 'Account 1', sourceAccountIdentifier: 'acc-1' }];
|
|
861
|
-
const action = {
|
|
862
|
-
type: GET_WECRM_ACCOUNTS_SUCCESS,
|
|
863
|
-
payload: { accounts },
|
|
864
|
-
};
|
|
865
|
-
const result = previewAndTestReducer(initialState, action);
|
|
866
|
-
|
|
867
|
-
expect(result.get('wecrmAccounts')).toEqual(fromJS(accounts));
|
|
868
|
-
expect(result.get('fetchWeCrmAccountsError')).toBeNull();
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
it('should handle empty accounts', () => {
|
|
872
|
-
const action = {
|
|
873
|
-
type: GET_WECRM_ACCOUNTS_SUCCESS,
|
|
874
|
-
payload: { accounts: [] },
|
|
875
|
-
};
|
|
876
|
-
const result = previewAndTestReducer(initialState, action);
|
|
877
|
-
|
|
878
|
-
expect(result.get('wecrmAccounts')).toEqual(fromJS([]));
|
|
879
|
-
});
|
|
880
|
-
});
|
|
881
|
-
|
|
882
|
-
describe('GET_WECRM_ACCOUNTS_FAILURE', () => {
|
|
883
|
-
it('should store fetchWeCrmAccountsError', () => {
|
|
884
|
-
const action = {
|
|
885
|
-
type: GET_WECRM_ACCOUNTS_FAILURE,
|
|
886
|
-
payload: { error: 'WeCRM fetch failed' },
|
|
887
|
-
};
|
|
888
|
-
const result = previewAndTestReducer(initialState, action);
|
|
889
|
-
|
|
890
|
-
expect(result.get('fetchWeCrmAccountsError')).toBe('WeCRM fetch failed');
|
|
891
|
-
});
|
|
892
|
-
});
|
|
893
|
-
|
|
894
776
|
describe('CLEAR_PREVIEW_ERRORS', () => {
|
|
895
777
|
it('should clear all preview-related errors', () => {
|
|
896
778
|
const stateWithErrors = initialState
|