@capillarytech/creatives-library 9.0.54-alpha.1 → 9.0.54-alpha.2
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
|
@@ -432,6 +432,52 @@ describe('handleSave — CCS flow', () => {
|
|
|
432
432
|
);
|
|
433
433
|
});
|
|
434
434
|
|
|
435
|
+
it('transforms WEBPUSH content from the legacy editor\'s messageContent.content wrapping to CCS\'s flat shape', async () => {
|
|
436
|
+
const onSave = jest.fn();
|
|
437
|
+
const cta = { type: 'SITE_URL', actionLink: 'https://example.com' };
|
|
438
|
+
const expandableDetails = { media: [{ url: 'https://example.com/banner.png', type: 'IMAGE' }], ctas: [] };
|
|
439
|
+
renderWithFlow({
|
|
440
|
+
features: {},
|
|
441
|
+
config: ccsConfig,
|
|
442
|
+
initialData: {
|
|
443
|
+
contentItems: [{
|
|
444
|
+
channel: 'WEBPUSH',
|
|
445
|
+
templateData: {
|
|
446
|
+
messageContent: {
|
|
447
|
+
content: {
|
|
448
|
+
channel: 'WEBPUSH',
|
|
449
|
+
accountId: 13792,
|
|
450
|
+
content: { title: 'Hi', message: 'Body', iconImageUrl: 'https://example.com/icon.png', cta, expandableDetails },
|
|
451
|
+
messageSubject: 'Subject',
|
|
452
|
+
offers: [],
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
}],
|
|
457
|
+
},
|
|
458
|
+
onSave,
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
462
|
+
|
|
463
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalledTimes(1));
|
|
464
|
+
expect(createCommDefinition).toHaveBeenCalledWith(
|
|
465
|
+
expect.objectContaining({
|
|
466
|
+
singleChannelStrategy: expect.objectContaining({
|
|
467
|
+
variant: expect.objectContaining({
|
|
468
|
+
channel: 'WEBPUSH',
|
|
469
|
+
webPushMessageContent: {
|
|
470
|
+
channel: 'WEBPUSH',
|
|
471
|
+
messageSubject: 'Subject',
|
|
472
|
+
accountId: 13792,
|
|
473
|
+
content: { title: 'Hi', message: 'Body', iconImageUrl: 'https://example.com/icon.png', cta, expandableDetails },
|
|
474
|
+
},
|
|
475
|
+
}),
|
|
476
|
+
}),
|
|
477
|
+
}),
|
|
478
|
+
);
|
|
479
|
+
});
|
|
480
|
+
|
|
435
481
|
it('normalizes the internal MOBILEPUSH channel to CCS\'s PUSH enum (keys stay mpush*)', async () => {
|
|
436
482
|
const onSave = jest.fn();
|
|
437
483
|
renderWithFlow({
|
|
@@ -77,6 +77,19 @@ export const CCS_CONTENT_TRANSFORMS = {
|
|
|
77
77
|
messageSubject: templateData.emailSubject,
|
|
78
78
|
messageBody: templateData.messageBody,
|
|
79
79
|
}),
|
|
80
|
+
// WEBPUSH: the legacy editor nests the real data under
|
|
81
|
+
// messageContent.content (see CommunicationFlowCard.js's own comment on
|
|
82
|
+
// this same wrapping, for the edit-mode case) — extracting it flat here
|
|
83
|
+
// matches CCS's shape ({ messageSubject, accountId, content }); `offers`
|
|
84
|
+
// (a legacy-only field) is deliberately dropped, not part of CCS's schema.
|
|
85
|
+
WEBPUSH: (templateData = {}) => {
|
|
86
|
+
const inner = templateData.messageContent?.content || templateData;
|
|
87
|
+
return {
|
|
88
|
+
messageSubject: inner.messageSubject,
|
|
89
|
+
accountId: inner.accountId,
|
|
90
|
+
content: inner.content,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
80
93
|
};
|
|
81
94
|
|
|
82
95
|
export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
@@ -298,4 +311,4 @@ export const INCENTIVE_TYPES = [
|
|
|
298
311
|
{
|
|
299
312
|
value: 'badges', label: <FormattedMessage {...messages.badges} />, isActive: false, disabled: false,
|
|
300
313
|
},
|
|
301
|
-
];
|
|
314
|
+
];
|