@capillarytech/creatives-library 9.0.55-alpha.0 → 9.0.55-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 +1 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +20 -0
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +106 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +9 -1
package/package.json
CHANGED
|
@@ -139,6 +139,26 @@ const UnifiedPreview = ({
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
case CHANNELS.LINE:
|
|
143
|
+
// LINE's real content today is a single text message (CCS's
|
|
144
|
+
// lineMessageContent.messageBody is a JSON string of LINE's native
|
|
145
|
+
// messages[] array — see testAndPreviewDataTransform.js's LINE case,
|
|
146
|
+
// which already resolves it down to plain text before it reaches
|
|
147
|
+
// here) — reuse the same simple chat-bubble preview as SMS. Rich LINE
|
|
148
|
+
// message types (image/video/sticker/imageMap/carousel/flex) are NOT
|
|
149
|
+
// rendered specially yet; they'll show as empty/raw text until this
|
|
150
|
+
// gets richer LINE-specific handling.
|
|
151
|
+
return (
|
|
152
|
+
<SmsPreviewContent
|
|
153
|
+
content={typeof content === 'string' ? content : (content?.resolvedBody || '')}
|
|
154
|
+
device={device}
|
|
155
|
+
isUpdating={isUpdating}
|
|
156
|
+
error={error}
|
|
157
|
+
formatMessage={formatMessage}
|
|
158
|
+
showHeader={showHeader}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
|
|
142
162
|
case CHANNELS.WHATSAPP: {
|
|
143
163
|
// WhatsApp content is an object with templateMsg, media, CTA, etc.
|
|
144
164
|
const whatsappContent = typeof content === 'object' ? content : {};
|
|
@@ -85,6 +85,7 @@ export const CHANNELS = {
|
|
|
85
85
|
VIBER: 'VIBER',
|
|
86
86
|
ZALO: 'ZALO',
|
|
87
87
|
WEBPUSH: 'WEBPUSH',
|
|
88
|
+
LINE: 'LINE',
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
/** Unified preview tab keys when RCS shows RCS + SMS fallback panes. */
|
|
@@ -100,6 +101,7 @@ export const CHANNELS_USING_ANDROID_PREVIEW_DEVICE = [
|
|
|
100
101
|
CHANNELS.INAPP,
|
|
101
102
|
CHANNELS.MOBILEPUSH,
|
|
102
103
|
CHANNELS.VIBER,
|
|
104
|
+
CHANNELS.LINE,
|
|
103
105
|
];
|
|
104
106
|
|
|
105
107
|
/** RCS createMessageMeta test payload — rich card envelope literals. */
|
|
@@ -479,6 +479,112 @@ describe('UnifiedPreview', () => {
|
|
|
479
479
|
});
|
|
480
480
|
});
|
|
481
481
|
|
|
482
|
+
describe('Channel Routing - LINE', () => {
|
|
483
|
+
it('should render SmsPreviewContent for LINE channel with string content', () => {
|
|
484
|
+
const props = {
|
|
485
|
+
...defaultProps,
|
|
486
|
+
channel: CHANNELS.LINE,
|
|
487
|
+
content: 'Hello world',
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
render(
|
|
491
|
+
<TestWrapper>
|
|
492
|
+
<ComponentToRender {...props} />
|
|
493
|
+
</TestWrapper>
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
497
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Hello world');
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('should handle object content with resolvedBody for LINE channel', () => {
|
|
501
|
+
const props = {
|
|
502
|
+
...defaultProps,
|
|
503
|
+
channel: CHANNELS.LINE,
|
|
504
|
+
content: {
|
|
505
|
+
resolvedBody: 'some text',
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
render(
|
|
510
|
+
<TestWrapper>
|
|
511
|
+
<ComponentToRender {...props} />
|
|
512
|
+
</TestWrapper>
|
|
513
|
+
);
|
|
514
|
+
|
|
515
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
516
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('some text');
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it('should not crash and render empty content for LINE channel when content is undefined', () => {
|
|
520
|
+
const props = {
|
|
521
|
+
...defaultProps,
|
|
522
|
+
channel: CHANNELS.LINE,
|
|
523
|
+
content: undefined,
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
render(
|
|
527
|
+
<TestWrapper>
|
|
528
|
+
<ComponentToRender {...props} />
|
|
529
|
+
</TestWrapper>
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
533
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('');
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it('should not crash and render empty content for LINE channel when content is null', () => {
|
|
537
|
+
const props = {
|
|
538
|
+
...defaultProps,
|
|
539
|
+
channel: CHANNELS.LINE,
|
|
540
|
+
content: null,
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
render(
|
|
544
|
+
<TestWrapper>
|
|
545
|
+
<ComponentToRender {...props} />
|
|
546
|
+
</TestWrapper>
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
550
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('');
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it('should render empty content for LINE channel when content is not a string and has no resolvedBody', () => {
|
|
554
|
+
const props = {
|
|
555
|
+
...defaultProps,
|
|
556
|
+
channel: CHANNELS.LINE,
|
|
557
|
+
content: { someOtherField: 'value' },
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
render(
|
|
561
|
+
<TestWrapper>
|
|
562
|
+
<ComponentToRender {...props} />
|
|
563
|
+
</TestWrapper>
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
567
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('');
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it('should not render the Unknown Channel fallback for LINE channel', () => {
|
|
571
|
+
const props = {
|
|
572
|
+
...defaultProps,
|
|
573
|
+
channel: CHANNELS.LINE,
|
|
574
|
+
content: 'Hello world',
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
render(
|
|
578
|
+
<TestWrapper>
|
|
579
|
+
<ComponentToRender {...props} />
|
|
580
|
+
</TestWrapper>
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
expect(screen.queryByText('Unknown Channel')).toBeNull();
|
|
584
|
+
expect(screen.getByTestId('sms-preview')).toBeTruthy();
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
|
|
482
588
|
describe('Channel Routing - WHATSAPP', () => {
|
|
483
589
|
it('should render WhatsAppPreviewContent for WHATSAPP channel', () => {
|
|
484
590
|
const props = {
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
CLEAR_PREVIEW_ERRORS,
|
|
43
43
|
// Channel Constants
|
|
44
44
|
CHANNELS,
|
|
45
|
+
CHANNELS_USING_ANDROID_PREVIEW_DEVICE,
|
|
45
46
|
// Device Constants
|
|
46
47
|
DESKTOP,
|
|
47
48
|
MOBILE,
|
|
@@ -180,15 +181,22 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
180
181
|
expect(CHANNELS.VIBER).toBe('VIBER');
|
|
181
182
|
expect(CHANNELS.ZALO).toBe('ZALO');
|
|
182
183
|
expect(CHANNELS.WEBPUSH).toBe('WEBPUSH');
|
|
184
|
+
expect(CHANNELS.LINE).toBe('LINE');
|
|
183
185
|
});
|
|
184
186
|
|
|
185
187
|
it('should have all required channel keys', () => {
|
|
186
|
-
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO', 'WEBPUSH'];
|
|
188
|
+
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO', 'WEBPUSH', 'LINE'];
|
|
187
189
|
expect(Object.keys(CHANNELS)).toEqual(expect.arrayContaining(expectedChannels));
|
|
188
190
|
expect(Object.keys(CHANNELS).length).toBe(expectedChannels.length);
|
|
189
191
|
});
|
|
190
192
|
});
|
|
191
193
|
|
|
194
|
+
describe('CHANNELS_USING_ANDROID_PREVIEW_DEVICE', () => {
|
|
195
|
+
it('should include CHANNELS.LINE', () => {
|
|
196
|
+
expect(CHANNELS_USING_ANDROID_PREVIEW_DEVICE).toContain(CHANNELS.LINE);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
192
200
|
describe('Device Constants', () => {
|
|
193
201
|
it('should export all device constants with correct values', () => {
|
|
194
202
|
expect(DESKTOP).toBe('desktop');
|