@capillarytech/creatives-library 8.0.294 → 8.0.295

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 (39) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -51
  3. package/v2Components/CommonTestAndPreview/actions.js +0 -20
  4. package/v2Components/CommonTestAndPreview/constants.js +0 -10
  5. package/v2Components/CommonTestAndPreview/index.js +15 -150
  6. package/v2Components/CommonTestAndPreview/reducer.js +0 -47
  7. package/v2Components/CommonTestAndPreview/sagas.js +0 -61
  8. package/v2Components/CommonTestAndPreview/selectors.js +0 -51
  9. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -135
  10. package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
  11. package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
  12. package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -342
  13. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
  14. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
  15. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
  16. package/v2Components/FormBuilder/index.js +1 -1
  17. package/v2Components/HtmlEditor/HTMLEditor.js +1 -0
  18. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1 -0
  19. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +132 -3
  20. package/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
  21. package/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
  22. package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
  23. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +2 -2
  24. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +110 -18
  25. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -697
  26. package/v2Containers/SmsTrai/Edit/index.js +1 -5
  27. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -201
  28. package/v2Containers/Whatsapp/index.js +1 -1
  29. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26242
  30. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
  31. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -425
  32. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
  33. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
  34. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -251
  35. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
  36. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -88
  37. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -889
  38. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -222
  39. 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,34 +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
- smsTraiDltEnabled: props.smsTraiDltEnabled,
36
- registeredSenderIds: props.registeredSenderIds,
37
- whatsappAccountFromForm: props.whatsappAccountFromForm,
38
- })}
39
- />
40
- );
41
- });
42
-
43
16
  // Mock CapStepsAccordian to always render content expanded
44
17
  jest.mock('@capillarytech/cap-ui-library/CapStepsAccordian', () => {
45
18
  // eslint-disable-next-line global-require, import/no-extraneous-dependencies
@@ -127,14 +100,6 @@ describe('SendTestMessage', () => {
127
100
  },
128
101
  isSendingTestMessage: false,
129
102
  formatMessage: jest.fn((msg) => msg.defaultMessage || msg.id),
130
- channel: 'EMAIL',
131
- deliverySettings: {},
132
- senderDetailsOptions: [],
133
- wecrmAccounts: [],
134
- onSaveDeliverySettings: jest.fn(),
135
- isLoadingSenderDetails: false,
136
- smsTraiDltEnabled: false,
137
- registeredSenderIds: [],
138
103
  };
139
104
 
140
105
  beforeEach(() => {
@@ -197,106 +162,6 @@ describe('SendTestMessage', () => {
197
162
  });
198
163
  });
199
164
 
200
- describe('DeliverySettings (sender ID / delivery settings)', () => {
201
- it('should render DeliverySettings when channel is SMS', () => {
202
- render(
203
- <TestWrapper>
204
- <SendTestMessage {...defaultProps} channel="SMS" />
205
- </TestWrapper>
206
- );
207
- const el = screen.getByTestId('delivery-settings');
208
- expect(el).toBeTruthy();
209
- const data = JSON.parse(el.getAttribute('data-props'));
210
- expect(data.channel).toBe('SMS');
211
- expect(data.hasOnSave).toBe(true);
212
- });
213
-
214
- it('should render DeliverySettings when channel is EMAIL', () => {
215
- render(
216
- <TestWrapper>
217
- <SendTestMessage {...defaultProps} channel="EMAIL" />
218
- </TestWrapper>
219
- );
220
- expect(screen.getByTestId('delivery-settings')).toBeTruthy();
221
- });
222
-
223
- it('should render DeliverySettings when channel is WHATSAPP', () => {
224
- render(
225
- <TestWrapper>
226
- <SendTestMessage {...defaultProps} channel="WHATSAPP" />
227
- </TestWrapper>
228
- );
229
- expect(screen.getByTestId('delivery-settings')).toBeTruthy();
230
- });
231
-
232
- it('should not render DeliverySettings when channel is INAPP', () => {
233
- render(
234
- <TestWrapper>
235
- <SendTestMessage {...defaultProps} channel="INAPP" />
236
- </TestWrapper>
237
- );
238
- expect(screen.queryByTestId('delivery-settings')).toBeNull();
239
- });
240
-
241
- it('should pass whatsappAccountFromForm when channel is WHATSAPP and formData has accountName', () => {
242
- render(
243
- <TestWrapper>
244
- <SendTestMessage
245
- {...defaultProps}
246
- channel="WHATSAPP"
247
- formData={{ ...defaultProps.formData, accountName: 'My WABA' }}
248
- />
249
- </TestWrapper>
250
- );
251
- const el = screen.getByTestId('delivery-settings');
252
- const data = JSON.parse(el.getAttribute('data-props'));
253
- expect(data.whatsappAccountFromForm).toEqual({ accountName: 'My WABA' });
254
- });
255
-
256
- it('should pass whatsappAccountFromForm undefined when channel is WHATSAPP and formData has no accountName', () => {
257
- render(
258
- <TestWrapper>
259
- <SendTestMessage
260
- {...defaultProps}
261
- channel="WHATSAPP"
262
- formData={{ ...defaultProps.formData, accountName: undefined }}
263
- />
264
- </TestWrapper>
265
- );
266
- const el = screen.getByTestId('delivery-settings');
267
- const data = JSON.parse(el.getAttribute('data-props'));
268
- expect(data.whatsappAccountFromForm).toBeUndefined();
269
- });
270
-
271
- it('should pass delivery props to DeliverySettings', () => {
272
- const onSave = jest.fn();
273
- render(
274
- <TestWrapper>
275
- <SendTestMessage
276
- {...defaultProps}
277
- channel="SMS"
278
- deliverySettings={{ domainId: 1 }}
279
- senderDetailsOptions={[{ domainId: 1, domainName: 'SMS Dom' }]}
280
- wecrmAccounts={[]}
281
- onSaveDeliverySettings={onSave}
282
- isLoadingSenderDetails={true}
283
- smsTraiDltEnabled
284
- registeredSenderIds={['ID1']}
285
- />
286
- </TestWrapper>
287
- );
288
- const el = screen.getByTestId('delivery-settings');
289
- const data = JSON.parse(el.getAttribute('data-props'));
290
- expect(data.hasDeliverySettings).toBe(true);
291
- expect(data.senderDetailsLength).toBe(1);
292
- expect(data.wecrmAccountsLength).toBe(0);
293
- expect(data.hasOnSave).toBe(true);
294
- expect(data.isLoadingSenderDetails).toBe(true);
295
- expect(data.smsTraiDltEnabled).toBe(true);
296
- expect(data.registeredSenderIds).toEqual(['ID1']);
297
- });
298
- });
299
-
300
165
  describe('Loading States', () => {
301
166
  it('should show loading when fetching test customers', () => {
302
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(props) {
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,338 +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 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
-
527
186
  describe('Component Rendering', () => {
528
187
  it('should render when show is true', async () => {
529
188
  render(