@capillarytech/creatives-library 8.0.291 → 8.0.292
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/DeliverySettings/DeliverySettings.scss +33 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +422 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +35 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +725 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +92 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +251 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +111 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +91 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +51 -1
- package/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/v2Components/CommonTestAndPreview/constants.js +10 -0
- package/v2Components/CommonTestAndPreview/index.js +148 -15
- package/v2Components/CommonTestAndPreview/reducer.js +47 -0
- package/v2Components/CommonTestAndPreview/sagas.js +60 -0
- package/v2Components/CommonTestAndPreview/selectors.js +51 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +889 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +222 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +235 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +135 -0
- package/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -0
- package/v2Components/CommonTestAndPreview/tests/index.test.js +342 -1
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +145 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +14 -0
- package/v2Containers/CreativesContainer/index.js +0 -8
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +697 -12
- package/v2Containers/SmsTrai/Edit/index.js +5 -1
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +201 -0
- package/v2Containers/Whatsapp/index.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26242 -4225
|
@@ -30,6 +30,12 @@ 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,
|
|
33
39
|
CLEAR_CUSTOMER_SEARCH_STATE,
|
|
34
40
|
CLEAR_SEARCH_RESULTS,
|
|
35
41
|
CLEAR_PREFILLED_VALUES,
|
|
@@ -137,6 +143,18 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
137
143
|
expect(GET_PREFILLED_VALUES_FAILURE).toBe('app/CommonTestAndPreview/GET_PREFILLED_VALUES_FAILURE');
|
|
138
144
|
});
|
|
139
145
|
|
|
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
|
+
|
|
140
158
|
it('should export all clear action types', () => {
|
|
141
159
|
expect(CLEAR_CUSTOMER_SEARCH_STATE).toBe('app/CommonTestAndPreview/CLEAR_CUSTOMER_SEARCH_STATE');
|
|
142
160
|
expect(CLEAR_SEARCH_RESULTS).toBe('app/CommonTestAndPreview/CLEAR_SEARCH_RESULTS');
|
|
@@ -52,12 +52,14 @@ jest.mock('../CustomValuesEditor', () => {
|
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
let lastSendTestMessageProps = null;
|
|
55
56
|
jest.mock('../SendTestMessage', () => {
|
|
56
57
|
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
57
58
|
const ReactLib = require('react');
|
|
58
59
|
return {
|
|
59
60
|
__esModule: true,
|
|
60
|
-
default: function MockSendTestMessage() {
|
|
61
|
+
default: function MockSendTestMessage(props) {
|
|
62
|
+
lastSendTestMessageProps = props;
|
|
61
63
|
return ReactLib.createElement('div', { 'data-testid': 'send-test-message' }, 'Send Test Message');
|
|
62
64
|
},
|
|
63
65
|
};
|
|
@@ -122,6 +124,8 @@ describe('CommonTestAndPreview', () => {
|
|
|
122
124
|
getPrefilledValuesRequested: jest.fn(),
|
|
123
125
|
clearPrefilledValues: jest.fn(),
|
|
124
126
|
clearPreviewErrors: jest.fn(),
|
|
127
|
+
getSenderDetailsRequested: jest.fn(),
|
|
128
|
+
getWeCrmAccountsRequested: jest.fn(),
|
|
125
129
|
};
|
|
126
130
|
|
|
127
131
|
const defaultProps = {
|
|
@@ -171,10 +175,15 @@ describe('CommonTestAndPreview', () => {
|
|
|
171
175
|
fetchPrefilledValuesErrors: [],
|
|
172
176
|
isSendingTestMessage: false,
|
|
173
177
|
currentTab: 1,
|
|
178
|
+
senderDetailsByChannel: {},
|
|
179
|
+
wecrmAccounts: [],
|
|
180
|
+
isLoadingSenderDetails: false,
|
|
181
|
+
orgUnitId: -1,
|
|
174
182
|
};
|
|
175
183
|
|
|
176
184
|
beforeEach(() => {
|
|
177
185
|
jest.clearAllMocks();
|
|
186
|
+
lastSendTestMessageProps = null;
|
|
178
187
|
// Reset all mock function implementations
|
|
179
188
|
Object.values(mockActions).forEach((mockFn) => {
|
|
180
189
|
if (jest.isMockFunction(mockFn)) {
|
|
@@ -183,6 +192,338 @@ describe('CommonTestAndPreview', () => {
|
|
|
183
192
|
});
|
|
184
193
|
});
|
|
185
194
|
|
|
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 SMS delivery settings from TRAI registered sender IDs when DLT is enabled', async () => {
|
|
318
|
+
const senderDetailsByChannel = {
|
|
319
|
+
[CHANNELS.SMS]: [
|
|
320
|
+
{
|
|
321
|
+
domainId: 1,
|
|
322
|
+
dgmId: 11,
|
|
323
|
+
gsmSenders: [{ value: 'SENDER_A' }],
|
|
324
|
+
cdmaSenders: [{ value: 'CDMA_A' }],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
domainId: 2,
|
|
328
|
+
dgmId: 22,
|
|
329
|
+
gsmSenders: [{ value: 'SENDER_B' }, { value: 'SENDER_C' }],
|
|
330
|
+
cdmaSenders: [{ value: 'CDMA_B' }],
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
render(
|
|
336
|
+
<TestWrapper>
|
|
337
|
+
<CommonTestAndPreview
|
|
338
|
+
{...defaultProps}
|
|
339
|
+
channel={CHANNELS.SMS}
|
|
340
|
+
formData={{
|
|
341
|
+
templateConfigs: {
|
|
342
|
+
traiDltEnabled: true,
|
|
343
|
+
registeredSenderIds: ['SENDER_B'],
|
|
344
|
+
},
|
|
345
|
+
}}
|
|
346
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
347
|
+
/>
|
|
348
|
+
</TestWrapper>
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
await waitFor(() => {
|
|
352
|
+
expect(lastSendTestMessageProps.deliverySettings).toEqual({
|
|
353
|
+
domainId: 2,
|
|
354
|
+
domainGatewayMapId: 22,
|
|
355
|
+
gsmSenderId: 'SENDER_B',
|
|
356
|
+
cdmaSenderId: 'CDMA_B',
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('should preserve existing SMS auto-set logic when TRAI DLT is not enabled', async () => {
|
|
362
|
+
const senderDetailsByChannel = {
|
|
363
|
+
[CHANNELS.SMS]: [
|
|
364
|
+
{
|
|
365
|
+
domainId: 1,
|
|
366
|
+
dgmId: 11,
|
|
367
|
+
gsmSenders: [{ value: 'SENDER_A' }, { value: 'SENDER_A_DEFAULT', default: true }],
|
|
368
|
+
cdmaSenders: [{ value: 'CDMA_A', default: true }],
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
domainId: 2,
|
|
372
|
+
dgmId: 22,
|
|
373
|
+
gsmSenders: [{ value: 'SENDER_B' }],
|
|
374
|
+
cdmaSenders: [{ value: 'CDMA_B' }],
|
|
375
|
+
},
|
|
376
|
+
],
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
render(
|
|
380
|
+
<TestWrapper>
|
|
381
|
+
<CommonTestAndPreview
|
|
382
|
+
{...defaultProps}
|
|
383
|
+
channel={CHANNELS.SMS}
|
|
384
|
+
formData={{
|
|
385
|
+
templateConfigs: {
|
|
386
|
+
traiDltEnabled: false,
|
|
387
|
+
registeredSenderIds: ['SENDER_B'],
|
|
388
|
+
},
|
|
389
|
+
}}
|
|
390
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
391
|
+
/>
|
|
392
|
+
</TestWrapper>
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
await waitFor(() => {
|
|
396
|
+
expect(lastSendTestMessageProps.deliverySettings).toEqual({
|
|
397
|
+
domainId: 1,
|
|
398
|
+
domainGatewayMapId: 11,
|
|
399
|
+
gsmSenderId: 'SENDER_A_DEFAULT',
|
|
400
|
+
cdmaSenderId: 'CDMA_A',
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('should keep SMS delivery settings empty when DLT is enabled and no registered sender ID matches', async () => {
|
|
406
|
+
const senderDetailsByChannel = {
|
|
407
|
+
[CHANNELS.SMS]: [
|
|
408
|
+
{
|
|
409
|
+
domainId: 1,
|
|
410
|
+
dgmId: 11,
|
|
411
|
+
gsmSenders: [{ value: 'SENDER_A' }],
|
|
412
|
+
cdmaSenders: [{ value: 'CDMA_A' }],
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
render(
|
|
418
|
+
<TestWrapper>
|
|
419
|
+
<CommonTestAndPreview
|
|
420
|
+
{...defaultProps}
|
|
421
|
+
channel={CHANNELS.SMS}
|
|
422
|
+
formData={{
|
|
423
|
+
templateConfigs: {
|
|
424
|
+
traiDltEnabled: true,
|
|
425
|
+
registeredSenderIds: ['SENDER_X'],
|
|
426
|
+
},
|
|
427
|
+
}}
|
|
428
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
429
|
+
/>
|
|
430
|
+
</TestWrapper>
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
await waitFor(() => {
|
|
434
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
expect(lastSendTestMessageProps.deliverySettings).toEqual({
|
|
438
|
+
domainId: null,
|
|
439
|
+
domainGatewayMapId: null,
|
|
440
|
+
gsmSenderId: '',
|
|
441
|
+
cdmaSenderId: '',
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it('should auto-set WhatsApp delivery settings from formData accountName when matching account exists', async () => {
|
|
446
|
+
const senderDetailsByChannel = {
|
|
447
|
+
[CHANNELS.WHATSAPP]: [
|
|
448
|
+
{
|
|
449
|
+
domainId: 1,
|
|
450
|
+
sourceAccountIdentifier: 'waba-1',
|
|
451
|
+
gsmSenders: [{ value: '+1111111111' }],
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
domainId: 2,
|
|
455
|
+
sourceAccountIdentifier: 'waba-2',
|
|
456
|
+
gsmSenders: [{ value: '+2222222222' }],
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
};
|
|
460
|
+
const wecrmAccounts = [
|
|
461
|
+
{ name: 'Account One', sourceAccountIdentifier: 'waba-1' },
|
|
462
|
+
{ name: 'Account Two', sourceAccountIdentifier: 'waba-2' },
|
|
463
|
+
];
|
|
464
|
+
|
|
465
|
+
render(
|
|
466
|
+
<TestWrapper>
|
|
467
|
+
<CommonTestAndPreview
|
|
468
|
+
{...defaultProps}
|
|
469
|
+
channel={CHANNELS.WHATSAPP}
|
|
470
|
+
formData={{ accountName: 'Account Two', templateMsg: 'WhatsApp test' }}
|
|
471
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
472
|
+
wecrmAccounts={wecrmAccounts}
|
|
473
|
+
/>
|
|
474
|
+
</TestWrapper>
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
await waitFor(() => {
|
|
478
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
479
|
+
expect(lastSendTestMessageProps.deliverySettings).toEqual({
|
|
480
|
+
domainId: 2,
|
|
481
|
+
senderMobNum: '+2222222222',
|
|
482
|
+
sourceAccountIdentifier: 'waba-2',
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it('should include delivery settings in payload when handleSendTestMessage is called for EMAIL', async () => {
|
|
488
|
+
render(
|
|
489
|
+
<TestWrapper>
|
|
490
|
+
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.EMAIL} />
|
|
491
|
+
</TestWrapper>
|
|
492
|
+
);
|
|
493
|
+
await waitFor(() => {
|
|
494
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
495
|
+
expect(typeof lastSendTestMessageProps.handleSendTestMessage).toBe('function');
|
|
496
|
+
});
|
|
497
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
498
|
+
expect(mockActions.createMessageMetaRequested).toHaveBeenCalled();
|
|
499
|
+
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
500
|
+
expect(initialPayload.emailDeliverySettings).toBeDefined();
|
|
501
|
+
expect(initialPayload.emailDeliverySettings.channelSettings).toBeDefined();
|
|
502
|
+
expect(initialPayload.emailDeliverySettings.channelSettings.channel).toBe(CHANNELS.EMAIL);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
it('should include delivery settings in payload when handleSendTestMessage is called for SMS', async () => {
|
|
506
|
+
render(
|
|
507
|
+
<TestWrapper>
|
|
508
|
+
<CommonTestAndPreview
|
|
509
|
+
{...defaultProps}
|
|
510
|
+
channel={CHANNELS.SMS}
|
|
511
|
+
formData={{ 'sms-editor': 'Test SMS' }}
|
|
512
|
+
/>
|
|
513
|
+
</TestWrapper>
|
|
514
|
+
);
|
|
515
|
+
await waitFor(() => {
|
|
516
|
+
expect(lastSendTestMessageProps).toBeDefined();
|
|
517
|
+
});
|
|
518
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
519
|
+
expect(mockActions.createMessageMetaRequested).toHaveBeenCalled();
|
|
520
|
+
const [initialPayload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
521
|
+
expect(initialPayload.smsDeliverySettings).toBeDefined();
|
|
522
|
+
expect(initialPayload.smsDeliverySettings.channelSettings).toBeDefined();
|
|
523
|
+
expect(initialPayload.smsDeliverySettings.channelSettings.channel).toBe(CHANNELS.SMS);
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
|
|
186
527
|
describe('Component Rendering', () => {
|
|
187
528
|
it('should render when show is true', async () => {
|
|
188
529
|
render(
|
|
@@ -35,6 +35,13 @@ 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,
|
|
38
45
|
} from '../constants';
|
|
39
46
|
|
|
40
47
|
describe('previewAndTestReducer', () => {
|
|
@@ -80,6 +87,15 @@ describe('previewAndTestReducer', () => {
|
|
|
80
87
|
isFetchingPrefilledValues: false,
|
|
81
88
|
fetchPrefilledValuesError: null,
|
|
82
89
|
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,
|
|
83
99
|
});
|
|
84
100
|
});
|
|
85
101
|
|
|
@@ -773,6 +789,108 @@ describe('previewAndTestReducer', () => {
|
|
|
773
789
|
});
|
|
774
790
|
});
|
|
775
791
|
|
|
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
|
+
|
|
776
894
|
describe('CLEAR_PREVIEW_ERRORS', () => {
|
|
777
895
|
it('should clear all preview-related errors', () => {
|
|
778
896
|
const stateWithErrors = initialState
|