@@ -11,6 +11,10 @@ async function renderTwig(template, data) {
11
11
return await render ( template , data , true ) ;
12
12
}
13
13
14
+ async function renderTwigString ( template , data ) {
15
+ return await renderString ( template , data , true ) ;
16
+ }
17
+
14
18
const timeout = 60000 ;
15
19
16
20
const viewportSizes = [
@@ -137,7 +141,7 @@ describe('<bolt-navbar> Component', async () => {
137
141
}
138
142
139
143
await processViewportSizes ( viewportSizes ) ;
140
- } , 10000 ) ;
144
+ } , 15000 ) ;
141
145
142
146
test ( '<bolt-navbar> with a linked title' , async ( ) => {
143
147
const { html, ok } = await renderTwig (
@@ -190,15 +194,16 @@ describe('<bolt-navbar> Component', async () => {
190
194
document . body . appendChild ( div ) ;
191
195
} , html ) ;
192
196
197
+ await page . hover ( '.c-bolt-navbar__title--link' ) ;
198
+
193
199
const image = await page . screenshot ( ) ;
194
200
expect ( image ) . toMatchImageSnapshot ( ) ;
195
201
196
202
await page . tap ( '.c-bolt-navbar__title--link' ) ;
197
203
198
204
const pageTitle = await page . title ( ) ;
199
205
expect ( pageTitle ) . toMatch ( 'Bolt Design System' ) ;
200
-
201
- } , 20000 ) ;
206
+ } , 15000 ) ;
202
207
203
208
test ( '<bolt-navbar> with 4 short links' , async ( ) => {
204
209
const { html, ok } = await renderTwig (
@@ -291,7 +296,7 @@ describe('<bolt-navbar> Component', async () => {
291
296
}
292
297
293
298
await processViewportSizes ( viewportSizes ) ;
294
- } , 10000 ) ;
299
+ } , 15000 ) ;
295
300
296
301
test ( '<bolt-navbar> centered with 4 short links' , async ( ) => {
297
302
const { html, ok } = await renderTwig (
@@ -385,7 +390,7 @@ describe('<bolt-navbar> Component', async () => {
385
390
}
386
391
387
392
await processViewportSizes ( viewportSizes ) ;
388
- } , 10000 ) ;
393
+ } , 15000 ) ;
389
394
390
395
test ( '<bolt-navbar> without links' , async ( ) => {
391
396
const { html, ok } = await renderTwig (
@@ -423,68 +428,124 @@ describe('<bolt-navbar> Component', async () => {
423
428
failureThreshold : '0.01' ,
424
429
failureThresholdType : 'percent' ,
425
430
} ) ;
426
- } ) ;
427
-
428
- // test('Default <bolt-ratio> w/o Shadow DOM renders', async function() {
429
- // const renderedRatioHTML = await page.evaluate(() => {
430
- // const ratio = document.createElement('bolt-ratio');
431
- // const img = document.createElement('img');
432
- // img.setAttribute('src', '/fixtures/1200x660.jpg');
433
-
434
- // ratio.setAttribute('no-shadow', '');
435
- // ratio.setAttribute('ratio', '1200/660');
436
- // ratio.appendChild(img);
437
-
438
- // document.body.appendChild(ratio);
439
- // return ratio.outerHTML;
440
- // });
441
- // expect(renderedRatioHTML).toMatchSnapshot();
442
-
443
- // const image = await page.screenshot();
444
- // expect(image).toMatchImageSnapshot({
445
- // failureThreshold: '0.01',
446
- // failureThresholdType: 'percent',
447
- // });
448
-
449
- // const renderedRatioStyles = await page.evaluate(() => {
450
- // const ratio = document.querySelector('bolt-ratio');
451
- // const innerRatio = ratio.renderRoot.querySelector('.c-bolt-ratio');
452
- // return innerRatio.style.getPropertyValue('--aspect-ratio').trim();
453
- // });
454
-
455
- // expect(renderedRatioStyles).toMatch(parseFloat(1200 / 660).toFixed(5));
456
- // });
457
-
458
- // test('<bolt-ratio> with HTML5 video renders', async function() {
459
- // const renderedRatioHTML = await page.evaluate(() => {
460
- // const ratio = document.createElement('bolt-ratio');
461
-
462
- // ratio.innerHTML = `<video controls poster="/fixtures/poster.png">
463
- // <source src="/fixtures/devstories.webm" type="video/webm;codecs="vp8, vorbis"">
464
- // <source src="/fixtures/devstories.mp4" type="video/mp4;codecs="avc1.42E01E, mp4a.40.2"">
465
- // <track src="/fixtures/devstories-en.vtt" label="English subtitles" kind="subtitles" srclang="en" default="">
466
- // </video>`;
467
- // ratio.setAttribute('ratio', '640/360');
468
- // ratio.style.width = '640px';
469
- // document.body.appendChild(ratio);
470
- // return ratio.outerHTML;
471
- // });
472
-
473
- // const renderedRatioSize = await page.evaluate(() => {
474
- // const ratioSize = {
475
- // width: document.querySelector('bolt-ratio').clientWidth,
476
- // height: document.querySelector('bolt-ratio').clientHeight,
477
- // };
478
- // return ratioSize;
479
- // });
480
-
481
- // const image = await page.screenshot();
482
-
483
- // expect(image).toMatchImageSnapshot({
484
- // failureThreshold: '0.01',
485
- // failureThresholdType: 'percent',
486
- // });
487
-
488
- // expect(renderedRatioHTML).toMatchSnapshot();
489
- // });
431
+ } , 15000 ) ;
432
+
433
+ test ( '<bolt-navbar> without a title' , async ( ) => {
434
+ const { html, ok } = await renderTwig (
435
+ '@bolt-components-navbar/navbar.twig' ,
436
+ {
437
+ links : [
438
+ {
439
+ text : 'Components' ,
440
+ url : '/pattern-lab/index.html' ,
441
+ } ,
442
+ {
443
+ text : 'Docs' ,
444
+ url : '/docs/getting-started/index.html' ,
445
+ } ,
446
+ {
447
+ text : 'Releases' ,
448
+ url : 'https://github.com/bolt-design-system/bolt/releases' ,
449
+ attributes : {
450
+ target : '_blank' ,
451
+ } ,
452
+ } ,
453
+ {
454
+ text : 'Github' ,
455
+ url : 'https://github.com/bolt-design-system/bolt' ,
456
+ attributes : {
457
+ target : '_blank' ,
458
+ } ,
459
+ icon : {
460
+ name : 'github' ,
461
+ position : 'after' ,
462
+ } ,
463
+ } ,
464
+ ] ,
465
+ } ,
466
+ ) ;
467
+ expect ( ok ) . toBe ( true ) ;
468
+ expect ( html ) . toMatchSnapshot ( ) ;
469
+
470
+ await page . evaluate ( html => {
471
+ const div = document . createElement ( 'div' ) ;
472
+ div . innerHTML = `${ html } ` ;
473
+ document . body . appendChild ( div ) ;
474
+ } , html ) ;
475
+ const largeViewport = await page . screenshot ( ) ;
476
+
477
+ expect ( largeViewport ) . toMatchImageSnapshot ( {
478
+ failureThreshold : '0.01' ,
479
+ failureThresholdType : 'percent' ,
480
+ } ) ;
481
+
482
+ await page . setViewport ( { height : 568 , width : 320 } ) ;
483
+ const smallViewport = await page . screenshot ( ) ;
484
+
485
+ expect ( smallViewport ) . toMatchImageSnapshot ( {
486
+ failureThreshold : '0.01' ,
487
+ failureThresholdType : 'percent' ,
488
+ } ) ;
489
+ } , 15000 ) ;
490
+
491
+ test ( '<bolt-navbar> variable width' , async ( ) => {
492
+ const { html, ok } = await renderTwigString ( `
493
+ {% grid "o-bolt-grid--center" %}
494
+ {% cell "u-bolt-width-2/3 u-bolt-width-1/2@small" %}
495
+ {% include "@bolt-components-navbar/navbar.twig" with {
496
+ width: 'auto',
497
+ links: [
498
+ {
499
+ text: 'Components',
500
+ url: '/pattern-lab/index.html',
501
+ },
502
+ {
503
+ text: 'Docs',
504
+ url: '/docs/getting-started/index.html',
505
+ },
506
+ {
507
+ text: 'Releases',
508
+ url: 'https://github.com/bolt-design-system/bolt/releases',
509
+ attributes: {
510
+ target: '_blank',
511
+ },
512
+ },
513
+ {
514
+ text: 'Github',
515
+ url: 'https://github.com/bolt-design-system/bolt',
516
+ attributes: {
517
+ target: '_blank',
518
+ },
519
+ icon: {
520
+ name: 'github',
521
+ position: 'after',
522
+ },
523
+ },
524
+ ],
525
+ } only %}
526
+ {% endcell %}
527
+ {% endgrid %}
528
+ ` ) ;
529
+ expect ( ok ) . toBe ( true ) ;
530
+ expect ( html ) . toMatchSnapshot ( ) ;
531
+
532
+ await page . evaluate ( html => {
533
+ const div = document . createElement ( 'div' ) ;
534
+ div . innerHTML = `${ html } ` ;
535
+ document . body . appendChild ( div ) ;
536
+ } , html ) ;
537
+
538
+ async function processViewportSizes ( viewportSizes ) {
539
+ for ( const item of viewportSizes ) {
540
+ const { height, width, size } = item ;
541
+ screenshots [ size ] = [ ] ;
542
+
543
+ await page . setViewport ( { height, width } ) ;
544
+ screenshots [ size ] . default = await page . screenshot ( ) ;
545
+ expect ( screenshots [ size ] . default ) . toMatchImageSnapshot ( ) ;
546
+ }
547
+ }
548
+
549
+ await processViewportSizes ( viewportSizes ) ;
550
+ } , 15000 ) ;
490
551
} ) ;
0 commit comments