@capillarytech/creatives-library 9.0.40 → 9.0.41-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.
@@ -200,6 +200,370 @@ describe('ViberPreviewContent', () => {
200
200
 
201
201
  expect(screen.getByText('Click Here')).toBeTruthy();
202
202
  });
203
+
204
+ it('should not render button when buttonText has only whitespace', () => {
205
+ const props = {
206
+ ...defaultProps,
207
+ content: {
208
+ viberPreviewContent: {
209
+ messageContent: 'Message',
210
+ buttonText: ' ',
211
+ },
212
+ },
213
+ };
214
+
215
+ const { container } = render(
216
+ <TestWrapper>
217
+ <ComponentToRender {...props} />
218
+ </TestWrapper>
219
+ );
220
+
221
+ expect(container.querySelector('.viber-button-base')).toBeFalsy();
222
+ });
223
+ });
224
+
225
+ describe('Carousel Content', () => {
226
+ it('should render no content when carousel is selected but cards are empty', () => {
227
+ const props = {
228
+ ...defaultProps,
229
+ content: {
230
+ viberPreviewContent: {
231
+ type: 'CAROUSEL',
232
+ cards: [
233
+ {
234
+ text: '',
235
+ mediaUrl: '',
236
+ buttons: [
237
+ { title: '', action: '' },
238
+ ],
239
+ },
240
+ {
241
+ text: ' ',
242
+ mediaUrl: ' ',
243
+ buttons: [
244
+ { title: ' ', action: 'https://example.com/2' },
245
+ ],
246
+ },
247
+ ],
248
+ },
249
+ },
250
+ };
251
+
252
+ render(
253
+ <TestWrapper>
254
+ <ComponentToRender {...props} />
255
+ </TestWrapper>
256
+ );
257
+
258
+ expect(screen.getByText('No content available')).toBeTruthy();
259
+ });
260
+
261
+ it('should render carousel cards when type is CAROUSEL', () => {
262
+ const props = {
263
+ ...defaultProps,
264
+ content: {
265
+ viberPreviewContent: {
266
+ type: 'CAROUSEL',
267
+ cards: [
268
+ {
269
+ text: 'Card 1 text',
270
+ mediaUrl: 'https://image.url/card1.jpg',
271
+ buttons: [
272
+ { title: 'Button 1', action: 'https://example.com/1' },
273
+ ],
274
+ },
275
+ {
276
+ text: 'Card 2 text',
277
+ mediaUrl: 'https://image.url/card2.jpg',
278
+ buttons: [
279
+ { title: 'Button 2', action: 'https://example.com/2' },
280
+ ],
281
+ },
282
+ ],
283
+ },
284
+ },
285
+ };
286
+
287
+ render(
288
+ <TestWrapper>
289
+ <ComponentToRender {...props} />
290
+ </TestWrapper>
291
+ );
292
+
293
+ expect(screen.getByText('Card 1 text')).toBeTruthy();
294
+ expect(screen.getByText('Card 2 text')).toBeTruthy();
295
+ expect(screen.getByText('Button 1')).toBeTruthy();
296
+ expect(screen.getByText('Button 2')).toBeTruthy();
297
+ });
298
+
299
+ it('should not render empty carousel button placeholder', () => {
300
+ const props = {
301
+ ...defaultProps,
302
+ content: {
303
+ viberPreviewContent: {
304
+ type: 'CAROUSEL',
305
+ cards: [
306
+ {
307
+ text: 'Card 1 text',
308
+ mediaUrl: 'https://image.url/card1.jpg',
309
+ buttons: [
310
+ { title: '', action: 'https://example.com/1' },
311
+ { title: ' ', action: 'https://example.com/2' },
312
+ ],
313
+ },
314
+ ],
315
+ },
316
+ },
317
+ };
318
+
319
+ const { container } = render(
320
+ <TestWrapper>
321
+ <ComponentToRender {...props} />
322
+ </TestWrapper>
323
+ );
324
+
325
+ expect(container.querySelector('.viber-carousel-preview-button')).toBeNull();
326
+ });
327
+
328
+ it('should show carousel shell when showCarouselEditorPreview is true even if cards are empty', () => {
329
+ const props = {
330
+ ...defaultProps,
331
+ content: {
332
+ viberPreviewContent: {
333
+ type: 'CAROUSEL',
334
+ showCarouselEditorPreview: true,
335
+ cards: [
336
+ { text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
337
+ { text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
338
+ ],
339
+ },
340
+ },
341
+ };
342
+
343
+ const { container } = render(
344
+ <TestWrapper>
345
+ <ComponentToRender {...props} />
346
+ </TestWrapper>
347
+ );
348
+
349
+ expect(screen.queryByText('No content available')).toBeNull();
350
+ expect(container.querySelector('.viber-carousel-preview-scroll')).toBeTruthy();
351
+ expect(container.querySelector('.viber-carousel-message-box-placeholder')).toBeTruthy();
352
+ });
353
+
354
+ it('should render carousel message text in message box when type is CAROUSEL', () => {
355
+ const props = {
356
+ ...defaultProps,
357
+ content: {
358
+ viberPreviewContent: {
359
+ type: 'CAROUSEL',
360
+ messageContent: 'Carousel intro copy',
361
+ cards: [
362
+ {
363
+ text: 'Card text',
364
+ mediaUrl: 'https://image.url/c.jpg',
365
+ buttons: [{ title: 'Go', action: 'https://example.com' }],
366
+ },
367
+ ],
368
+ },
369
+ },
370
+ };
371
+
372
+ const { container } = render(
373
+ <TestWrapper>
374
+ <ComponentToRender {...props} />
375
+ </TestWrapper>
376
+ );
377
+
378
+ expect(container.querySelector('.viber-carousel-message-box-text')).toHaveTextContent('Carousel intro copy');
379
+ expect(screen.queryByText('Carousel intro copy')).toBeTruthy();
380
+ });
381
+
382
+ it('should hide account icon when carousel is shown', () => {
383
+ const props = {
384
+ ...defaultProps,
385
+ content: {
386
+ viberPreviewContent: {
387
+ type: 'CAROUSEL',
388
+ cards: [
389
+ {
390
+ text: 'Carousel card line',
391
+ mediaUrl: '',
392
+ buttons: [{ title: 'Open link', action: 'https://x.com' }],
393
+ },
394
+ ],
395
+ },
396
+ },
397
+ };
398
+
399
+ const { container } = render(
400
+ <TestWrapper>
401
+ <ComponentToRender {...props} />
402
+ </TestWrapper>
403
+ );
404
+
405
+ expect(container.querySelector('.viber-account-icon')).toBeNull();
406
+ });
407
+
408
+ it('should use image placeholder when carousel card mediaUrl is whitespace only', () => {
409
+ const props = {
410
+ ...defaultProps,
411
+ content: {
412
+ viberPreviewContent: {
413
+ type: 'CAROUSEL',
414
+ cards: [
415
+ {
416
+ text: 'Only text',
417
+ mediaUrl: ' ',
418
+ buttons: [{ title: 'Btn', action: 'https://example.com' }],
419
+ },
420
+ ],
421
+ },
422
+ },
423
+ };
424
+
425
+ const { container } = render(
426
+ <TestWrapper>
427
+ <ComponentToRender {...props} />
428
+ </TestWrapper>
429
+ );
430
+
431
+ expect(container.querySelector('.viber-carousel-preview-image-placeholder')).toBeTruthy();
432
+ expect(container.querySelector('.viber-carousel-preview-image')).toBeNull();
433
+ });
434
+
435
+ it('should render at most two carousel buttons per card', () => {
436
+ const props = {
437
+ ...defaultProps,
438
+ content: {
439
+ viberPreviewContent: {
440
+ type: 'CAROUSEL',
441
+ cards: [
442
+ {
443
+ text: 'Card',
444
+ mediaUrl: 'https://image.url/c.jpg',
445
+ buttons: [
446
+ { title: 'One', action: 'https://a.com' },
447
+ { title: 'Two', action: 'https://b.com' },
448
+ { title: 'Three', action: 'https://c.com' },
449
+ ],
450
+ },
451
+ ],
452
+ },
453
+ },
454
+ };
455
+
456
+ const { container } = render(
457
+ <TestWrapper>
458
+ <ComponentToRender {...props} />
459
+ </TestWrapper>
460
+ );
461
+
462
+ expect(container.querySelectorAll('.viber-carousel-preview-button')).toHaveLength(2);
463
+ expect(screen.getByText('One')).toBeTruthy();
464
+ expect(screen.getByText('Two')).toBeTruthy();
465
+ expect(screen.queryByText('Three')).toBeNull();
466
+ });
467
+
468
+ it('should apply secondary class to second carousel button', () => {
469
+ const props = {
470
+ ...defaultProps,
471
+ content: {
472
+ viberPreviewContent: {
473
+ type: 'CAROUSEL',
474
+ cards: [
475
+ {
476
+ text: 'Card',
477
+ mediaUrl: 'https://image.url/c.jpg',
478
+ buttons: [
479
+ { title: 'Primary', action: 'https://a.com' },
480
+ { title: 'Secondary', action: 'https://b.com' },
481
+ ],
482
+ },
483
+ ],
484
+ },
485
+ },
486
+ };
487
+
488
+ const { container } = render(
489
+ <TestWrapper>
490
+ <ComponentToRender {...props} />
491
+ </TestWrapper>
492
+ );
493
+
494
+ const buttons = container.querySelectorAll('.viber-carousel-preview-button');
495
+ expect(buttons[0].className).toContain('viber-carousel-preview-button');
496
+ expect(buttons[0].className).not.toContain('viber-carousel-preview-button-secondary');
497
+ expect(buttons[1].className).toContain('viber-carousel-preview-button-secondary');
498
+ });
499
+
500
+ it('should show carousel when only a button title is present on a card', () => {
501
+ const props = {
502
+ ...defaultProps,
503
+ content: {
504
+ viberPreviewContent: {
505
+ type: 'CAROUSEL',
506
+ cards: [
507
+ {
508
+ text: '',
509
+ mediaUrl: '',
510
+ buttons: [{ title: 'Tap me', action: 'https://example.com' }],
511
+ },
512
+ ],
513
+ },
514
+ },
515
+ };
516
+
517
+ render(
518
+ <TestWrapper>
519
+ <ComponentToRender {...props} />
520
+ </TestWrapper>
521
+ );
522
+
523
+ expect(screen.getByText('Tap me')).toBeTruthy();
524
+ expect(screen.queryByText('No content available')).toBeNull();
525
+ });
526
+
527
+ it('should show one placeholder card when editor preview and cards array is empty', () => {
528
+ const props = {
529
+ ...defaultProps,
530
+ content: {
531
+ viberPreviewContent: {
532
+ type: 'CAROUSEL',
533
+ showCarouselEditorPreview: true,
534
+ cards: [],
535
+ },
536
+ },
537
+ };
538
+
539
+ const { container } = render(
540
+ <TestWrapper>
541
+ <ComponentToRender {...props} />
542
+ </TestWrapper>
543
+ );
544
+
545
+ expect(container.querySelectorAll('.viber-carousel-preview-card')).toHaveLength(1);
546
+ });
547
+
548
+ it('should show no content when CAROUSEL has empty cards and no editor preview flag', () => {
549
+ const props = {
550
+ ...defaultProps,
551
+ content: {
552
+ viberPreviewContent: {
553
+ type: 'CAROUSEL',
554
+ cards: [],
555
+ },
556
+ },
557
+ };
558
+
559
+ render(
560
+ <TestWrapper>
561
+ <ComponentToRender {...props} />
562
+ </TestWrapper>
563
+ );
564
+
565
+ expect(screen.getByText('No content available')).toBeTruthy();
566
+ });
203
567
  });
204
568
 
205
569
  describe('Account and Brand Name', () => {
@@ -160,6 +160,102 @@
160
160
  line-clamp: 3;
161
161
  }
162
162
  }
163
+ .viber-carousel-static-content {
164
+ width: 100%;
165
+ overflow: visible;
166
+ display: flex;
167
+ flex-direction: column;
168
+ .viber-carousel-static-message-box {
169
+ width: 100%;
170
+ height: auto;
171
+ border-radius: $CAP_SPACE_04;
172
+ background: $CAP_WHITE;
173
+ margin-bottom: $CAP_SPACE_08;
174
+ display: flex;
175
+ align-items: flex-start;
176
+ }
177
+ .viber-carousel-static-message {
178
+ display: -webkit-box;
179
+ width: 100%;
180
+ color: $CAP_G01;
181
+ line-height: 1.3;
182
+ overflow: hidden;
183
+ text-overflow: ellipsis;
184
+ -webkit-line-clamp: 2;
185
+ line-clamp: 2;
186
+ -webkit-box-orient: vertical;
187
+ white-space: normal;
188
+ word-break: break-word;
189
+ }
190
+ .viber-carousel-static-cards {
191
+ display: flex;
192
+ gap: $CAP_SPACE_08;
193
+ overflow: visible;
194
+ }
195
+ .viber-carousel-static-card {
196
+ flex: 1;
197
+ min-width: 0;
198
+ width: 100%;
199
+ background: $CAP_WHITE;
200
+ border-radius: $CAP_SPACE_04;
201
+ overflow: visible;
202
+ display: flex;
203
+ flex-direction: column;
204
+ }
205
+ .viber-carousel-static-image {
206
+ width: 100%;
207
+ max-height: 11rem;
208
+ margin-bottom: $CAP_SPACE_04;
209
+ border-radius: $CAP_SPACE_04;
210
+ display: block;
211
+ flex-shrink: 0;
212
+ }
213
+ .viber-carousel-static-image-placeholder {
214
+ width: 100%;
215
+ height: 7.143rem;
216
+ border-radius: $CAP_SPACE_04;
217
+ }
218
+ .viber-carousel-static-image-placeholder {
219
+ background: $CAP_G07;
220
+ }
221
+ .viber-carousel-static-text {
222
+ display: block;
223
+ color: $CAP_G01;
224
+ margin: $CAP_SPACE_04 0;
225
+ line-height: 1.3;
226
+ overflow: hidden;
227
+ text-overflow: ellipsis;
228
+ white-space: normal;
229
+ -webkit-line-clamp: 2;
230
+ line-clamp: 2;
231
+ -webkit-box-orient: vertical;
232
+ display: -webkit-box;
233
+ flex-shrink: 0;
234
+ }
235
+ .viber-carousel-static-buttons {
236
+ display: flex;
237
+ flex-direction: column;
238
+ gap: $CAP_SPACE_04;
239
+ flex-shrink: 0;
240
+ width: 100%;
241
+ }
242
+ .viber-carousel-static-button {
243
+ display: block;
244
+ min-height: 1.5rem;
245
+ border-radius: $CAP_SPACE_12;
246
+ background: $CAP_PURPLE01;
247
+ color: $CAP_WHITE;
248
+ text-align: center;
249
+ padding: 0.179rem $CAP_SPACE_08;
250
+ white-space: normal;
251
+ }
252
+ .viber-carousel-static-button-secondary {
253
+ color: $CAP_PURPLE01;
254
+ background: transparent;
255
+ border: none;
256
+ box-shadow: none;
257
+ }
258
+ }
163
259
 
164
260
  }
165
261
 
@@ -168,6 +264,44 @@
168
264
  word-wrap: break-word;
169
265
  }
170
266
  }
267
+
268
+ &.viber-carousel-static {
269
+ height: auto;
270
+ min-height: 21.125rem;
271
+ overflow: visible;
272
+
273
+ .ant-card-body {
274
+ height: auto;
275
+ overflow: visible;
276
+ padding-bottom: $CAP_SPACE_12;
277
+
278
+ .ant-card-meta,
279
+ .ant-card-meta-detail,
280
+ .ant-card-meta-description {
281
+ height: auto;
282
+ max-height: none;
283
+ overflow: visible;
284
+ }
285
+
286
+ .truncate-text-viber {
287
+ .ant-card-meta-description {
288
+ display: block;
289
+ overflow: visible;
290
+ max-height: none;
291
+ -webkit-box-orient: unset;
292
+ -webkit-line-clamp: unset;
293
+ line-clamp: unset;
294
+ }
295
+ }
296
+
297
+ .viber-carousel-static-content,
298
+ .viber-carousel-static-cards,
299
+ .viber-carousel-static-card {
300
+ overflow: visible;
301
+ height: auto;
302
+ }
303
+ }
304
+ }
171
305
 
172
306
 
173
307
  &.carousel-img-section {
@@ -1222,6 +1356,67 @@
1222
1356
  max-height: 11rem;
1223
1357
  margin-bottom: $CAP_SPACE_04;
1224
1358
  }
1359
+
1360
+ /* Listing carousel preview: always grow with content so title + buttons stay visible for any image */
1361
+ .cap-custom-card.ant-card.VIBER.viber-carousel-static {
1362
+ height: auto;
1363
+ min-height: 21.125rem;
1364
+ overflow: visible;
1365
+
1366
+ > .ant-card-body {
1367
+ height: auto;
1368
+ max-height: none;
1369
+ overflow: visible;
1370
+ padding-bottom: $CAP_SPACE_12;
1371
+ }
1372
+
1373
+ .ant-card-meta,
1374
+ .ant-card-meta-detail,
1375
+ .ant-card-meta-description,
1376
+ .truncate-text-viber,
1377
+ .truncate-text-viber .ant-card-meta-description {
1378
+ height: auto;
1379
+ max-height: none;
1380
+ overflow: visible;
1381
+ display: block;
1382
+ -webkit-line-clamp: unset;
1383
+ line-clamp: unset;
1384
+ -webkit-box-orient: unset;
1385
+ }
1386
+
1387
+ .viber-carousel-static-content,
1388
+ .viber-carousel-static-card,
1389
+ .viber-carousel-static-buttons {
1390
+ display: flex;
1391
+ flex-direction: column;
1392
+ width: 100%;
1393
+ }
1394
+
1395
+ .viber-carousel-static-content,
1396
+ .viber-carousel-static-cards,
1397
+ .viber-carousel-static-card {
1398
+ overflow: visible;
1399
+ height: auto;
1400
+ }
1401
+
1402
+ .viber-carousel-static-cards {
1403
+ width: 100%;
1404
+ }
1405
+
1406
+ .viber-carousel-static-image {
1407
+ width: 100%;
1408
+ max-height: 11rem;
1409
+ display: block;
1410
+ flex-shrink: 0;
1411
+ }
1412
+
1413
+ .viber-carousel-static-text,
1414
+ .viber-carousel-static-buttons {
1415
+ width: 100%;
1416
+ flex-shrink: 0;
1417
+ visibility: visible;
1418
+ }
1419
+ }
1225
1420
  .whatsapp-doc {
1226
1421
  width: 100%;
1227
1422
  max-height: 123px;