From 9eb6edba654ad7446ea1e521ed882a6f38b290e9 Mon Sep 17 00:00:00 2001 From: Tommmaso Menga Date: Thu, 27 Jun 2024 10:41:03 +0200 Subject: [PATCH] test(sbb-map-container): add visual spec --- .../map-container.snapshot.spec.snap.js | 28 +++++--- .../map-container.snapshot.spec.ts | 46 +++++++------ .../map-container.visual.spec.ts | 65 +++++++++++++++++++ 3 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 src/elements/map-container/map-container.visual.spec.ts diff --git a/src/elements/map-container/__snapshots__/map-container.snapshot.spec.snap.js b/src/elements/map-container/__snapshots__/map-container.snapshot.spec.snap.js index b34b4141e9..23c270d5a0 100644 --- a/src/elements/map-container/__snapshots__/map-container.snapshot.spec.snap.js +++ b/src/elements/map-container/__snapshots__/map-container.snapshot.spec.snap.js @@ -1,7 +1,13 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["sbb-map-container renders the container with button"] = +snapshots["sbb-map-container renders DOM"] = +` + +`; +/* end snapshot sbb-map-container renders DOM */ + +snapshots["sbb-map-container renders Shadow DOM"] = `
@@ -31,9 +37,15 @@ snapshots["sbb-map-container renders the container with button"] =
`; -/* end snapshot sbb-map-container renders the container with button */ +/* end snapshot sbb-map-container renders Shadow DOM */ + +snapshots["sbb-map-container renders without scroll-up button DOM"] = +` + +`; +/* end snapshot sbb-map-container renders without scroll-up button DOM */ -snapshots["sbb-map-container renders the container without button"] = +snapshots["sbb-map-container renders without scroll-up button Shadow DOM"] = `
@@ -45,9 +57,9 @@ snapshots["sbb-map-container renders the container without button"] =
`; -/* end snapshot sbb-map-container renders the container without button */ +/* end snapshot sbb-map-container renders without scroll-up button Shadow DOM */ -snapshots["sbb-map-container A11y tree Chrome"] = +snapshots["sbb-map-container renders A11y tree Chrome"] = `

{ "role": "WebArea", @@ -55,9 +67,9 @@ snapshots["sbb-map-container A11y tree Chrome"] = }

`; -/* end snapshot sbb-map-container A11y tree Chrome */ +/* end snapshot sbb-map-container renders A11y tree Chrome */ -snapshots["sbb-map-container A11y tree Firefox"] = +snapshots["sbb-map-container renders A11y tree Firefox"] = `

{ "role": "document", @@ -65,5 +77,5 @@ snapshots["sbb-map-container A11y tree Firefox"] = }

`; -/* end snapshot sbb-map-container A11y tree Firefox */ +/* end snapshot sbb-map-container renders A11y tree Firefox */ diff --git a/src/elements/map-container/map-container.snapshot.spec.ts b/src/elements/map-container/map-container.snapshot.spec.ts index 676840060e..75aa5f0b16 100644 --- a/src/elements/map-container/map-container.snapshot.spec.ts +++ b/src/elements/map-container/map-container.snapshot.spec.ts @@ -10,29 +10,33 @@ import './map-container.js'; describe(`sbb-map-container`, () => { let element: SbbMapContainerElement; - it('renders the container with button', async () => { - element = await fixture(html``); - - expect(element).dom.to.be.equal( - ` - - - `, - ); - await expect(element).shadowDom.to.be.equalSnapshot(); - }); + describe('renders', () => { + beforeEach(async () => { + element = await fixture(html``); + }); + + it('DOM', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); - it('renders the container without button', async () => { - element = await fixture(html``); + it('Shadow DOM', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); - expect(element).dom.to.be.equal( - ` - - - `, - ); - await expect(element).shadowDom.to.be.equalSnapshot(); + testA11yTreeSnapshot(); }); - testA11yTreeSnapshot(html``); + describe('renders without scroll-up button', () => { + beforeEach(async () => { + element = await fixture(html``); + }); + + it('DOM', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('Shadow DOM', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + }); }); diff --git a/src/elements/map-container/map-container.visual.spec.ts b/src/elements/map-container/map-container.visual.spec.ts new file mode 100644 index 0000000000..856e89804c --- /dev/null +++ b/src/elements/map-container/map-container.visual.spec.ts @@ -0,0 +1,65 @@ +import { html } from 'lit'; +import { styleMap } from 'lit/directives/style-map.js'; + +import { describeViewports, visualDiffDefault } from '../core/testing/private.js'; + +import './map-container.js'; +import '../header.js'; +import '../title.js'; + +describe(`sbb-map-container`, () => { + describeViewports({ viewports: ['zero', 'medium'], viewportHeight: 500 }, () => { + it( + visualDiffDefault.name, + visualDiffDefault.with(async (setup) => { + await setup.withFixture( + html` + + + Menu + + + + +
+ Operations & Disruptions + ${[...Array(5).keys()].map( + (value) => html` +
+

Situation ${value}

+
+ `, + )} +
+ +
+
+ map +
+
+
+ `, + { padding: '0' }, + ); + }), + ); + }); +});