@capillarytech/creatives-library 9.0.54-0 → 9.0.54-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 +0 -1
- package/package.json +1 -1
- package/services/api.js +9 -0
- package/utils/common.js +0 -4
- package/v2Components/CommonTestAndPreview/index.js +0 -3
- package/v2Containers/CommunicationFlow/CommunicationFlow.js +93 -58
- package/v2Containers/CommunicationFlow/CommunicationFlowCard.js +20 -4
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +194 -49
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlowCard.test.js +16 -0
- package/v2Containers/CommunicationFlow/constants.js +47 -0
- package/v2Containers/CommunicationFlow/index.js +15 -20
- package/v2Containers/CommunicationFlow/messages.js +4 -0
- package/v2Containers/CreativesContainer/index.js +0 -2
- package/v2Containers/Rcs/constants.js +0 -1
- package/v2Containers/Rcs/index.js +1 -9
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -108
- package/v2Containers/Rcs/tests/index.test.js +0 -121
- package/v2Containers/Templates/index.js +0 -20
- package/.vscode/settings.json +0 -3
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
jest.mock('../../../services/api', () => ({
|
|
4
|
-
|
|
5
|
-
getCentralCommsMetaIds: jest.fn(),
|
|
4
|
+
createCommDefinition: jest.fn(),
|
|
6
5
|
}));
|
|
7
6
|
|
|
8
7
|
jest.mock('../../CreativesContainer', () => function MockCreativesContainer({
|
|
@@ -38,7 +37,7 @@ import { IntlProvider } from 'react-intl';
|
|
|
38
37
|
import history from '../../../utils/history';
|
|
39
38
|
import { initialReducer } from '../../../initialReducer';
|
|
40
39
|
import CommunicationFlow from '../CommunicationFlow';
|
|
41
|
-
import {
|
|
40
|
+
import { createCommDefinition } from '../../../services/api';
|
|
42
41
|
import { getEnabledSteps } from '../utils/getEnabledSteps';
|
|
43
42
|
import {
|
|
44
43
|
CHANNELS,
|
|
@@ -359,82 +358,151 @@ describe('isSaveDisabled', () => {
|
|
|
359
358
|
});
|
|
360
359
|
|
|
361
360
|
describe('handleSave — CCS flow', () => {
|
|
361
|
+
const ccsConfig = { ...baseConfig, context: { name: 'Order Placed Notification' }, features: {} };
|
|
362
|
+
|
|
362
363
|
beforeEach(() => {
|
|
363
|
-
|
|
364
|
-
|
|
364
|
+
createCommDefinition.mockResolvedValue({
|
|
365
|
+
response: { data: { id: 'cd_123', referenceId: 'ORDER_PLACED_123', status: 'DRAFT', version: { version: 1 } } },
|
|
366
|
+
});
|
|
365
367
|
});
|
|
366
368
|
|
|
367
369
|
afterEach(() => {
|
|
368
370
|
jest.clearAllMocks();
|
|
369
371
|
});
|
|
370
372
|
|
|
371
|
-
it('calls
|
|
373
|
+
it('calls createCommDefinition with a SINGLE-strategy payload when useCCS is not false', async () => {
|
|
372
374
|
const onSave = jest.fn();
|
|
373
375
|
renderWithFlow({
|
|
374
376
|
features: {},
|
|
377
|
+
config: ccsConfig,
|
|
375
378
|
initialData: {
|
|
376
|
-
contentItems: [{ channel: 'sms', templateData: {
|
|
379
|
+
contentItems: [{ channel: 'sms', templateData: { message: 'Hello' } }],
|
|
377
380
|
},
|
|
378
381
|
onSave,
|
|
379
382
|
});
|
|
380
383
|
|
|
381
384
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
382
385
|
|
|
383
|
-
await waitFor(() => expect(
|
|
384
|
-
expect(
|
|
386
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalledTimes(1));
|
|
387
|
+
expect(createCommDefinition).toHaveBeenCalledWith(
|
|
385
388
|
expect.objectContaining({
|
|
386
|
-
|
|
389
|
+
name: 'Order Placed Notification',
|
|
390
|
+
strategyType: 'SINGLE',
|
|
391
|
+
singleChannelStrategy: expect.objectContaining({
|
|
392
|
+
variant: expect.objectContaining({
|
|
393
|
+
channel: 'SMS',
|
|
394
|
+
smsMessageContent: { message: 'Hello' },
|
|
395
|
+
}),
|
|
396
|
+
}),
|
|
387
397
|
}),
|
|
388
398
|
);
|
|
389
399
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
390
400
|
});
|
|
391
401
|
|
|
392
|
-
it('
|
|
402
|
+
it('normalizes the internal MOBILEPUSH channel to CCS\'s MPUSH enum and key names', async () => {
|
|
403
|
+
const onSave = jest.fn();
|
|
393
404
|
renderWithFlow({
|
|
394
405
|
features: {},
|
|
395
|
-
|
|
406
|
+
config: ccsConfig,
|
|
407
|
+
initialData: {
|
|
408
|
+
contentItems: [{ channel: 'MOBILEPUSH', templateData: { messageSubject: 'Hi' } }],
|
|
409
|
+
},
|
|
410
|
+
onSave,
|
|
396
411
|
});
|
|
397
412
|
|
|
398
413
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
399
414
|
|
|
400
|
-
await waitFor(() => expect(
|
|
415
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalledTimes(1));
|
|
416
|
+
expect(createCommDefinition).toHaveBeenCalledWith(
|
|
417
|
+
expect.objectContaining({
|
|
418
|
+
singleChannelStrategy: expect.objectContaining({
|
|
419
|
+
variant: expect.objectContaining({
|
|
420
|
+
channel: 'MPUSH',
|
|
421
|
+
mpushMessageContent: { messageSubject: 'Hi' },
|
|
422
|
+
}),
|
|
423
|
+
}),
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
401
426
|
});
|
|
402
427
|
|
|
403
|
-
it('
|
|
404
|
-
|
|
428
|
+
it('merges ccsCommDefinition into the data passed to onSave when create succeeds', async () => {
|
|
429
|
+
const onSave = jest.fn();
|
|
405
430
|
renderWithFlow({
|
|
406
431
|
features: {},
|
|
432
|
+
config: ccsConfig,
|
|
407
433
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
434
|
+
onSave,
|
|
408
435
|
});
|
|
409
436
|
|
|
410
437
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
411
438
|
|
|
412
|
-
await waitFor(() => expect(
|
|
413
|
-
expect(
|
|
439
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
440
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
441
|
+
expect.objectContaining({
|
|
442
|
+
ccsCommDefinition: { id: 'cd_123', referenceId: 'ORDER_PLACED_123', version: 1, status: 'DRAFT' },
|
|
443
|
+
}),
|
|
444
|
+
);
|
|
414
445
|
});
|
|
415
446
|
|
|
416
|
-
it('
|
|
447
|
+
it('preserves a real version of 0 from CCS (not coerced to 1 by a falsy-zero fallback)', async () => {
|
|
448
|
+
const onSave = jest.fn();
|
|
449
|
+
createCommDefinition.mockResolvedValueOnce({
|
|
450
|
+
response: { data: { id: 'cd_123', referenceId: 'ORDER_PLACED_123', status: 'DRAFT', version: { version: 0 } } },
|
|
451
|
+
});
|
|
417
452
|
renderWithFlow({
|
|
418
453
|
features: {},
|
|
419
|
-
config:
|
|
454
|
+
config: ccsConfig,
|
|
420
455
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
456
|
+
onSave,
|
|
421
457
|
});
|
|
422
458
|
|
|
423
459
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
424
460
|
|
|
425
|
-
await waitFor(() => expect(
|
|
426
|
-
expect(
|
|
461
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
462
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
427
463
|
expect.objectContaining({
|
|
428
|
-
|
|
464
|
+
ccsCommDefinition: { id: 'cd_123', referenceId: 'ORDER_PLACED_123', version: 0, status: 'DRAFT' },
|
|
429
465
|
}),
|
|
430
466
|
);
|
|
431
467
|
});
|
|
432
468
|
|
|
469
|
+
it('generates a referenceId from name when config.context.referenceId is absent', async () => {
|
|
470
|
+
// moduleMocks.js spies on Date.now globally, but this config's resetMocks:true
|
|
471
|
+
// clears that return value before every test — set it explicitly here.
|
|
472
|
+
jest.spyOn(Date, 'now').mockReturnValue(1612267539410);
|
|
473
|
+
renderWithFlow({
|
|
474
|
+
features: {},
|
|
475
|
+
config: ccsConfig,
|
|
476
|
+
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
480
|
+
|
|
481
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalled());
|
|
482
|
+
const payload = createCommDefinition.mock.calls[0][0];
|
|
483
|
+
expect(payload.referenceId).toBe('ORDER_PLACED_NOTIFICATION_1612267539410');
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('uses config.context.referenceId and description when provided', async () => {
|
|
487
|
+
renderWithFlow({
|
|
488
|
+
features: {},
|
|
489
|
+
config: { ...ccsConfig, context: { ...ccsConfig.context, referenceId: 'ORDER_PLACED', description: 'desc' } },
|
|
490
|
+
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
494
|
+
|
|
495
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalled());
|
|
496
|
+
expect(createCommDefinition).toHaveBeenCalledWith(
|
|
497
|
+
expect.objectContaining({ referenceId: 'ORDER_PLACED', description: 'desc' }),
|
|
498
|
+
);
|
|
499
|
+
});
|
|
500
|
+
|
|
433
501
|
it('skips CCS entirely when useCCS is false', async () => {
|
|
434
502
|
const onSave = jest.fn();
|
|
435
503
|
renderWithFlow({
|
|
436
504
|
features: {},
|
|
437
|
-
config: { ...
|
|
505
|
+
config: { ...ccsConfig, useCCS: false },
|
|
438
506
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
439
507
|
onSave,
|
|
440
508
|
});
|
|
@@ -442,14 +510,15 @@ describe('handleSave — CCS flow', () => {
|
|
|
442
510
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
443
511
|
|
|
444
512
|
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
445
|
-
expect(
|
|
513
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
514
|
+
expect(onSave).toHaveBeenCalledWith(expect.not.objectContaining({ ccsCommDefinition: expect.anything() }));
|
|
446
515
|
});
|
|
447
516
|
|
|
448
|
-
it('
|
|
449
|
-
createCentralCommsMetaId.mockRejectedValue(new Error('Network error'));
|
|
517
|
+
it('skips createCommDefinition when config.context.name is absent (mandatory)', async () => {
|
|
450
518
|
const onSave = jest.fn();
|
|
451
519
|
renderWithFlow({
|
|
452
520
|
features: {},
|
|
521
|
+
config: { ...baseConfig, features: {} },
|
|
453
522
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
454
523
|
onSave,
|
|
455
524
|
});
|
|
@@ -457,12 +526,70 @@ describe('handleSave — CCS flow', () => {
|
|
|
457
526
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
458
527
|
|
|
459
528
|
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
529
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
460
530
|
});
|
|
461
531
|
|
|
462
|
-
it('skips
|
|
532
|
+
it('skips createCommDefinition for multi-channel strategies (CHANNEL_PRIORITY/AB_TEST)', async () => {
|
|
463
533
|
const onSave = jest.fn();
|
|
464
534
|
renderWithFlow({
|
|
465
535
|
features: {},
|
|
536
|
+
config: ccsConfig,
|
|
537
|
+
initialData: {
|
|
538
|
+
communicationStrategy: CHANNEL_PRIORITY,
|
|
539
|
+
channels: ['SMS', 'EMAIL'],
|
|
540
|
+
contentItems: [{ channel: 'SMS', templateData: {} }, { channel: 'EMAIL', templateData: {} }],
|
|
541
|
+
},
|
|
542
|
+
onSave,
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
546
|
+
|
|
547
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
548
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('still calls onSave (without ccsCommDefinition) when createCommDefinition rejects', async () => {
|
|
552
|
+
createCommDefinition.mockRejectedValue(new Error('Network error'));
|
|
553
|
+
const onSave = jest.fn();
|
|
554
|
+
renderWithFlow({
|
|
555
|
+
features: {},
|
|
556
|
+
config: ccsConfig,
|
|
557
|
+
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
558
|
+
onSave,
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
562
|
+
|
|
563
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
564
|
+
expect(onSave).toHaveBeenCalledWith(expect.not.objectContaining({ ccsCommDefinition: expect.anything() }));
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
it('blocks save and shows an error when createCommDefinition resolves with a duplicate REFERENCE_ID_EXISTS conflict', async () => {
|
|
568
|
+
createCommDefinition.mockResolvedValue({
|
|
569
|
+
success: false,
|
|
570
|
+
status: { isError: true, code: 409, message: 'REFERENCE_ID_EXISTS' },
|
|
571
|
+
message: 'REFERENCE_ID_EXISTS',
|
|
572
|
+
});
|
|
573
|
+
const onSave = jest.fn();
|
|
574
|
+
renderWithFlow({
|
|
575
|
+
features: {},
|
|
576
|
+
config: ccsConfig,
|
|
577
|
+
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
578
|
+
onSave,
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
582
|
+
|
|
583
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalledTimes(1));
|
|
584
|
+
expect(await screen.findByText(/already in use in your organization/i)).toBeInTheDocument();
|
|
585
|
+
expect(onSave).not.toHaveBeenCalled();
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it('skips createCommDefinition when contentItems is empty', async () => {
|
|
589
|
+
const onSave = jest.fn();
|
|
590
|
+
renderWithFlow({
|
|
591
|
+
features: {},
|
|
592
|
+
config: ccsConfig,
|
|
466
593
|
initialData: { contentItems: [] },
|
|
467
594
|
onSave,
|
|
468
595
|
});
|
|
@@ -470,12 +597,13 @@ describe('handleSave — CCS flow', () => {
|
|
|
470
597
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
471
598
|
|
|
472
599
|
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
473
|
-
expect(
|
|
600
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
474
601
|
});
|
|
475
602
|
|
|
476
|
-
it('
|
|
603
|
+
it('places additionalSettings derived from dynamicControls under settings.additionalSettings (not delivery settings)', async () => {
|
|
477
604
|
renderWithFlow({
|
|
478
605
|
features: {},
|
|
606
|
+
config: ccsConfig,
|
|
479
607
|
initialData: {
|
|
480
608
|
contentItems: [{ channel: 'SMS', templateData: {} }],
|
|
481
609
|
dynamicControls: {
|
|
@@ -489,14 +617,36 @@ describe('handleSave — CCS flow', () => {
|
|
|
489
617
|
|
|
490
618
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
491
619
|
|
|
492
|
-
await waitFor(() => expect(
|
|
493
|
-
const payload =
|
|
494
|
-
expect(payload.
|
|
620
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalled());
|
|
621
|
+
const payload = createCommDefinition.mock.calls[0][0];
|
|
622
|
+
expect(payload.settings.additionalSettings).toEqual({
|
|
495
623
|
useTinyUrl: true,
|
|
496
624
|
encryptUrl: true,
|
|
497
625
|
linkTrackingEnabled: true,
|
|
498
626
|
userSubscriptionDisabled: true,
|
|
499
627
|
});
|
|
628
|
+
expect(payload.singleChannelStrategy.variant.smsDeliverySettings.additionalSettings).toBeUndefined();
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
it('includes channelSettings from deliverySetting.channelSetting in the payload', async () => {
|
|
632
|
+
renderWithFlow({
|
|
633
|
+
features: {},
|
|
634
|
+
config: ccsConfig,
|
|
635
|
+
initialData: {
|
|
636
|
+
contentItems: [{ channel: 'SMS', templateData: {} }],
|
|
637
|
+
deliverySetting: { channelSetting: { SMS: { domainId: 1001, gsmSenderId: 'BRAND1' } } },
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
642
|
+
|
|
643
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalled());
|
|
644
|
+
const payload = createCommDefinition.mock.calls[0][0];
|
|
645
|
+
expect(payload.singleChannelStrategy.variant.smsDeliverySettings.channelSettings).toEqual({
|
|
646
|
+
channel: 'SMS',
|
|
647
|
+
domainId: 1001,
|
|
648
|
+
gsmSenderId: 'BRAND1',
|
|
649
|
+
});
|
|
500
650
|
});
|
|
501
651
|
});
|
|
502
652
|
|
|
@@ -552,39 +702,34 @@ describe('optional chaining safety', () => {
|
|
|
552
702
|
jest.clearAllMocks();
|
|
553
703
|
});
|
|
554
704
|
|
|
555
|
-
it('
|
|
556
|
-
|
|
705
|
+
it('does not crash and skips CCS when config.context is entirely absent', async () => {
|
|
706
|
+
const onSave = jest.fn();
|
|
557
707
|
renderWithFlow({
|
|
558
708
|
features: {},
|
|
709
|
+
config: { ...baseConfig, features: {} },
|
|
559
710
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
711
|
+
onSave,
|
|
560
712
|
});
|
|
561
713
|
|
|
562
714
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
563
715
|
|
|
564
|
-
await waitFor(() => expect(
|
|
565
|
-
expect(
|
|
566
|
-
expect.objectContaining({
|
|
567
|
-
centralCommsPayload: expect.objectContaining({ ouId: -1 }),
|
|
568
|
-
}),
|
|
569
|
-
);
|
|
716
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
717
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
570
718
|
});
|
|
571
719
|
|
|
572
|
-
it('
|
|
573
|
-
|
|
720
|
+
it('does not crash when config.context is present but empty', async () => {
|
|
721
|
+
const onSave = jest.fn();
|
|
574
722
|
renderWithFlow({
|
|
575
723
|
features: {},
|
|
576
|
-
config: { ...baseConfig,
|
|
724
|
+
config: { ...baseConfig, context: {}, features: {} },
|
|
577
725
|
initialData: { contentItems: [{ channel: 'SMS', templateData: {} }] },
|
|
726
|
+
onSave,
|
|
578
727
|
});
|
|
579
728
|
|
|
580
729
|
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
581
730
|
|
|
582
|
-
await waitFor(() => expect(
|
|
583
|
-
expect(
|
|
584
|
-
expect.objectContaining({
|
|
585
|
-
centralCommsPayload: expect.objectContaining({ module: 'LOYALTY' }),
|
|
586
|
-
}),
|
|
587
|
-
);
|
|
731
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
732
|
+
expect(createCommDefinition).not.toHaveBeenCalled();
|
|
588
733
|
});
|
|
589
734
|
|
|
590
735
|
it('initializes channel from config.channel when initialData.channel is absent', () => {
|
|
@@ -108,6 +108,22 @@ describe('CommunicationFlowCard', () => {
|
|
|
108
108
|
fireEvent.click(screen.getByText('Add creatives'));
|
|
109
109
|
expect(screen.getByTestId('comm-flow-mock')).toHaveAttribute('data-mode', 'create');
|
|
110
110
|
});
|
|
111
|
+
|
|
112
|
+
it('disables the Add creatives button when disabled prop is true', () => {
|
|
113
|
+
renderCard({ disabled: true, disabledTooltip: 'Enter an Alert name to add content' });
|
|
114
|
+
expect(screen.getByText('Add creatives').closest('button')).toBeDisabled();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('does not open SlideBox when Add creatives is clicked while disabled', () => {
|
|
118
|
+
renderCard({ disabled: true, disabledTooltip: 'Enter an Alert name to add content' });
|
|
119
|
+
fireEvent.click(screen.getByText('Add creatives'));
|
|
120
|
+
expect(screen.queryByTestId('slide-box')).not.toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('Add creatives button is enabled by default (disabled prop absent)', () => {
|
|
124
|
+
renderCard();
|
|
125
|
+
expect(screen.getByText('Add creatives').closest('button')).not.toBeDisabled();
|
|
126
|
+
});
|
|
111
127
|
});
|
|
112
128
|
|
|
113
129
|
describe('configured state (initialData provided)', () => {
|
|
@@ -38,6 +38,53 @@ export const CHANNEL_PRIORITY = 'CHANNEL_PRIORITY';
|
|
|
38
38
|
export const AB_TEST = 'AB_TEST';
|
|
39
39
|
export const SINGLE_TEMPLATE = 'SINGLE_TEMPLATE';
|
|
40
40
|
|
|
41
|
+
// CCS CommDefinition strategyType — distinct from SINGLE_TEMPLATE above, which
|
|
42
|
+
// is this UI's own communicationStrategy value. Only SINGLE is supported this
|
|
43
|
+
// phase; CCS create is skipped entirely for CHANNEL_PRIORITY/AB_TEST.
|
|
44
|
+
export const CCS_STRATEGY_TYPE_SINGLE = 'SINGLE';
|
|
45
|
+
|
|
46
|
+
// Mirrors CCS's SingleChannelStrategy field names exactly (Cap Notify API
|
|
47
|
+
// Design doc sample payloads, verified against real create responses). Kept
|
|
48
|
+
// separate from CHANNEL_CONTENT_KEY_MAP/CHANNEL_DELIVERY_KEY_MAP below, which
|
|
49
|
+
// are the legacy messageMeta payload's keys.
|
|
50
|
+
export const CCS_CHANNEL_CONTENT_KEY_MAP = {
|
|
51
|
+
SMS: 'smsMessageContent',
|
|
52
|
+
EMAIL: 'emailMessageContent',
|
|
53
|
+
WHATSAPP: 'whatsappMessageContent',
|
|
54
|
+
MPUSH: 'mpushMessageContent',
|
|
55
|
+
INAPP: 'inAppMessageContent',
|
|
56
|
+
ANDROID: 'androidMessageContent',
|
|
57
|
+
IOS: 'iosMessageContent',
|
|
58
|
+
ZALO: 'zaloMessageContent',
|
|
59
|
+
VIBER: 'viberMessageContent',
|
|
60
|
+
LINE: 'lineMessageContent',
|
|
61
|
+
WEBPUSH: 'webPushMessageContent',
|
|
62
|
+
RCS: 'rcsMessageContent',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
66
|
+
SMS: 'smsDeliverySettings',
|
|
67
|
+
EMAIL: 'emailDeliverySettings',
|
|
68
|
+
WHATSAPP: 'whatsappDeliverySettings',
|
|
69
|
+
MPUSH: 'mpushDeliverySettings',
|
|
70
|
+
INAPP: 'inAppDeliverySettings',
|
|
71
|
+
ANDROID: 'androidDeliverySettings',
|
|
72
|
+
IOS: 'iosDeliverySettings',
|
|
73
|
+
ZALO: 'zaloDeliverySettings',
|
|
74
|
+
VIBER: 'viberDeliverySettings',
|
|
75
|
+
LINE: 'lineDeliverySettings',
|
|
76
|
+
WEBPUSH: 'webPushDeliverySettings',
|
|
77
|
+
RCS: 'rcsDeliverySettings',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// The UI's own internal channel identifier for mobile push is 'MOBILEPUSH'
|
|
81
|
+
// (see CreativesContainer/constants.js MOBILE_PUSH), but CCS's channel enum
|
|
82
|
+
// only recognises 'MPUSH' (globals.js CCS_CHANNELS) — normalize before
|
|
83
|
+
// building the CCS payload. Every other channel identifier matches CCS as-is.
|
|
84
|
+
export const CCS_CHANNEL_NAME_MAP = {
|
|
85
|
+
MOBILEPUSH: 'MPUSH',
|
|
86
|
+
};
|
|
87
|
+
|
|
41
88
|
// Channel config - single source of truth for CreativesContainer and TemplatesV2
|
|
42
89
|
// paneKey: TemplatesV2 defaultPanes object key (for channelsToHide)
|
|
43
90
|
// channelProp: CreativesContainer channel prop (must match pane.key for tab to be active)
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import CommunicationFlow from './CommunicationFlow';
|
|
12
|
-
import { hasSupportEngagementModule } from '../../utils/common';
|
|
13
12
|
|
|
14
13
|
const CommunicationFlowContainer = ({
|
|
15
14
|
config,
|
|
@@ -18,22 +17,16 @@ const CommunicationFlowContainer = ({
|
|
|
18
17
|
onCancel,
|
|
19
18
|
onChange,
|
|
20
19
|
...otherProps
|
|
21
|
-
}) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
onCancel={onCancel}
|
|
32
|
-
onChange={onChange}
|
|
33
|
-
{...otherProps}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
20
|
+
}) => (
|
|
21
|
+
<CommunicationFlow
|
|
22
|
+
config={config}
|
|
23
|
+
initialData={initialData}
|
|
24
|
+
onSave={onSave}
|
|
25
|
+
onCancel={onCancel}
|
|
26
|
+
onChange={onChange}
|
|
27
|
+
{...otherProps}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
37
30
|
|
|
38
31
|
CommunicationFlowContainer.propTypes = {
|
|
39
32
|
config: PropTypes.shape({
|
|
@@ -87,11 +80,13 @@ CommunicationFlowContainer.propTypes = {
|
|
|
87
80
|
controls: PropTypes.array,
|
|
88
81
|
}),
|
|
89
82
|
}),
|
|
90
|
-
context: PropTypes.object, // ouId, campaignId, programId,
|
|
91
|
-
|
|
83
|
+
context: PropTypes.object, // ouId, campaignId, programId; name (required for CCS create),
|
|
84
|
+
// referenceId (optional, auto-generated from name if absent), description (optional).
|
|
85
|
+
useCCS: PropTypes.bool, // If false, skips the CCS createCommDefinition call on save. Defaults to true.
|
|
92
86
|
}).isRequired,
|
|
93
87
|
initialData: PropTypes.object, // for edit/preview mode
|
|
94
|
-
onSave: PropTypes.func.isRequired, // (data) => void - called when user saves
|
|
88
|
+
onSave: PropTypes.func.isRequired, // (data) => void - called when user saves; data.ccsCommDefinition
|
|
89
|
+
// ({id, referenceId, version, status}) is present when the CCS create succeeded
|
|
95
90
|
onCancel: PropTypes.func.isRequired, // () => void - called when user cancels
|
|
96
91
|
onChange: PropTypes.func, // (data) => void - optional, called on data changes
|
|
97
92
|
};
|
|
@@ -363,4 +363,8 @@ export default {
|
|
|
363
363
|
id: `${prefix}.senderNotConfiguredError`,
|
|
364
364
|
defaultMessage: 'Selected domain gateway id is not correct. Please change the domain id or contact the gateway team to register them with Capillary.',
|
|
365
365
|
},
|
|
366
|
+
duplicateReferenceIdError: {
|
|
367
|
+
id: `${prefix}.duplicateReferenceIdError`,
|
|
368
|
+
defaultMessage: 'This reference ID is already in use in your organization. Please use a different reference ID.',
|
|
369
|
+
},
|
|
366
370
|
};
|
|
@@ -1441,7 +1441,6 @@ export class Creatives extends React.Component {
|
|
|
1441
1441
|
cardType = "",
|
|
1442
1442
|
cardSettings = {},
|
|
1443
1443
|
accountId = "",
|
|
1444
|
-
vfTemplateId,
|
|
1445
1444
|
} = get(versions, 'base.content.RCS.rcsContent', {});
|
|
1446
1445
|
const firstCardFromSubmit = Array.isArray(cardContentFromSubmit)
|
|
1447
1446
|
? cardContentFromSubmit[0]
|
|
@@ -1470,7 +1469,6 @@ export class Creatives extends React.Component {
|
|
|
1470
1469
|
creativeName: name,
|
|
1471
1470
|
rcsContent,
|
|
1472
1471
|
accountId,
|
|
1473
|
-
...(vfTemplateId && { templateId: vfTemplateId }),
|
|
1474
1472
|
...(includeRootRcsCardVarMappedOnConsumerPayload
|
|
1475
1473
|
? { rcsCardVarMapped: cardVarMappedFromFirstRcsCard }
|
|
1476
1474
|
: {}),
|
|
@@ -358,8 +358,6 @@ export const Rcs = (props) => {
|
|
|
358
358
|
const [accessToken, setAccessToken] = useState('');
|
|
359
359
|
const [hostName, setHostName] = useState('');
|
|
360
360
|
const [accountName, setAccountName] = useState('');
|
|
361
|
-
const [botId, setBotId] = useState('');
|
|
362
|
-
const [vfTemplateId, setVfTemplateId] = useState('');
|
|
363
361
|
const isHostInfoBip = hostName === HOST_INFOBIP;
|
|
364
362
|
const isHostIcs = hostName === HOST_ICS;
|
|
365
363
|
|
|
@@ -383,14 +381,12 @@ export const Rcs = (props) => {
|
|
|
383
381
|
setHostName(accountObj.hostName || '');
|
|
384
382
|
setAccountName(accountObj.name || '');
|
|
385
383
|
setRcsAccount(accountObj.id || '');
|
|
386
|
-
setBotId(accountObj.connectionProperties?.agentid || '');
|
|
387
384
|
} else {
|
|
388
385
|
setAccountId('');
|
|
389
386
|
setWecrmAccountId('');
|
|
390
387
|
setAccessToken('');
|
|
391
388
|
setHostName('');
|
|
392
389
|
setAccountName('');
|
|
393
|
-
setBotId('');
|
|
394
390
|
}
|
|
395
391
|
}, [accountData.selectedRcsAccount]);
|
|
396
392
|
|
|
@@ -1391,8 +1387,6 @@ export const Rcs = (props) => {
|
|
|
1391
1387
|
const rcsAccountId = get(details, 'versions.base.content.RCS.rcsContent.accountId', '');
|
|
1392
1388
|
setRcsAccount(rcsAccountId);
|
|
1393
1389
|
}
|
|
1394
|
-
const storedVfTemplateId = get(details, 'versions.base.content.RCS.rcsContent.vfTemplateId', '');
|
|
1395
|
-
if (storedVfTemplateId) setVfTemplateId(storedVfTemplateId);
|
|
1396
1390
|
|
|
1397
1391
|
applySmsFallbackHydration({
|
|
1398
1392
|
details,
|
|
@@ -2830,8 +2824,7 @@ const onTitleAddVar = () => {
|
|
|
2830
2824
|
}
|
|
2831
2825
|
],
|
|
2832
2826
|
contentType: isFullMode ? templateType : RICHCARD,
|
|
2833
|
-
...(isFullMode && {accountId, accessToken, accountName, hostName
|
|
2834
|
-
...(vfTemplateId && { vfTemplateId }),
|
|
2827
|
+
...(isFullMode && {accountId:accountId, accessToken: accessToken, accountName: accountName, hostName: hostName}),
|
|
2835
2828
|
},
|
|
2836
2829
|
...smsFallbackPayloadContent,
|
|
2837
2830
|
},
|
|
@@ -2971,7 +2964,6 @@ const onTitleAddVar = () => {
|
|
|
2971
2964
|
accountName,
|
|
2972
2965
|
hostName,
|
|
2973
2966
|
smsRegister,
|
|
2974
|
-
vfTemplateId,
|
|
2975
2967
|
]);
|
|
2976
2968
|
|
|
2977
2969
|
/**
|