@capillarytech/creatives-library 9.0.53-alpha.0 → 9.0.53-alpha.1
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
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
CCS_STRATEGY_TYPE_SINGLE,
|
|
40
40
|
CCS_CHANNEL_CONTENT_KEY_MAP,
|
|
41
41
|
CCS_CHANNEL_DELIVERY_KEY_MAP,
|
|
42
|
+
CCS_CHANNEL_NAME_MAP,
|
|
42
43
|
} from './constants';
|
|
43
44
|
import { getEnabledSteps } from './utils/getEnabledSteps';
|
|
44
45
|
import messages from './messages';
|
|
@@ -186,7 +187,8 @@ const CommunicationFlow = ({
|
|
|
186
187
|
// CCS create is SINGLE-strategy only this phase (D1); CHANNEL_PRIORITY/AB_TEST
|
|
187
188
|
// carry multiple content items with no CCS equivalent yet.
|
|
188
189
|
if (!isMultiChannel && contentItem && name) {
|
|
189
|
-
const
|
|
190
|
+
const rawChannel = (contentItem.channel || '').toUpperCase();
|
|
191
|
+
const channel = CCS_CHANNEL_NAME_MAP[rawChannel] || rawChannel;
|
|
190
192
|
const contentKey = CCS_CHANNEL_CONTENT_KEY_MAP[channel];
|
|
191
193
|
const deliveryKey = CCS_CHANNEL_DELIVERY_KEY_MAP[channel];
|
|
192
194
|
const { dynamicControls = {} } = aggregatedData;
|
|
@@ -208,9 +210,11 @@ const CommunicationFlow = ({
|
|
|
208
210
|
executionParams: {},
|
|
209
211
|
},
|
|
210
212
|
singleChannelStrategy: {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
variant: {
|
|
214
|
+
channel,
|
|
215
|
+
...(contentKey && { [contentKey]: contentItem.templateData }),
|
|
216
|
+
...(deliveryKey && { [deliveryKey]: { channelSettings: { channel, ...channelSettings } } }),
|
|
217
|
+
},
|
|
214
218
|
},
|
|
215
219
|
};
|
|
216
220
|
|
|
@@ -389,14 +389,42 @@ describe('handleSave — CCS flow', () => {
|
|
|
389
389
|
name: 'Order Placed Notification',
|
|
390
390
|
strategyType: 'SINGLE',
|
|
391
391
|
singleChannelStrategy: expect.objectContaining({
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
variant: expect.objectContaining({
|
|
393
|
+
channel: 'SMS',
|
|
394
|
+
smsMessageContent: { message: 'Hello' },
|
|
395
|
+
}),
|
|
394
396
|
}),
|
|
395
397
|
}),
|
|
396
398
|
);
|
|
397
399
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
398
400
|
});
|
|
399
401
|
|
|
402
|
+
it('normalizes the internal MOBILEPUSH channel to CCS\'s MPUSH enum and key names', async () => {
|
|
403
|
+
const onSave = jest.fn();
|
|
404
|
+
renderWithFlow({
|
|
405
|
+
features: {},
|
|
406
|
+
config: ccsConfig,
|
|
407
|
+
initialData: {
|
|
408
|
+
contentItems: [{ channel: 'MOBILEPUSH', templateData: { messageSubject: 'Hi' } }],
|
|
409
|
+
},
|
|
410
|
+
onSave,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
414
|
+
|
|
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
|
+
);
|
|
426
|
+
});
|
|
427
|
+
|
|
400
428
|
it('merges ccsCommDefinition into the data passed to onSave when create succeeds', async () => {
|
|
401
429
|
const onSave = jest.fn();
|
|
402
430
|
renderWithFlow({
|
|
@@ -575,7 +603,7 @@ describe('handleSave — CCS flow', () => {
|
|
|
575
603
|
linkTrackingEnabled: true,
|
|
576
604
|
userSubscriptionDisabled: true,
|
|
577
605
|
});
|
|
578
|
-
expect(payload.singleChannelStrategy.smsDeliverySettings.additionalSettings).toBeUndefined();
|
|
606
|
+
expect(payload.singleChannelStrategy.variant.smsDeliverySettings.additionalSettings).toBeUndefined();
|
|
579
607
|
});
|
|
580
608
|
|
|
581
609
|
it('includes channelSettings from deliverySetting.channelSetting in the payload', async () => {
|
|
@@ -592,7 +620,7 @@ describe('handleSave — CCS flow', () => {
|
|
|
592
620
|
|
|
593
621
|
await waitFor(() => expect(createCommDefinition).toHaveBeenCalled());
|
|
594
622
|
const payload = createCommDefinition.mock.calls[0][0];
|
|
595
|
-
expect(payload.singleChannelStrategy.smsDeliverySettings.channelSettings).toEqual({
|
|
623
|
+
expect(payload.singleChannelStrategy.variant.smsDeliverySettings.channelSettings).toEqual({
|
|
596
624
|
channel: 'SMS',
|
|
597
625
|
domainId: 1001,
|
|
598
626
|
gsmSenderId: 'BRAND1',
|
|
@@ -44,15 +44,14 @@ export const SINGLE_TEMPLATE = 'SINGLE_TEMPLATE';
|
|
|
44
44
|
export const CCS_STRATEGY_TYPE_SINGLE = 'SINGLE';
|
|
45
45
|
|
|
46
46
|
// Mirrors CCS's SingleChannelStrategy field names exactly (Cap Notify API
|
|
47
|
-
// Design doc,
|
|
48
|
-
// CHANNEL_CONTENT_KEY_MAP/CHANNEL_DELIVERY_KEY_MAP below, which
|
|
49
|
-
// messageMeta payload's keys
|
|
50
|
-
// (e.g. legacy uses lowercase 'mpushMessageContent'; CCS uses 'mPushMessageContent').
|
|
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.
|
|
51
50
|
export const CCS_CHANNEL_CONTENT_KEY_MAP = {
|
|
52
51
|
SMS: 'smsMessageContent',
|
|
53
52
|
EMAIL: 'emailMessageContent',
|
|
54
53
|
WHATSAPP: 'whatsappMessageContent',
|
|
55
|
-
MPUSH: '
|
|
54
|
+
MPUSH: 'mpushMessageContent',
|
|
56
55
|
INAPP: 'inAppMessageContent',
|
|
57
56
|
ANDROID: 'androidMessageContent',
|
|
58
57
|
IOS: 'iosMessageContent',
|
|
@@ -67,7 +66,7 @@ export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
|
67
66
|
SMS: 'smsDeliverySettings',
|
|
68
67
|
EMAIL: 'emailDeliverySettings',
|
|
69
68
|
WHATSAPP: 'whatsappDeliverySettings',
|
|
70
|
-
MPUSH: '
|
|
69
|
+
MPUSH: 'mpushDeliverySettings',
|
|
71
70
|
INAPP: 'inAppDeliverySettings',
|
|
72
71
|
ANDROID: 'androidDeliverySettings',
|
|
73
72
|
IOS: 'iosDeliverySettings',
|
|
@@ -78,6 +77,14 @@ export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
|
78
77
|
RCS: 'rcsDeliverySettings',
|
|
79
78
|
};
|
|
80
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
|
+
|
|
81
88
|
// Channel config - single source of truth for CreativesContainer and TemplatesV2
|
|
82
89
|
// paneKey: TemplatesV2 defaultPanes object key (for channelsToHide)
|
|
83
90
|
// channelProp: CreativesContainer channel prop (must match pane.key for tab to be active)
|