From c87b787bfaaa8d7ae074e4230d0e296e4f8d6b07 Mon Sep 17 00:00:00 2001 From: Tommmaso Menga Date: Wed, 31 Jan 2024 18:04:38 +0100 Subject: [PATCH] test: implemented a11y tree tests --- .../__snapshots__/accordion.spec.snap.js | 129 ++ src/components/accordion/accordion.spec.ts | 71 +- .../__snapshots__/action-group.spec.snap.js | 130 ++ .../action-group/action-group.spec.ts | 51 +- .../__snapshots__/alert-group.spec.snap.js | 158 ++ .../alert/alert-group/alert-group.spec.ts | 56 +- .../alert/__snapshots__/alert.spec.snap.js | 247 +++ src/components/alert/alert/alert.e2e.ts | 8 + src/components/alert/alert/alert.spec.ts | 87 +- .../__snapshots__/autocomplete.spec.snap.js | 377 +++++ .../autocomplete/autocomplete.spec.ts | 156 +- .../breadcrumb-group.spec.snap.js | 182 ++- .../breadcrumb-group/breadcrumb-group.spec.ts | 30 +- .../__snapshots__/breadcrumb.spec.snap.js | 73 + .../breadcrumb/breadcrumb/breadcrumb.spec.ts | 7 +- .../__snapshots__/calendar.spec.snap.js | 1320 +++++++++++++++++ src/components/calendar/calendar.spec.ts | 241 +-- .../__snapshots__/card-badge.spec.snap.js | 80 + .../card/card-badge/card-badge.spec.ts | 37 +- .../card/card/__snapshots__/card.spec.snap.js | 148 ++ src/components/card/card/card.e2e.ts | 38 +- src/components/card/card/card.spec.ts | 28 +- .../__snapshots__/checkbox-group.spec.snap.js | 141 ++ .../checkbox-group/checkbox-group.spec.ts | 41 +- .../__snapshots__/checkbox.spec.snap.js | 101 ++ .../checkbox/checkbox/checkbox.spec.ts | 5 + .../chip/__snapshots__/chip.spec.snap.js | 71 + src/components/chip/chip.spec.ts | 26 +- .../clock/__snapshots__/clock.spec.snap.js | 64 + src/components/clock/clock.spec.ts | 46 +- .../datepicker-next-day.spec.snap.js | 64 + .../datepicker-next-day.spec.ts | 15 +- .../datepicker-previous-day.spec.snap.js | 64 + .../datepicker-previous-day.spec.ts | 18 +- .../datepicker-toggle.spec.snap.js | 159 ++ .../datepicker-toggle.spec.ts | 100 +- .../__snapshots__/datepicker.spec.snap.js | 93 ++ .../datepicker/datepicker/datepicker.spec.ts | 17 + .../dialog/__snapshots__/dialog.spec.snap.js | 30 + src/components/dialog/dialog.spec.ts | 4 + .../__snapshots__/divider.spec.snap.js | 33 + src/components/divider/divider.spec.ts | 8 +- .../expansion-panel-content.spec.snap.js | 67 + .../expansion-panel-content.spec.ts | 24 +- .../expansion-panel-header.spec.snap.js | 48 + .../expansion-panel-header.spec.ts | 6 + .../expansion-panel.spec.snap.js | 137 ++ .../expansion-panel/expansion-panel.spec.ts | 86 +- .../__snapshots__/file-selector.spec.snap.js | 72 + .../file-selector/file-selector.spec.ts | 3 + .../footer/__snapshots__/footer.spec.snap.js | 67 + src/components/footer/footer.spec.ts | 15 +- .../__snapshots__/form-error.spec.snap.js | 63 + src/components/form-error/form-error.spec.ts | 28 +- .../form-field-clear.spec.snap.js | 173 +++ .../form-field-clear/form-field-clear.spec.ts | 81 +- .../__snapshots__/form-field.spec.snap.js | 72 + .../form-field/form-field/form-field.spec.ts | 11 + .../header/__snapshots__/header.spec.snap.js | 85 ++ src/components/header/header/header.spec.ts | 90 +- .../icon/__snapshots__/icon.spec.snap.js | 30 + src/components/icon/icon.spec.ts | 3 + .../__snapshots__/journey-header.spec.snap.js | 155 ++ .../journey-header/journey-header.spec.ts | 56 +- .../journey-summary.spec.snap.js | 128 ++ .../journey-summary/journey-summary.spec.ts | 106 +- .../__snapshots__/link-list.spec.snap.js | 30 + src/components/link-list/link-list.spec.ts | 3 + .../loading-indicator.spec.snap.js | 123 ++ .../loading-indicator.spec.ts | 87 +- .../__snapshots__/map-container.spec.snap.js | 77 + .../map-container/map-container.spec.ts | 47 +- .../__snapshots__/message.spec.snap.js | 163 ++ src/components/message/message.spec.ts | 84 +- .../__snapshots__/notification.spec.snap.js | 30 + .../notification/notification.spec.ts | 12 +- .../__snapshots__/optgroup.spec.snap.js | 272 ++++ .../option/optgroup/optgroup.spec.ts | 107 +- .../option/__snapshots__/option.spec.snap.js | 87 ++ src/components/option/option/option.spec.ts | 44 +- .../radio-button-group.spec.snap.js | 54 + .../radio-button-group.spec.ts | 35 +- .../__snapshots__/radio-button.spec.snap.js | 83 ++ .../radio-button/radio-button.spec.ts | 35 +- .../screenreader-only.spec.snap.js | 42 + .../screenreader-only.spec.ts | 12 +- .../select/__snapshots__/select.spec.snap.js | 467 ++++++ src/components/select/select.spec.ts | 152 +- .../selection-panel/selection-panel.spec.ts | 49 +- .../__snapshots__/skiplink-list.spec.snap.js | 336 +++++ .../skiplink-list/skiplink-list.spec.ts | 86 +- .../slider/__snapshots__/slider.spec.snap.js | 138 ++ src/components/slider/slider.spec.ts | 40 +- .../status/__snapshots__/status.spec.snap.js | 62 + src/components/status/status.spec.ts | 6 + .../__snapshots__/tab-group.spec.snap.js | 135 ++ .../tabs/tab-group/tab-group.spec.ts | 15 +- .../__snapshots__/tab-title.spec.snap.js | 50 + .../tabs/tab-title/tab-title.spec.ts | 3 + .../__snapshots__/tag-group.spec.snap.js | 129 ++ .../tag/tag-group/tag-group.spec.ts | 60 +- .../tag/tag/__snapshots__/tag.spec.snap.js | 49 + src/components/tag/tag/tag.spec.ts | 3 + .../__snapshots__/teaser-hero.spec.snap.js | 206 +++ .../teaser-hero/teaser-hero.spec.ts | 129 +- .../teaser/__snapshots__/teaser.spec.snap.js | 73 + src/components/teaser/teaser.spec.ts | 3 + .../__snapshots__/time-input.spec.snap.js | 67 + src/components/time-input/time-input.spec.ts | 19 +- .../title/__snapshots__/title.spec.snap.js | 54 + src/components/title/title.spec.ts | 11 +- .../toast/__snapshots__/toast.spec.snap.js | 152 ++ src/components/toast/toast.spec.ts | 70 +- .../__snapshots__/toggle-check.spec.snap.js | 229 +++ .../toggle-check/toggle-check.spec.ts | 135 +- .../__snapshots__/toggle-option.spec.snap.js | 51 + .../toggle-option/toggle-option.spec.ts | 6 + .../toggle/__snapshots__/toggle.spec.snap.js | 68 + src/components/toggle/toggle/toggle.spec.ts | 3 + .../tooltip-trigger.spec.snap.js | 81 + .../tooltip-trigger/tooltip-trigger.spec.ts | 30 +- .../__snapshots__/tooltip.spec.snap.js | 62 + .../tooltip/tooltip/tooltip.spec.ts | 45 +- .../visual-checkbox.spec.snap.js | 57 + .../visual-checkbox/visual-checkbox.spec.ts | 62 +- 125 files changed, 9195 insertions(+), 1985 deletions(-) create mode 100644 src/components/accordion/__snapshots__/accordion.spec.snap.js create mode 100644 src/components/action-group/__snapshots__/action-group.spec.snap.js create mode 100644 src/components/alert/alert-group/__snapshots__/alert-group.spec.snap.js create mode 100644 src/components/alert/alert/__snapshots__/alert.spec.snap.js create mode 100644 src/components/autocomplete/__snapshots__/autocomplete.spec.snap.js create mode 100644 src/components/calendar/__snapshots__/calendar.spec.snap.js create mode 100644 src/components/card/card-badge/__snapshots__/card-badge.spec.snap.js create mode 100644 src/components/card/card/__snapshots__/card.spec.snap.js create mode 100644 src/components/checkbox/checkbox-group/__snapshots__/checkbox-group.spec.snap.js create mode 100644 src/components/chip/__snapshots__/chip.spec.snap.js create mode 100644 src/components/clock/__snapshots__/clock.spec.snap.js create mode 100644 src/components/datepicker/datepicker-toggle/__snapshots__/datepicker-toggle.spec.snap.js create mode 100644 src/components/divider/__snapshots__/divider.spec.snap.js create mode 100644 src/components/expansion-panel/expansion-panel-content/__snapshots__/expansion-panel-content.spec.snap.js create mode 100644 src/components/expansion-panel/expansion-panel/__snapshots__/expansion-panel.spec.snap.js create mode 100644 src/components/footer/__snapshots__/footer.spec.snap.js create mode 100644 src/components/form-error/__snapshots__/form-error.spec.snap.js create mode 100644 src/components/form-field/form-field-clear/__snapshots__/form-field-clear.spec.snap.js create mode 100644 src/components/header/header/__snapshots__/header.spec.snap.js create mode 100644 src/components/journey-header/__snapshots__/journey-header.spec.snap.js create mode 100644 src/components/journey-summary/__snapshots__/journey-summary.spec.snap.js create mode 100644 src/components/loading-indicator/__snapshots__/loading-indicator.spec.snap.js create mode 100644 src/components/map-container/__snapshots__/map-container.spec.snap.js create mode 100644 src/components/message/__snapshots__/message.spec.snap.js create mode 100644 src/components/option/optgroup/__snapshots__/optgroup.spec.snap.js create mode 100644 src/components/option/option/__snapshots__/option.spec.snap.js create mode 100644 src/components/radio-button/radio-button-group/__snapshots__/radio-button-group.spec.snap.js create mode 100644 src/components/radio-button/radio-button/__snapshots__/radio-button.spec.snap.js create mode 100644 src/components/select/__snapshots__/select.spec.snap.js create mode 100644 src/components/slider/__snapshots__/slider.spec.snap.js create mode 100644 src/components/tabs/tab-group/__snapshots__/tab-group.spec.snap.js create mode 100644 src/components/tag/tag-group/__snapshots__/tag-group.spec.snap.js create mode 100644 src/components/teaser-hero/__snapshots__/teaser-hero.spec.snap.js create mode 100644 src/components/time-input/__snapshots__/time-input.spec.snap.js create mode 100644 src/components/title/__snapshots__/title.spec.snap.js create mode 100644 src/components/toast/__snapshots__/toast.spec.snap.js create mode 100644 src/components/toggle-check/__snapshots__/toggle-check.spec.snap.js create mode 100644 src/components/toggle/toggle/__snapshots__/toggle.spec.snap.js create mode 100644 src/components/tooltip/tooltip-trigger/__snapshots__/tooltip-trigger.spec.snap.js create mode 100644 src/components/tooltip/tooltip/__snapshots__/tooltip.spec.snap.js create mode 100644 src/components/visual-checkbox/__snapshots__/visual-checkbox.spec.snap.js diff --git a/src/components/accordion/__snapshots__/accordion.spec.snap.js b/src/components/accordion/__snapshots__/accordion.spec.snap.js new file mode 100644 index 00000000000..f69dca3cb9d --- /dev/null +++ b/src/components/accordion/__snapshots__/accordion.spec.snap.js @@ -0,0 +1,129 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-accordion renders - Dom"] = +` + + + + + + + + + +`; +/* end snapshot sbb-accordion renders - Dom */ + +snapshots["sbb-accordion renders - ShadowDom"] = +`
+ + +
+`; +/* end snapshot sbb-accordion renders - ShadowDom */ + +snapshots["sbb-accordion A11y tree Chrome"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header 1" + }, + { + "role": "button", + "name": "Header 2" + } + ] +} +

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

+ { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Header 1" + }, + { + "role": "button", + "name": "Header 2" + } + ] +} +

+`; +/* end snapshot sbb-accordion A11y tree Firefox */ + +snapshots["sbb-accordion A11y tree Safari"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header 1" + }, + { + "role": "button", + "name": "Header 2" + } + ] +} +

+`; +/* end snapshot sbb-accordion A11y tree Safari */ + diff --git a/src/components/accordion/accordion.spec.ts b/src/components/accordion/accordion.spec.ts index c52fcfe03e2..946c8e76210 100644 --- a/src/components/accordion/accordion.spec.ts +++ b/src/components/accordion/accordion.spec.ts @@ -1,11 +1,18 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbAccordionElement } from './accordion'; import './accordion'; import '../expansion-panel'; describe('sbb-accordion', () => { - it('renders', async () => { - const root = await fixture(html` + let element: SbbAccordionElement; + + beforeEach(async () => { + element = await fixture(html` Header 1 @@ -17,56 +24,16 @@ describe('sbb-accordion', () => { `); + await waitForLitRender(element); + }); - expect(root).dom.to.be.equal( - ` - - - - - - - - - - - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
- -
- `, - ); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/action-group/__snapshots__/action-group.spec.snap.js b/src/components/action-group/__snapshots__/action-group.spec.snap.js new file mode 100644 index 00000000000..febe259b1dd --- /dev/null +++ b/src/components/action-group/__snapshots__/action-group.spec.snap.js @@ -0,0 +1,130 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-action-group renders renders - Dom"] = +` + + Button + + + Link + + +`; +/* end snapshot sbb-action-group renders renders - Dom */ + +snapshots["sbb-action-group renders renders - ShadowDom"] = +`
+ + +
+`; +/* end snapshot sbb-action-group renders renders - ShadowDom */ + +snapshots["sbb-action-group renders A11y tree Chrome"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Button" + }, + { + "role": "link", + "name": "Link", + "children": [ + { + "role": "link", + "name": "Link" + } + ] + } + ] +} +

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

+ { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Button" + }, + { + "role": "link", + "name": "Link", + "children": [ + { + "role": "link", + "name": "Link", + "value": "https://github.com/lyne-design-system/lyne-components" + } + ] + } + ] +} +

+`; +/* end snapshot sbb-action-group renders A11y tree Firefox */ + +snapshots["sbb-action-group renders A11y tree Safari"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Button" + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Link", + "children": [ + { + "role": "text", + "name": "Link" + } + ] + } + ] + } + ] +} +

+`; +/* end snapshot sbb-action-group renders A11y tree Safari */ + diff --git a/src/components/action-group/action-group.spec.ts b/src/components/action-group/action-group.spec.ts index ef9c0310647..9d10b77e92c 100644 --- a/src/components/action-group/action-group.spec.ts +++ b/src/components/action-group/action-group.spec.ts @@ -2,43 +2,42 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import type { SbbButtonElement } from '../button'; +import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import type { SbbActionGroupElement } from './action-group'; -import '.'; +import './action-group'; +import '../button'; +import '../link'; describe('sbb-action-group', () => { - it('renders', async () => { - const root = await fixture(html` - - Button - - Link - - - `); + describe('renders', () => { + let element: SbbActionGroupElement; - expect(root).dom.to.be.equal( - ` - + beforeEach(async () => { + element = await fixture(html` + Button + href="https://github.com/lyne-design-system/lyne-components" + > Link - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
- -
- `, - ); + `); + await waitForLitRender(element); + }); + + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); describe('property sync', () => { diff --git a/src/components/alert/alert-group/__snapshots__/alert-group.spec.snap.js b/src/components/alert/alert-group/__snapshots__/alert-group.spec.snap.js new file mode 100644 index 00000000000..f83b6bf0a0e --- /dev/null +++ b/src/components/alert/alert-group/__snapshots__/alert-group.spec.snap.js @@ -0,0 +1,158 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-alert-group should render Dom"] = +` + + The rail traffic between Allaman and Morges is interrupted. All trains are cancelled. + + +`; +/* end snapshot sbb-alert-group should render Dom */ + +snapshots["sbb-alert-group should render ShadowDom"] = +`
+

+ + Disruptions + +

+ + +
+`; +/* end snapshot sbb-alert-group should render ShadowDom */ + +snapshots["sbb-alert-group should render A11y tree Chrome"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Disruptions", + "level": 2 + }, + { + "role": "heading", + "name": "Interruption between Genève and Lausanne", + "level": 3 + }, + { + "role": "text", + "name": "The rail traffic between Allaman and Morges is interrupted. All trains are cancelled. " + }, + { + "role": "link", + "name": "Find out more", + "children": [ + { + "role": "link", + "name": "Find out more" + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

+`; +/* end snapshot sbb-alert-group should render A11y tree Chrome */ + +snapshots["sbb-alert-group should render A11y tree Firefox"] = +`

+ { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Disruptions", + "level": 2 + }, + { + "role": "heading", + "name": "Interruption between Genève and Lausanne", + "level": 3 + }, + { + "role": "text leaf", + "name": "The rail traffic between Allaman and Morges is interrupted. All trains are cancelled. " + }, + { + "role": "link", + "name": "Find out more", + "children": [ + { + "role": "link", + "name": "Find out more", + "value": "https://www.sbb.ch/" + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

+`; +/* end snapshot sbb-alert-group should render A11y tree Firefox */ + +snapshots["sbb-alert-group should render A11y tree Safari"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Disruptions" + }, + { + "role": "text", + "name": "Interruption between Genève and Lausanne" + }, + { + "role": "text", + "name": "The rail traffic between Allaman and Morges is interrupted. All trains are cancelled." + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Find out more", + "children": [ + { + "role": "text", + "name": "Find out more" + } + ] + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

+`; +/* end snapshot sbb-alert-group should render A11y tree Safari */ + diff --git a/src/components/alert/alert-group/alert-group.spec.ts b/src/components/alert/alert-group/alert-group.spec.ts index b83dd1fcf28..eb30fa91081 100644 --- a/src/components/alert/alert-group/alert-group.spec.ts +++ b/src/components/alert/alert-group/alert-group.spec.ts @@ -1,42 +1,40 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbAlertGroupElement } from './alert-group'; import './alert-group'; import '../alert'; describe('sbb-alert-group', () => { - it('should render', async () => { - const root = await fixture(html` - - - The rail traffic between Allaman and Morges is interrupted. All trains are cancelled. - - - `); + describe('should render', () => { + let root: SbbAlertGroupElement; - expect(root).dom.to.be.equal( - ` - - + beforeEach(async () => { + root = await fixture(html` + + The rail traffic between Allaman and Morges is interrupted. All trains are cancelled. - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
-

- - Disruptions - -

- -
- `, - ); + `); + await waitForLitRender(root); + }); + + it('Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(root).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); it('should render with slots', async () => { diff --git a/src/components/alert/alert/__snapshots__/alert.spec.snap.js b/src/components/alert/alert/__snapshots__/alert.spec.snap.js new file mode 100644 index 00000000000..f4cb69b98f6 --- /dev/null +++ b/src/components/alert/alert/__snapshots__/alert.spec.snap.js @@ -0,0 +1,247 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-alert should render default properties"] = +`
+
+ + + + + + + + + Interruption + + +

+ + +

+
+ + + + + + +
+
+`; +/* end snapshot sbb-alert should render default properties */ + +snapshots["sbb-alert should render customized properties"] = +`
+
+ + + + + + + + + Interruption + + +

+ + +

+ + Show much more + +
+ + + + + + +
+
+`; +/* end snapshot sbb-alert should render customized properties */ + +snapshots["sbb-alert A11y tree Chrome"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Interruption", + "level": 3 + }, + { + "role": "text", + "name": "Alert content " + }, + { + "role": "link", + "name": "test-a11y-label", + "children": [ + { + "role": "link", + "name": "Find out more" + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

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

+ { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Interruption", + "level": 3 + }, + { + "role": "text leaf", + "name": "Alert content " + }, + { + "role": "link", + "name": "test-a11y-label", + "children": [ + { + "role": "link", + "name": "Find out more", + "value": "https://www.sbb.ch/" + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

+`; +/* end snapshot sbb-alert A11y tree Firefox */ + +snapshots["sbb-alert A11y tree Safari"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Interruption" + }, + { + "role": "text", + "name": "Alert content " + }, + { + "role": "link", + "name": "test-a11y-label", + "children": [ + { + "role": "link", + "name": "Find out more", + "children": [ + { + "role": "text", + "name": "Find out more" + } + ] + } + ] + }, + { + "role": "button", + "name": "Close message" + } + ] +} +

+`; +/* end snapshot sbb-alert A11y tree Safari */ + diff --git a/src/components/alert/alert/alert.e2e.ts b/src/components/alert/alert/alert.e2e.ts index 533606ebbf8..e8ee2c570d9 100644 --- a/src/components/alert/alert/alert.e2e.ts +++ b/src/components/alert/alert/alert.e2e.ts @@ -24,4 +24,12 @@ describe('sbb-alert', () => { await waitForCondition(() => didPresentSpy.events.length === 1); expect(didPresentSpy.count).to.be.equal(1); }); + + it('should hide close button in readonly mode', async () => { + alert = await fixture( + html`Alert content`, + ); + + expect(alert.shadowRoot!.querySelector('.sbb-alert__close-button-wrapper')).to.be.null; + }); }); diff --git a/src/components/alert/alert/alert.spec.ts b/src/components/alert/alert/alert.spec.ts index ecfee4fb0f2..3177967dc94 100644 --- a/src/components/alert/alert/alert.spec.ts +++ b/src/components/alert/alert/alert.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbAlertElement } from './alert'; @@ -14,7 +15,6 @@ describe('sbb-alert', () => { element = await fixture( html`Alert content`, ); - await waitForLitRender(element); expect(element).dom.to.be.equal( @@ -24,36 +24,7 @@ describe('sbb-alert', () => {
`, ); - expect(element).shadowDom.to.be.equal( - ` -
-
- - - - - - - - Interruption - -

- -

-
- - - - -
-
- `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); it('should render customized properties', async () => { @@ -82,46 +53,20 @@ describe('sbb-alert', () => { `, ); - expect(element).shadowDom.to.be.equal( - ` -
-
- - - - - - - - Interruption - -

- -

- - Show much more - -
- - - - -
-
- `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); - it('should hide close button in readonly mode', async () => { - element = await fixture( - html`Alert content`, - ); - - expect(element.shadowRoot!.querySelector('.sbb-alert__close-button-wrapper')).to.be.null; - }); + testA11yTreeSnapshot( + undefined, + html` + + Alert content + + `, + ); }); diff --git a/src/components/autocomplete/__snapshots__/autocomplete.spec.snap.js b/src/components/autocomplete/__snapshots__/autocomplete.spec.snap.js new file mode 100644 index 00000000000..7f868c6a24b --- /dev/null +++ b/src/components/autocomplete/__snapshots__/autocomplete.spec.snap.js @@ -0,0 +1,377 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-autocomplete renders standalone Chrome-Firefox Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-autocomplete renders standalone Chrome-Firefox Dom */ + +snapshots["sbb-autocomplete renders in form field Chrome-Firefox Dom"] = +` + + + + 1 + + + 2 + + + +`; +/* end snapshot sbb-autocomplete renders in form field Chrome-Firefox Dom */ + +snapshots["sbb-autocomplete renders in form field Chrome-Firefox ShadowDom"] = +`
+
+ + +
+ + + + + + + +
+ + +
+
+ + +
+
+ + +
+
+`; +/* end snapshot sbb-autocomplete renders in form field Chrome-Firefox ShadowDom */ + +snapshots["sbb-autocomplete renders in form field A11y tree Chrome"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "combobox", + "name": "", + "autocomplete": "list", + "haspopup": "listbox" + } + ] +} +

+`; +/* end snapshot sbb-autocomplete renders in form field A11y tree Chrome */ + +snapshots["sbb-autocomplete renders standalone Chrome-Firefox ShadowDom"] = +`
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+`; +/* end snapshot sbb-autocomplete renders standalone Chrome-Firefox ShadowDom */ + +snapshots["sbb-autocomplete renders in form field A11y tree Firefox"] = +`

+ { + "role": "document", + "name": "", + "children": [ + { + "role": "statictext", + "name": "​" + }, + { + "role": "combobox", + "name": "", + "autocomplete": "list", + "haspopup": "listbox" + } + ] +} +

+`; +/* end snapshot sbb-autocomplete renders in form field A11y tree Firefox */ + +snapshots["sbb-autocomplete renders standalone Safari Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-autocomplete renders standalone Safari Dom */ + +snapshots["sbb-autocomplete renders standalone Safari ShadowDom"] = +`
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+`; +/* end snapshot sbb-autocomplete renders standalone Safari ShadowDom */ + +snapshots["sbb-autocomplete renders in form field Safari Dom"] = +` + + + + 1 + + + 2 + + + +`; +/* end snapshot sbb-autocomplete renders in form field Safari Dom */ + +snapshots["sbb-autocomplete renders in form field Safari ShadowDom"] = +`
+
+ + +
+ + + + + + + +
+ + +
+
+ + +
+
+ + +
+
+`; +/* end snapshot sbb-autocomplete renders in form field Safari ShadowDom */ + +snapshots["sbb-autocomplete renders in form field A11y tree Safari"] = +`

+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "combobox", + "name": "", + "autocomplete": "list", + "haspopup": "listbox" + } + ] +} +

+`; +/* end snapshot sbb-autocomplete renders in form field A11y tree Safari */ + diff --git a/src/components/autocomplete/autocomplete.spec.ts b/src/components/autocomplete/autocomplete.spec.ts index 1a0d75976e4..27c4d958151 100644 --- a/src/components/autocomplete/autocomplete.spec.ts +++ b/src/components/autocomplete/autocomplete.spec.ts @@ -1,96 +1,90 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { isSafari } from '../core/dom'; +import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; +import type { SbbFormFieldElement } from '../form-field'; + +import type { SbbAutocompleteElement } from './autocomplete'; import '../form-field'; import '../option'; import './autocomplete'; -import { isSafari } from '../core/dom'; describe('sbb-autocomplete', () => { - it('renders standalone', async () => { - await fixture(html` -
- - - 1 - 2 - - `); - const elem = document.querySelector('sbb-autocomplete'); - const listboxAttr = 'id="sbb-autocomplete-1" role="listbox"'; - - expect(elem).dom.to.be.equal(` - - 1 - 2 - - `); - expect(elem).shadowDom.to.be.equal(` -
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- `); - }); + describe('renders standalone', async () => { + let elem: SbbAutocompleteElement; - it('renders in form field', async () => { - const root = await fixture(html` - - - + beforeEach(async () => { + await fixture(html` +
+ + 1 2 -
- `); - const elem = root.querySelector('sbb-autocomplete'); - const listboxAttr = 'id="sbb-autocomplete-4" role="listbox"'; + `); + elem = document.querySelector('sbb-autocomplete')!; + await waitForLitRender(elem); + }); - expect(root).dom.to.be.equal(` - - - - 1 - 2 - - - `); - expect(elem).shadowDom.to.equal(` -
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
- `); + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + }); + + describe('renders in form field', async () => { + let root: SbbFormFieldElement; + + beforeEach(async () => { + root = await fixture(html` + + + + 1 + 2 + + + `); + await waitForLitRender(root); + }); + + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(root).shadowDom.to.be.equalSnapshot(); + }); + }); + + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(root).shadowDom.to.be.equalSnapshot(); + }); + }); + + testA11yTreeSnapshot(); }); }); diff --git a/src/components/breadcrumb/breadcrumb-group/__snapshots__/breadcrumb-group.spec.snap.js b/src/components/breadcrumb/breadcrumb-group/__snapshots__/breadcrumb-group.spec.snap.js index 98925817665..cf2a31c8584 100644 --- a/src/components/breadcrumb/breadcrumb-group/__snapshots__/breadcrumb-group.spec.snap.js +++ b/src/components/breadcrumb/breadcrumb-group/__snapshots__/breadcrumb-group.spec.snap.js @@ -1,7 +1,44 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["sbb-breadcrumb-group renders"] = +snapshots["sbb-breadcrumb-group renders - Dom"] = +` + + + + One + + + Two + + +`; +/* end snapshot sbb-breadcrumb-group renders - Dom */ + +snapshots["sbb-breadcrumb-group renders - ShadowDom"] = `
  1. @@ -37,5 +74,146 @@ snapshots["sbb-breadcrumb-group renders"] = `; -/* end snapshot sbb-breadcrumb-group renders */ +/* end snapshot sbb-breadcrumb-group renders - ShadowDom */ + +snapshots["sbb-breadcrumb-group A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "" + } + ] + }, + { + "role": "link", + "name": "One", + "children": [ + { + "role": "link", + "name": "One" + } + ] + }, + { + "role": "link", + "name": "Two", + "children": [ + { + "role": "link", + "name": "Two" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-breadcrumb-group A11y tree Chrome */ + +snapshots["sbb-breadcrumb-group A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "", + "value": "http://localhost:8000/" + } + ] + }, + { + "role": "link", + "name": "One", + "children": [ + { + "role": "link", + "name": "One", + "value": "http://localhost:8000/one" + } + ] + }, + { + "role": "link", + "name": "Two", + "children": [ + { + "role": "link", + "name": "Two", + "value": "http://localhost:8000/one" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-breadcrumb-group A11y tree Firefox */ + +snapshots["sbb-breadcrumb-group A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "" + } + ] + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "One", + "children": [ + { + "role": "text", + "name": "One" + } + ] + } + ] + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Two", + "children": [ + { + "role": "text", + "name": "Two" + } + ] + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-breadcrumb-group A11y tree Safari */ diff --git a/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts b/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts index 3adb44d2067..5734d3cc676 100644 --- a/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts +++ b/src/components/breadcrumb/breadcrumb-group/breadcrumb-group.spec.ts @@ -1,34 +1,34 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbBreadcrumbGroupElement } from './breadcrumb-group'; import '../breadcrumb'; import './breadcrumb-group'; -import { waitForLitRender } from '../../core/testing'; describe('sbb-breadcrumb-group', () => { - it('renders', async () => { - const root = await fixture(html` + let root: SbbBreadcrumbGroupElement; + + beforeEach(async () => { + root = await fixture(html` One Two `); - await waitForLitRender(root); + }); - expect(root).dom.to.be.equal(` - - - - One - - - Two - - - `); + it('renders - Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + it('renders - ShadowDom', async () => { await expect(root).shadowDom.to.equalSnapshot(); }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/breadcrumb/breadcrumb/__snapshots__/breadcrumb.spec.snap.js b/src/components/breadcrumb/breadcrumb/__snapshots__/breadcrumb.spec.snap.js index 9de65f093b8..484b92e69c5 100644 --- a/src/components/breadcrumb/breadcrumb/__snapshots__/breadcrumb.spec.snap.js +++ b/src/components/breadcrumb/breadcrumb/__snapshots__/breadcrumb.spec.snap.js @@ -89,3 +89,76 @@ snapshots["sbb-breadcrumb renders as span if no href is provided"] = `; /* end snapshot sbb-breadcrumb renders as span if no href is provided */ +snapshots["sbb-breadcrumb A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "Breadcrumb", + "children": [ + { + "role": "link", + "name": "Breadcrumb" + } + ] + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "link", + "name": "Breadcrumb", + "children": [ + { + "role": "link", + "name": "Breadcrumb", + "value": "http://localhost:8000/test" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-breadcrumb A11y tree Firefox */ + +snapshots["sbb-breadcrumb A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Breadcrumb", + "children": [ + { + "role": "text", + "name": "Breadcrumb" + } + ] + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-breadcrumb A11y tree Safari */ + diff --git a/src/components/breadcrumb/breadcrumb/breadcrumb.spec.ts b/src/components/breadcrumb/breadcrumb/breadcrumb.spec.ts index 6da7c4ac3ff..fa2b4ece570 100644 --- a/src/components/breadcrumb/breadcrumb/breadcrumb.spec.ts +++ b/src/components/breadcrumb/breadcrumb/breadcrumb.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './breadcrumb'; @@ -33,8 +34,8 @@ describe('sbb-breadcrumb', () => { const root = await fixture(html` `); - await waitForLitRender(root); + expect(root).dom.to.be.equal(` { const root = await fixture(html` Home `); - await waitForLitRender(root); + expect(root).dom.to.be.equal(` { await expect(root).shadowDom.to.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html` Breadcrumb `); }); diff --git a/src/components/calendar/__snapshots__/calendar.spec.snap.js b/src/components/calendar/__snapshots__/calendar.spec.snap.js new file mode 100644 index 00000000000..fe036caec11 --- /dev/null +++ b/src/components/calendar/__snapshots__/calendar.spec.snap.js @@ -0,0 +1,1320 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-calendar renders"] = +`
    +
    + + +
    + + + January 2023 + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + Monday + + + + + Tuesday + + + + + Wednesday + + + + + Thursday + + + + + Friday + + + + + Saturday + + + + + Sunday + + +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +
    +
    +`; +/* end snapshot sbb-calendar renders */ + +snapshots["sbb-calendar A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Change to the previous month" + }, + { + "role": "button", + "name": "Choose year and month January 2023" + }, + { + "role": "text", + "name": "January 2023" + }, + { + "role": "button", + "name": "Change to the next month" + }, + { + "role": "text", + "name": "Monday" + }, + { + "role": "text", + "name": "Tuesday" + }, + { + "role": "text", + "name": "Wednesday" + }, + { + "role": "text", + "name": "Thursday" + }, + { + "role": "text", + "name": "Friday" + }, + { + "role": "text", + "name": "Saturday" + }, + { + "role": "text", + "name": "Sunday" + }, + { + "role": "button", + "name": "January 1, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 2, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 3, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 4, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 5, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 6, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 7, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 8, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 9, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 10, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 11, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 12, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 13, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 14, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 15, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 16, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 17, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 18, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 19, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 20, 2023", + "pressed": true + }, + { + "role": "button", + "name": "January 21, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 22, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 23, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 24, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 25, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 26, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 27, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 28, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 29, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 30, 2023", + "pressed": false + }, + { + "role": "button", + "name": "January 31, 2023", + "pressed": false + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Change to the previous month" + }, + { + "role": "button", + "name": "Choose year and month January 2023" + }, + { + "role": "text leaf", + "name": "January 2023 " + }, + { + "role": "button", + "name": "Change to the next month" + }, + { + "role": "text leaf", + "name": "Monday" + }, + { + "role": "text leaf", + "name": "Tuesday" + }, + { + "role": "text leaf", + "name": "Wednesday" + }, + { + "role": "text leaf", + "name": "Thursday" + }, + { + "role": "text leaf", + "name": "Friday" + }, + { + "role": "text leaf", + "name": "Saturday" + }, + { + "role": "text leaf", + "name": "Sunday" + }, + { + "role": "toggle button", + "name": "January 1, 2023" + }, + { + "role": "toggle button", + "name": "January 2, 2023" + }, + { + "role": "toggle button", + "name": "January 3, 2023" + }, + { + "role": "toggle button", + "name": "January 4, 2023" + }, + { + "role": "toggle button", + "name": "January 5, 2023" + }, + { + "role": "toggle button", + "name": "January 6, 2023" + }, + { + "role": "toggle button", + "name": "January 7, 2023" + }, + { + "role": "toggle button", + "name": "January 8, 2023" + }, + { + "role": "toggle button", + "name": "January 9, 2023" + }, + { + "role": "toggle button", + "name": "January 10, 2023" + }, + { + "role": "toggle button", + "name": "January 11, 2023" + }, + { + "role": "toggle button", + "name": "January 12, 2023" + }, + { + "role": "toggle button", + "name": "January 13, 2023" + }, + { + "role": "toggle button", + "name": "January 14, 2023" + }, + { + "role": "toggle button", + "name": "January 15, 2023" + }, + { + "role": "toggle button", + "name": "January 16, 2023" + }, + { + "role": "toggle button", + "name": "January 17, 2023" + }, + { + "role": "toggle button", + "name": "January 18, 2023" + }, + { + "role": "toggle button", + "name": "January 19, 2023" + }, + { + "role": "toggle button", + "name": "January 20, 2023", + "pressed": true + }, + { + "role": "toggle button", + "name": "January 21, 2023" + }, + { + "role": "toggle button", + "name": "January 22, 2023" + }, + { + "role": "toggle button", + "name": "January 23, 2023" + }, + { + "role": "toggle button", + "name": "January 24, 2023" + }, + { + "role": "toggle button", + "name": "January 25, 2023" + }, + { + "role": "toggle button", + "name": "January 26, 2023" + }, + { + "role": "toggle button", + "name": "January 27, 2023" + }, + { + "role": "toggle button", + "name": "January 28, 2023" + }, + { + "role": "toggle button", + "name": "January 29, 2023" + }, + { + "role": "toggle button", + "name": "January 30, 2023" + }, + { + "role": "toggle button", + "name": "January 31, 2023" + } + ] +} +

    +`; +/* end snapshot sbb-calendar A11y tree Firefox */ + +snapshots["sbb-calendar A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Change to the previous month" + }, + { + "role": "button", + "name": "Choose year and month January 2023" + }, + { + "role": "text", + "name": "January 2023" + }, + { + "role": "button", + "name": "Change to the next month" + }, + { + "role": "text", + "name": "Monday" + }, + { + "role": "text", + "name": "Tuesday" + }, + { + "role": "text", + "name": "Wednesday" + }, + { + "role": "text", + "name": "Thursday" + }, + { + "role": "text", + "name": "Friday" + }, + { + "role": "text", + "name": "Saturday" + }, + { + "role": "text", + "name": "Sunday" + }, + { + "role": "button", + "name": "January 1, 2023" + }, + { + "role": "button", + "name": "January 2, 2023" + }, + { + "role": "button", + "name": "January 3, 2023" + }, + { + "role": "button", + "name": "January 4, 2023" + }, + { + "role": "button", + "name": "January 5, 2023" + }, + { + "role": "button", + "name": "January 6, 2023" + }, + { + "role": "button", + "name": "January 7, 2023" + }, + { + "role": "button", + "name": "January 8, 2023" + }, + { + "role": "button", + "name": "January 9, 2023" + }, + { + "role": "button", + "name": "January 10, 2023" + }, + { + "role": "button", + "name": "January 11, 2023" + }, + { + "role": "button", + "name": "January 12, 2023" + }, + { + "role": "button", + "name": "January 13, 2023" + }, + { + "role": "button", + "name": "January 14, 2023" + }, + { + "role": "button", + "name": "January 15, 2023" + }, + { + "role": "button", + "name": "January 16, 2023" + }, + { + "role": "button", + "name": "January 17, 2023" + }, + { + "role": "button", + "name": "January 18, 2023" + }, + { + "role": "button", + "name": "January 19, 2023" + }, + { + "role": "button", + "name": "January 20, 2023" + }, + { + "role": "button", + "name": "January 21, 2023" + }, + { + "role": "button", + "name": "January 22, 2023" + }, + { + "role": "button", + "name": "January 23, 2023" + }, + { + "role": "button", + "name": "January 24, 2023" + }, + { + "role": "button", + "name": "January 25, 2023" + }, + { + "role": "button", + "name": "January 26, 2023" + }, + { + "role": "button", + "name": "January 27, 2023" + }, + { + "role": "button", + "name": "January 28, 2023" + }, + { + "role": "button", + "name": "January 29, 2023" + }, + { + "role": "button", + "name": "January 30, 2023" + }, + { + "role": "button", + "name": "January 31, 2023" + }, + { + "role": "text", + "name": "Monday" + }, + { + "role": "button", + "name": "January 2, 2023" + }, + { + "role": "button", + "name": "January 9, 2023" + }, + { + "role": "button", + "name": "January 16, 2023" + }, + { + "role": "button", + "name": "January 23, 2023" + }, + { + "role": "button", + "name": "January 30, 2023" + }, + { + "role": "text", + "name": "Tuesday" + }, + { + "role": "button", + "name": "January 3, 2023" + }, + { + "role": "button", + "name": "January 10, 2023" + }, + { + "role": "button", + "name": "January 17, 2023" + }, + { + "role": "button", + "name": "January 24, 2023" + }, + { + "role": "button", + "name": "January 31, 2023" + }, + { + "role": "text", + "name": "Wednesday" + }, + { + "role": "button", + "name": "January 4, 2023" + }, + { + "role": "button", + "name": "January 11, 2023" + }, + { + "role": "button", + "name": "January 18, 2023" + }, + { + "role": "button", + "name": "January 25, 2023" + }, + { + "role": "text", + "name": "Thursday" + }, + { + "role": "button", + "name": "January 5, 2023" + }, + { + "role": "button", + "name": "January 12, 2023" + }, + { + "role": "button", + "name": "January 19, 2023" + }, + { + "role": "button", + "name": "January 26, 2023" + }, + { + "role": "text", + "name": "Friday" + }, + { + "role": "button", + "name": "January 6, 2023" + }, + { + "role": "button", + "name": "January 13, 2023" + }, + { + "role": "button", + "name": "January 20, 2023" + }, + { + "role": "button", + "name": "January 27, 2023" + }, + { + "role": "text", + "name": "Saturday" + }, + { + "role": "button", + "name": "January 7, 2023" + }, + { + "role": "button", + "name": "January 14, 2023" + }, + { + "role": "button", + "name": "January 21, 2023" + }, + { + "role": "button", + "name": "January 28, 2023" + }, + { + "role": "text", + "name": "Sunday" + }, + { + "role": "button", + "name": "January 1, 2023" + }, + { + "role": "button", + "name": "January 8, 2023" + }, + { + "role": "button", + "name": "January 15, 2023" + }, + { + "role": "button", + "name": "January 22, 2023" + }, + { + "role": "button", + "name": "January 29, 2023" + }, + { + "role": "text", + "name": "Monday" + }, + { + "role": "text", + "name": "Tuesday" + }, + { + "role": "text", + "name": "Wednesday" + }, + { + "role": "text", + "name": "Thursday" + }, + { + "role": "text", + "name": "Friday" + }, + { + "role": "text", + "name": "Saturday" + }, + { + "role": "text", + "name": "Sunday" + } + ] +} +

    +`; +/* end snapshot sbb-calendar A11y tree Safari */ + diff --git a/src/components/calendar/calendar.spec.ts b/src/components/calendar/calendar.spec.ts index e99063cb744..2f607267344 100644 --- a/src/components/calendar/calendar.spec.ts +++ b/src/components/calendar/calendar.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './calendar'; import '../button'; @@ -14,242 +15,12 @@ describe('sbb-calendar', () => { data-now="1672790400000" >`, ); - await waitForLitRender(root); expect(root).dom.to.be.equal( ``, ); - expect(root).shadowDom.to.be.equal( - ` -
    -
    - -
    - - - January 2023 - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Monday - - - Tuesday - - - Wednesday - - - Thursday - - - Friday - - - Saturday - - - Sunday - -
    - -
    - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - -
    -
    -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with min and max', async () => { @@ -287,4 +58,12 @@ describe('sbb-calendar', () => { expect(firstDisabledMaxDate).to.have.attribute('disabled'); expect(firstDisabledMaxDate).to.have.attribute('aria-disabled', 'true'); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/card/card-badge/__snapshots__/card-badge.spec.snap.js b/src/components/card/card-badge/__snapshots__/card-badge.spec.snap.js new file mode 100644 index 00000000000..ca05f6439fb --- /dev/null +++ b/src/components/card/card-badge/__snapshots__/card-badge.spec.snap.js @@ -0,0 +1,80 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-card-badge renders - Dom"] = +` + Black Friday Special + +`; +/* end snapshot sbb-card-badge renders - Dom */ + +snapshots["sbb-card-badge renders - ShadowDom"] = +` + + + + + + + + +`; +/* end snapshot sbb-card-badge renders - ShadowDom */ + +snapshots["sbb-card-badge A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Black Friday Special" + } + ] +} +

    +`; +/* end snapshot sbb-card-badge A11y tree Chrome */ + +snapshots["sbb-card-badge A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Black Friday Special" + } + ] +} +

    +`; +/* end snapshot sbb-card-badge A11y tree Firefox */ + +snapshots["sbb-card-badge A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Black Friday Special" + } + ] +} +

    +`; +/* end snapshot sbb-card-badge A11y tree Safari */ + diff --git a/src/components/card/card-badge/card-badge.spec.ts b/src/components/card/card-badge/card-badge.spec.ts index b84980afe8a..7f4e89bf238 100644 --- a/src/components/card/card-badge/card-badge.spec.ts +++ b/src/components/card/card-badge/card-badge.spec.ts @@ -1,28 +1,25 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbCardBadgeElement } from './card-badge'; import './card-badge'; describe('sbb-card-badge', () => { - it('renders', async () => { - const root = await fixture(html``); + let element: SbbCardBadgeElement; + + beforeEach(async () => { + element = await fixture(html`Black Friday Special`); + }); - expect(root).dom.to.be.equal( - ` - - - `, - ); - expect(root).shadowDom.to.be.equal( - ` - - - - - - - - - `, - ); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/card/card/__snapshots__/card.spec.snap.js b/src/components/card/card/__snapshots__/card.spec.snap.js new file mode 100644 index 00000000000..6536d56fd2f --- /dev/null +++ b/src/components/card/card/__snapshots__/card.spec.snap.js @@ -0,0 +1,148 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-card should render with sbb-card-badge - Dom"] = +` +

    + Title +

    + Content text + + + % + + + from CHF + + + 19.99 + + +
    +`; +/* end snapshot sbb-card should render with sbb-card-badge - Dom */ + +snapshots["sbb-card should render with sbb-card-badge - ShadowDom"] = +` + + + + + + + + + + + +`; +/* end snapshot sbb-card should render with sbb-card-badge - ShadowDom */ + +snapshots["sbb-card A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title", + "level": 2 + }, + { + "role": "text", + "name": "Content text" + }, + { + "role": "text", + "name": "%" + }, + { + "role": "text", + "name": "from CHF" + }, + { + "role": "text", + "name": "19.99" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title", + "level": 2 + }, + { + "role": "text leaf", + "name": "Content text " + }, + { + "role": "text leaf", + "name": "%" + }, + { + "role": "text leaf", + "name": "from CHF" + }, + { + "role": "text leaf", + "name": "19.99" + } + ] +} +

    +`; +/* end snapshot sbb-card A11y tree Firefox */ + +snapshots["sbb-card A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title", + "level": 2 + }, + { + "role": "text", + "name": "Content text" + }, + { + "role": "text", + "name": "%" + }, + { + "role": "text", + "name": "from CHF" + }, + { + "role": "text", + "name": "19.99" + } + ] +} +

    +`; +/* end snapshot sbb-card A11y tree Safari */ + diff --git a/src/components/card/card/card.e2e.ts b/src/components/card/card/card.e2e.ts index 599aa2ffa1c..c663b82c635 100644 --- a/src/components/card/card/card.e2e.ts +++ b/src/components/card/card/card.e2e.ts @@ -31,28 +31,6 @@ describe('sbb-card', () => { ).getPropertyValue('display'), ).not.to.be.equal('none'); expect(element).to.have.attribute('data-has-card-badge'); - expect(element).dom.to.be.equal(` - -

    Title

    - Content text - - % - from CHF - 19.99 - -
    - `); - expect(element).shadowDom.to.be.equal(` - - - - - - - - - - `); }); it('should render without sbb-card-badge', async () => { @@ -70,4 +48,20 @@ describe('sbb-card', () => { ).to.be.equal('none'); expect(element).not.to.have.attribute('data-has-card-badge'); }); + + it('should not render sbb-card-badge for small sizes', async () => { + const root = await fixture( + html` +

    Title

    + Content text + + % + from CHF + 19.99 + +
    `, + ); + + expect(root.shadowRoot!.querySelector('.sbb-card__badge-wrapper')).not.to.be.ok; + }); }); diff --git a/src/components/card/card/card.spec.ts b/src/components/card/card/card.spec.ts index 7b1c5b21fce..67f9f2aa2ec 100644 --- a/src/components/card/card/card.spec.ts +++ b/src/components/card/card/card.spec.ts @@ -1,16 +1,20 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbCardElement } from './card'; import './card'; import '../card-badge'; -const cardBadgeWrapperSelector = '.sbb-card__badge-wrapper'; - describe('sbb-card', () => { - it('should not render sbb-card-badge for small sizes', async () => { + let element: SbbCardElement; + + beforeEach(async () => { // Note: for easier testing, we add the slot="badge" // to which would not be needed in real. - const root = await fixture( - html` + element = await fixture(html` +

    Title

    Content text @@ -18,9 +22,17 @@ describe('sbb-card', () => { from CHF 19.99 -
    `, - ); +
    + `); + }); + + it('should render with sbb-card-badge - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); - expect(root.shadowRoot!.querySelector(cardBadgeWrapperSelector)).not.to.be.ok; + it('should render with sbb-card-badge - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/checkbox/checkbox-group/__snapshots__/checkbox-group.spec.snap.js b/src/components/checkbox/checkbox-group/__snapshots__/checkbox-group.spec.snap.js new file mode 100644 index 00000000000..3d04b3f57b8 --- /dev/null +++ b/src/components/checkbox/checkbox-group/__snapshots__/checkbox-group.spec.snap.js @@ -0,0 +1,141 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-checkbox-group renders - ShadowDom"] = +`
    + + +
    +
    + + +
    +`; +/* end snapshot sbb-checkbox-group renders - ShadowDom */ + +snapshots["sbb-checkbox-group renders - Dom"] = +` + + Label 1 + + + Label 2 + + + Label 3 + + +`; +/* end snapshot sbb-checkbox-group renders - Dom */ + +snapshots["sbb-checkbox-group A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label 1", + "checked": false + }, + { + "role": "checkbox", + "name": "​ Label 2", + "checked": false + }, + { + "role": "checkbox", + "name": "​ Label 3", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-checkbox-group A11y tree Chrome */ + +snapshots["sbb-checkbox-group A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label 1" + }, + { + "role": "checkbox", + "name": "​ Label 2" + }, + { + "role": "checkbox", + "name": "​ Label 3" + } + ] +} +

    +`; +/* end snapshot sbb-checkbox-group A11y tree Firefox */ + +snapshots["sbb-checkbox-group A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label 1", + "checked": false + }, + { + "role": "checkbox", + "name": "​ Label 2", + "checked": false + }, + { + "role": "checkbox", + "name": "​ Label 3", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-checkbox-group A11y tree Safari */ + diff --git a/src/components/checkbox/checkbox-group/checkbox-group.spec.ts b/src/components/checkbox/checkbox-group/checkbox-group.spec.ts index 5c7fe969199..e364947114b 100644 --- a/src/components/checkbox/checkbox-group/checkbox-group.spec.ts +++ b/src/components/checkbox/checkbox-group/checkbox-group.spec.ts @@ -1,35 +1,32 @@ -import './checkbox-group'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbCheckboxGroupElement } from './checkbox-group'; +import './checkbox-group'; +import '../checkbox'; + describe('sbb-checkbox-group', () => { - it('renders', async () => { - const root = await fixture(html` + let element: SbbCheckboxGroupElement; + + beforeEach(async () => { + element = await fixture(html` Label 1 Label 2 Label 3 `); + }); - expect(root).dom.to.be.equal( - ` - - Label 1 - Label 2 - Label 3 - - `, - ); - expect(root).shadowDom.to.be.equal(` -
    - -
    -
    - - -
    - `); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/checkbox/checkbox/__snapshots__/checkbox.spec.snap.js b/src/components/checkbox/checkbox/__snapshots__/checkbox.spec.snap.js index 6e701468ab3..d5f4803ba25 100644 --- a/src/components/checkbox/checkbox/__snapshots__/checkbox.spec.snap.js +++ b/src/components/checkbox/checkbox/__snapshots__/checkbox.spec.snap.js @@ -172,3 +172,104 @@ snapshots["sbb-checkbox icon position with slotted icon"] = `; /* end snapshot sbb-checkbox icon position with slotted icon */ +snapshots["sbb-checkbox Unchecked - A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Unchecked - A11y tree Chrome */ + +snapshots["sbb-checkbox Checked - A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Checked - A11y tree Chrome */ + +snapshots["sbb-checkbox Unchecked - A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label" + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Unchecked - A11y tree Firefox */ + +snapshots["sbb-checkbox Checked - A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Checked - A11y tree Firefox */ + +snapshots["sbb-checkbox Unchecked - A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Unchecked - A11y tree Safari */ + +snapshots["sbb-checkbox Checked - A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​ Label", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-checkbox Checked - A11y tree Safari */ + diff --git a/src/components/checkbox/checkbox/checkbox.spec.ts b/src/components/checkbox/checkbox/checkbox.spec.ts index 9ccd5da2210..ae88216ef59 100644 --- a/src/components/checkbox/checkbox/checkbox.spec.ts +++ b/src/components/checkbox/checkbox/checkbox.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './checkbox'; @@ -96,4 +97,8 @@ describe('sbb-checkbox', () => { await expect(root).shadowDom.to.be.equalSnapshot(); }); }); + + testA11yTreeSnapshot('Unchecked - A11y tree', html`Label`); + + testA11yTreeSnapshot('Checked - A11y tree', html`Label`); }); diff --git a/src/components/chip/__snapshots__/chip.spec.snap.js b/src/components/chip/__snapshots__/chip.spec.snap.js new file mode 100644 index 00000000000..8b154609289 --- /dev/null +++ b/src/components/chip/__snapshots__/chip.spec.snap.js @@ -0,0 +1,71 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-chip renders - Dom"] = +` + Label + +`; +/* end snapshot sbb-chip renders - Dom */ + +snapshots["sbb-chip renders - ShadowDom"] = +` + + + + + +`; +/* end snapshot sbb-chip renders - ShadowDom */ + +snapshots["sbb-chip A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Label" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Label" + } + ] +} +

    +`; +/* end snapshot sbb-chip A11y tree Firefox */ + +snapshots["sbb-chip A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Label" + } + ] +} +

    +`; +/* end snapshot sbb-chip A11y tree Safari */ + diff --git a/src/components/chip/chip.spec.ts b/src/components/chip/chip.spec.ts index 452f2d5324c..f267b6fda45 100644 --- a/src/components/chip/chip.spec.ts +++ b/src/components/chip/chip.spec.ts @@ -1,19 +1,25 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbChipElement } from './chip'; import './chip'; describe('sbb-chip', () => { - it('renders', async () => { - const root: Element = await fixture(html`Label`); + let element: SbbChipElement; + + beforeEach(async () => { + element = await fixture(html`Label`); + }); - expect(root).dom.to.be.equal(`Label`); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); - expect(root).shadowDom.to.be.equal(` - - - - - - `); + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/clock/__snapshots__/clock.spec.snap.js b/src/components/clock/__snapshots__/clock.spec.snap.js new file mode 100644 index 00000000000..b19b2891c58 --- /dev/null +++ b/src/components/clock/__snapshots__/clock.spec.snap.js @@ -0,0 +1,64 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-clock renders"] = +`
    + + + + + + + + +
    +`; +/* end snapshot sbb-clock renders */ + +snapshots["sbb-clock renders with a fixed time"] = +`
    + + + + + + + + +
    +`; +/* end snapshot sbb-clock renders with a fixed time */ + +snapshots["sbb-clock A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-clock A11y tree Firefox */ + +snapshots["sbb-clock A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-clock A11y tree Safari */ + diff --git a/src/components/clock/clock.spec.ts b/src/components/clock/clock.spec.ts index 629bff5723d..df3613c69a7 100644 --- a/src/components/clock/clock.spec.ts +++ b/src/components/clock/clock.spec.ts @@ -1,6 +1,8 @@ import { assert, expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import { SbbClockElement } from './clock'; describe('sbb-clock', () => { @@ -12,16 +14,7 @@ describe('sbb-clock', () => { expect(element).dom.to.be.equal(``); - expect(element).shadowDom.to.be.equal( - ` -
    - - - - -
    - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); it('renders with a fixed time', async () => { @@ -30,35 +23,8 @@ describe('sbb-clock', () => { expect(element).to.have.attribute('data-initialized'); - expect(element).shadowDom.to.be.equal(` -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -`); + await expect(element).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/datepicker/datepicker-next-day/__snapshots__/datepicker-next-day.spec.snap.js b/src/components/datepicker/datepicker-next-day/__snapshots__/datepicker-next-day.spec.snap.js index ba1fde6d468..53c5d2d594b 100644 --- a/src/components/datepicker/datepicker-next-day/__snapshots__/datepicker-next-day.spec.snap.js +++ b/src/components/datepicker/datepicker-next-day/__snapshots__/datepicker-next-day.spec.snap.js @@ -14,3 +14,67 @@ snapshots["sbb-datepicker-next-day renders"] = `; /* end snapshot sbb-datepicker-next-day renders */ +snapshots["sbb-datepicker-next-day renders with connected datepicker"] = +` + +`; +/* end snapshot sbb-datepicker-next-day renders with connected datepicker */ + +snapshots["sbb-datepicker-next-day A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Next day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-next-day A11y tree Chrome */ + +snapshots["sbb-datepicker-next-day A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Next day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-next-day A11y tree Firefox */ + +snapshots["sbb-datepicker-next-day A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Next day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-next-day A11y tree Safari */ + diff --git a/src/components/datepicker/datepicker-next-day/datepicker-next-day.spec.ts b/src/components/datepicker/datepicker-next-day/datepicker-next-day.spec.ts index 54b9e61c3d5..1430433e673 100644 --- a/src/components/datepicker/datepicker-next-day/datepicker-next-day.spec.ts +++ b/src/components/datepicker/datepicker-next-day/datepicker-next-day.spec.ts @@ -1,6 +1,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbFormFieldElement } from '../../form-field'; import type { SbbDatepickerNextDayElement } from './datepicker-next-day'; @@ -34,16 +35,8 @@ describe('sbb-datepicker-next-day', () => { const element: SbbDatepickerNextDayElement = page.querySelector('sbb-datepicker-next-day')!; - expect(element).dom.to.be.equal(` - - - `); + + await expect(element).dom.to.be.equalSnapshot(); expect(element).shadowDom.to.be.equal(` @@ -79,4 +72,6 @@ describe('sbb-datepicker-next-day', () => { page.querySelector('sbb-datepicker-next-day')!; expect(element).to.have.attribute('data-disabled'); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/datepicker/datepicker-previous-day/__snapshots__/datepicker-previous-day.spec.snap.js b/src/components/datepicker/datepicker-previous-day/__snapshots__/datepicker-previous-day.spec.snap.js index 9fe33d4f1ea..0deee4e6eb3 100644 --- a/src/components/datepicker/datepicker-previous-day/__snapshots__/datepicker-previous-day.spec.snap.js +++ b/src/components/datepicker/datepicker-previous-day/__snapshots__/datepicker-previous-day.spec.snap.js @@ -14,3 +14,67 @@ snapshots["sbb-datepicker-previous-day renders"] = `; /* end snapshot sbb-datepicker-previous-day renders */ +snapshots["sbb-datepicker-previous-day renders with connected datepicker"] = +` + +`; +/* end snapshot sbb-datepicker-previous-day renders with connected datepicker */ + +snapshots["sbb-datepicker-previous-day A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Previous day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-previous-day A11y tree Chrome */ + +snapshots["sbb-datepicker-previous-day A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Previous day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-previous-day A11y tree Firefox */ + +snapshots["sbb-datepicker-previous-day A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Previous day", + "disabled": true + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-previous-day A11y tree Safari */ + diff --git a/src/components/datepicker/datepicker-previous-day/datepicker-previous-day.spec.ts b/src/components/datepicker/datepicker-previous-day/datepicker-previous-day.spec.ts index bc26fd0932e..df85bfd50d8 100644 --- a/src/components/datepicker/datepicker-previous-day/datepicker-previous-day.spec.ts +++ b/src/components/datepicker/datepicker-previous-day/datepicker-previous-day.spec.ts @@ -1,6 +1,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbFormFieldElement } from '../../form-field'; import type { SbbDatepickerPreviousDayElement } from './datepicker-previous-day'; @@ -34,16 +35,8 @@ describe('sbb-datepicker-previous-day', () => { const element: SbbDatepickerPreviousDayElement = page.querySelector('sbb-datepicker-previous-day')!; - expect(element).dom.to.be.equal(` - - - `); + + await expect(element).dom.to.be.equalSnapshot(); expect(element).shadowDom.to.be.equal(` @@ -79,4 +72,9 @@ describe('sbb-datepicker-previous-day', () => { page.querySelector('sbb-datepicker-previous-day')!; expect(element).to.have.attribute('data-disabled'); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/datepicker/datepicker-toggle/__snapshots__/datepicker-toggle.spec.snap.js b/src/components/datepicker/datepicker-toggle/__snapshots__/datepicker-toggle.spec.snap.js new file mode 100644 index 00000000000..53574eaff47 --- /dev/null +++ b/src/components/datepicker/datepicker-toggle/__snapshots__/datepicker-toggle.spec.snap.js @@ -0,0 +1,159 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-datepicker-toggle renders"] = +` + + + + +`; +/* end snapshot sbb-datepicker-toggle renders */ + +snapshots["sbb-datepicker-toggle renders in form-field renders in form-field"] = +` + + + + +`; +/* end snapshot sbb-datepicker-toggle renders in form-field renders in form-field */ + +snapshots["sbb-datepicker-toggle renders in form-field renders in disabled form-field"] = +` + + + + +`; +/* end snapshot sbb-datepicker-toggle renders in form-field renders in disabled form-field */ + +snapshots["sbb-datepicker-toggle renders in form-field renders in form-field with calendar parameters"] = +` + + + + +`; +/* end snapshot sbb-datepicker-toggle renders in form-field renders in form-field with calendar parameters */ + +snapshots["sbb-datepicker-toggle A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Show calendar", + "disabled": true, + "haspopup": "dialog" + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-toggle A11y tree Chrome */ + +snapshots["sbb-datepicker-toggle A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Show calendar", + "disabled": true, + "haspopup": "dialog" + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-toggle A11y tree Firefox */ + +snapshots["sbb-datepicker-toggle A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Show calendar", + "disabled": true, + "haspopup": "dialog" + } + ] +} +

    +`; +/* end snapshot sbb-datepicker-toggle A11y tree Safari */ + diff --git a/src/components/datepicker/datepicker-toggle/datepicker-toggle.spec.ts b/src/components/datepicker/datepicker-toggle/datepicker-toggle.spec.ts index 049c82c0705..21f92a6058e 100644 --- a/src/components/datepicker/datepicker-toggle/datepicker-toggle.spec.ts +++ b/src/components/datepicker/datepicker-toggle/datepicker-toggle.spec.ts @@ -1,6 +1,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbFormFieldElement } from '../../form-field'; import type { SbbDatepickerToggleElement } from './datepicker-toggle'; @@ -13,29 +14,7 @@ describe('sbb-datepicker-toggle', () => { const page = await fixture(html``); expect(page).dom.to.equal(``); - expect(page).shadowDom.to.equal(` - - - - - `); + await expect(page).shadowDom.to.equalSnapshot(); }); describe('renders in form-field', () => { @@ -52,29 +31,7 @@ describe('sbb-datepicker-toggle', () => { expect(element).dom.to.be.equal( ``, ); - expect(element).shadowDom.to.be.equal( - ` - - - - - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); it('renders in disabled form-field', async () => { @@ -90,30 +47,7 @@ describe('sbb-datepicker-toggle', () => { expect(element).dom.to.be.equal( ``, ); - expect(element).shadowDom.to.be.equal( - ` - - - - - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); it('renders in form-field with calendar parameters', async () => { @@ -129,29 +63,9 @@ describe('sbb-datepicker-toggle', () => { expect(element).dom.to.be.equal( ``, ); - expect(element).shadowDom.to.be.equal( - ` - - - - - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/datepicker/datepicker/__snapshots__/datepicker.spec.snap.js b/src/components/datepicker/datepicker/__snapshots__/datepicker.spec.snap.js index dc7008007f6..59f27a48da4 100644 --- a/src/components/datepicker/datepicker/__snapshots__/datepicker.spec.snap.js +++ b/src/components/datepicker/datepicker/__snapshots__/datepicker.spec.snap.js @@ -10,3 +10,96 @@ snapshots["sbb-datepicker renders"] = `; /* end snapshot sbb-datepicker renders */ +snapshots["sbb-datepicker A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "textbox", + "name": "DD.MM.YYYY" + }, + { + "role": "button", + "name": "Previous day", + "disabled": true + }, + { + "role": "button", + "name": "Next day", + "disabled": true + }, + { + "role": "button", + "name": "Show calendar", + "haspopup": "dialog" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "textbox", + "name": "DD.MM.YYYY" + }, + { + "role": "button", + "name": "Previous day", + "disabled": true + }, + { + "role": "button", + "name": "Next day", + "disabled": true + }, + { + "role": "button", + "name": "Show calendar", + "haspopup": "dialog" + } + ] +} +

    +`; +/* end snapshot sbb-datepicker A11y tree Firefox */ + +snapshots["sbb-datepicker A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "textbox", + "name": "DD.MM.YYYY" + }, + { + "role": "button", + "name": "Previous day", + "disabled": true + }, + { + "role": "button", + "name": "Next day", + "disabled": true + }, + { + "role": "button", + "name": "Show calendar", + "haspopup": "dialog" + } + ] +} +

    +`; +/* end snapshot sbb-datepicker A11y tree Safari */ + diff --git a/src/components/datepicker/datepicker/datepicker.spec.ts b/src/components/datepicker/datepicker/datepicker.spec.ts index 4ee4819897e..21eecccf31b 100644 --- a/src/components/datepicker/datepicker/datepicker.spec.ts +++ b/src/components/datepicker/datepicker/datepicker.spec.ts @@ -3,6 +3,7 @@ import { html } from 'lit/static-html.js'; import { NativeDateAdapter } from '../../core/datetime'; import { findInput } from '../../core/dom'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbFormFieldElement } from '../../form-field'; import type { SbbDatepickerNextDayElement, SbbDatepickerPreviousDayElement } from '../index'; @@ -14,6 +15,9 @@ import { findNextAvailableDate, isDateAvailable, } from './datepicker'; +import '../datepicker-next-day'; +import '../datepicker-previous-day'; +import '../datepicker-toggle'; describe('sbb-datepicker', () => { it('renders', async () => { @@ -22,6 +26,19 @@ describe('sbb-datepicker', () => { expect(root).dom.to.be.equal(``); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html` + + + + + + + + `, + ); }); describe('getDatePicker', () => { diff --git a/src/components/dialog/__snapshots__/dialog.spec.snap.js b/src/components/dialog/__snapshots__/dialog.spec.snap.js index 47a26582569..4106207d37a 100644 --- a/src/components/dialog/__snapshots__/dialog.spec.snap.js +++ b/src/components/dialog/__snapshots__/dialog.spec.snap.js @@ -53,3 +53,33 @@ snapshots["sbb-dialog renders"] = `; /* end snapshot sbb-dialog renders */ +snapshots["sbb-dialog A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-dialog A11y tree Firefox */ + +snapshots["sbb-dialog A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-dialog A11y tree Safari */ + diff --git a/src/components/dialog/dialog.spec.ts b/src/components/dialog/dialog.spec.ts index 065cecf7f4b..896b3c6d1c1 100644 --- a/src/components/dialog/dialog.spec.ts +++ b/src/components/dialog/dialog.spec.ts @@ -1,6 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import '.'; describe('sbb-dialog', () => { @@ -11,4 +13,6 @@ describe('sbb-dialog', () => { await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/divider/__snapshots__/divider.spec.snap.js b/src/components/divider/__snapshots__/divider.spec.snap.js new file mode 100644 index 00000000000..d494526a59c --- /dev/null +++ b/src/components/divider/__snapshots__/divider.spec.snap.js @@ -0,0 +1,33 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-divider A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-divider A11y tree Firefox */ + +snapshots["sbb-divider A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-divider A11y tree Safari */ + diff --git a/src/components/divider/divider.spec.ts b/src/components/divider/divider.spec.ts index b7f10442653..ee40538ee7f 100644 --- a/src/components/divider/divider.spec.ts +++ b/src/components/divider/divider.spec.ts @@ -1,8 +1,10 @@ -import './divider'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import './divider'; + describe('sbb-divider', () => { it('should render with default values', async () => { const element: Element = await fixture(html``); @@ -31,4 +33,6 @@ describe('sbb-divider', () => { ); expect(element).shadowDom.to.be.equal(`
    `); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/expansion-panel/expansion-panel-content/__snapshots__/expansion-panel-content.spec.snap.js b/src/components/expansion-panel/expansion-panel-content/__snapshots__/expansion-panel-content.spec.snap.js new file mode 100644 index 00000000000..49881a885ee --- /dev/null +++ b/src/components/expansion-panel/expansion-panel-content/__snapshots__/expansion-panel-content.spec.snap.js @@ -0,0 +1,67 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-expansion-panel-content renders"] = +`
    + + +
    +`; +/* end snapshot sbb-expansion-panel-content renders */ + +snapshots["sbb-expansion-panel-content renders expanded"] = +`
    + + +
    +`; +/* end snapshot sbb-expansion-panel-content renders expanded */ + +snapshots["sbb-expansion-panel-content A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Content" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-content A11y tree Chrome */ + +snapshots["sbb-expansion-panel-content A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Content" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-content A11y tree Firefox */ + +snapshots["sbb-expansion-panel-content A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Content" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-content A11y tree Safari */ + diff --git a/src/components/expansion-panel/expansion-panel-content/expansion-panel-content.spec.ts b/src/components/expansion-panel/expansion-panel-content/expansion-panel-content.spec.ts index ab40a795634..085c9791e84 100644 --- a/src/components/expansion-panel/expansion-panel-content/expansion-panel-content.spec.ts +++ b/src/components/expansion-panel/expansion-panel-content/expansion-panel-content.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + import './expansion-panel-content'; describe('sbb-expansion-panel-content', () => { @@ -15,13 +18,7 @@ describe('sbb-expansion-panel-content', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` -
    - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders expanded', async () => { @@ -36,12 +33,11 @@ describe('sbb-expansion-panel-content', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` -
    - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html`Content`, + ); }); diff --git a/src/components/expansion-panel/expansion-panel-header/__snapshots__/expansion-panel-header.spec.snap.js b/src/components/expansion-panel/expansion-panel-header/__snapshots__/expansion-panel-header.spec.snap.js index 9bec3a80bdd..3faa70d2203 100644 --- a/src/components/expansion-panel/expansion-panel-header/__snapshots__/expansion-panel-header.spec.snap.js +++ b/src/components/expansion-panel/expansion-panel-header/__snapshots__/expansion-panel-header.spec.snap.js @@ -80,3 +80,51 @@ snapshots["sbb-expansion-panel-header renders with slotted icon"] = `; /* end snapshot sbb-expansion-panel-header renders with slotted icon */ +snapshots["sbb-expansion-panel-header A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-header A11y tree Chrome */ + +snapshots["sbb-expansion-panel-header A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-header A11y tree Firefox */ + +snapshots["sbb-expansion-panel-header A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel-header A11y tree Safari */ + diff --git a/src/components/expansion-panel/expansion-panel-header/expansion-panel-header.spec.ts b/src/components/expansion-panel/expansion-panel-header/expansion-panel-header.spec.ts index 057cf524b8a..85568beb0b4 100644 --- a/src/components/expansion-panel/expansion-panel-header/expansion-panel-header.spec.ts +++ b/src/components/expansion-panel/expansion-panel-header/expansion-panel-header.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './expansion-panel-header'; @@ -74,4 +75,9 @@ describe('sbb-expansion-panel-header', () => { ); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html`Header`, + ); }); diff --git a/src/components/expansion-panel/expansion-panel/__snapshots__/expansion-panel.spec.snap.js b/src/components/expansion-panel/expansion-panel/__snapshots__/expansion-panel.spec.snap.js new file mode 100644 index 00000000000..0a075040704 --- /dev/null +++ b/src/components/expansion-panel/expansion-panel/__snapshots__/expansion-panel.spec.snap.js @@ -0,0 +1,137 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-expansion-panel renders Dom"] = +` + + + +`; +/* end snapshot sbb-expansion-panel renders Dom */ + +snapshots["sbb-expansion-panel renders ShadowDom"] = +`
    +
    + + +
    +
    + + + + +
    +
    +`; +/* end snapshot sbb-expansion-panel renders ShadowDom */ + +snapshots["sbb-expansion-panel renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel renders A11y tree Chrome */ + +snapshots["sbb-expansion-panel renders with level set Dom"] = +` + + + +`; +/* end snapshot sbb-expansion-panel renders with level set Dom */ + +snapshots["sbb-expansion-panel renders with level set ShadowDom"] = +`
    +

    + + +

    +
    + + + + +
    +
    +`; +/* end snapshot sbb-expansion-panel renders with level set ShadowDom */ + +snapshots["sbb-expansion-panel renders A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel renders A11y tree Firefox */ + +snapshots["sbb-expansion-panel renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Header" + } + ] +} +

    +`; +/* end snapshot sbb-expansion-panel renders A11y tree Safari */ + diff --git a/src/components/expansion-panel/expansion-panel/expansion-panel.spec.ts b/src/components/expansion-panel/expansion-panel/expansion-panel.spec.ts index 26259936414..6b0a611d70b 100644 --- a/src/components/expansion-panel/expansion-panel/expansion-panel.spec.ts +++ b/src/components/expansion-panel/expansion-panel/expansion-panel.spec.ts @@ -1,69 +1,55 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbExpansionPanelElement } from './expansion-panel'; import './expansion-panel'; +import '../expansion-panel-header'; +import '../expansion-panel-content'; describe('sbb-expansion-panel', () => { - it('renders', async () => { - const root = await fixture(html` - - Header - Content - - `); + describe('renders', () => { + let element: SbbExpansionPanelElement; - expect(root).dom.to.be.equal( - ` + beforeEach(async () => { + element = await fixture(html` Header Content - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -
    - -
    -
    - - - -
    -
    - `, - ); + `); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); - it('renders with level set', async () => { - const root = await fixture(html` - - Header - Content - - `); + describe('renders with level set', () => { + let element: SbbExpansionPanelElement; - expect(root).dom.to.be.equal( - ` + beforeEach(async () => { + element = await fixture(html` Header Content - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -

    - -

    -
    - - - -
    -
    - `, - ); + `); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); }); }); diff --git a/src/components/file-selector/__snapshots__/file-selector.spec.snap.js b/src/components/file-selector/__snapshots__/file-selector.spec.snap.js index 352c4c6b84c..ace155dead5 100644 --- a/src/components/file-selector/__snapshots__/file-selector.spec.snap.js +++ b/src/components/file-selector/__snapshots__/file-selector.spec.snap.js @@ -84,3 +84,75 @@ snapshots["sbb-file-selector renders with dropzone area"] = `; /* end snapshot sbb-file-selector renders with dropzone area */ +snapshots["sbb-file-selector A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Choose a file" + }, + { + "role": "button", + "name": "Choose a file", + "value": "No file chosen" + } + ] +} +

    +`; +/* end snapshot sbb-file-selector A11y tree Chrome */ + +snapshots["sbb-file-selector A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Choose a file" + }, + { + "role": "group", + "name": "", + "children": [ + { + "role": "button", + "name": "Browse…" + }, + { + "role": "text leaf", + "name": "…" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-file-selector A11y tree Firefox */ + +snapshots["sbb-file-selector A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Choose a file" + }, + { + "role": "button", + "name": "Choose File", + "roledescription": "file upload button" + } + ] +} +

    +`; +/* end snapshot sbb-file-selector A11y tree Safari */ + diff --git a/src/components/file-selector/file-selector.spec.ts b/src/components/file-selector/file-selector.spec.ts index 2b6634ff7bc..cfb89375a5b 100644 --- a/src/components/file-selector/file-selector.spec.ts +++ b/src/components/file-selector/file-selector.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './file-selector'; @@ -27,4 +28,6 @@ describe('sbb-file-selector', () => { `); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/footer/__snapshots__/footer.spec.snap.js b/src/components/footer/__snapshots__/footer.spec.snap.js new file mode 100644 index 00000000000..44a5fec6d49 --- /dev/null +++ b/src/components/footer/__snapshots__/footer.spec.snap.js @@ -0,0 +1,67 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-footer renders"] = +`
    + +
    +`; +/* end snapshot sbb-footer renders */ + +snapshots["sbb-footer A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Footer", + "level": 1 + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Footer", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-footer A11y tree Firefox */ + +snapshots["sbb-footer A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Footer", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-footer A11y tree Safari */ + diff --git a/src/components/footer/footer.spec.ts b/src/components/footer/footer.spec.ts index ae3bb7b853d..f5c1cd47863 100644 --- a/src/components/footer/footer.spec.ts +++ b/src/components/footer/footer.spec.ts @@ -1,6 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import type { SbbFooterElement } from './footer'; import './footer'; @@ -16,15 +18,8 @@ describe('sbb-footer', () => { `, ); - expect(element).shadowDom.to.be.equal( - ` -
    - -
    - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/form-error/__snapshots__/form-error.spec.snap.js b/src/components/form-error/__snapshots__/form-error.spec.snap.js new file mode 100644 index 00000000000..e4126a44bf3 --- /dev/null +++ b/src/components/form-error/__snapshots__/form-error.spec.snap.js @@ -0,0 +1,63 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-form-error renders"] = +` + + + + + + + +`; +/* end snapshot sbb-form-error renders */ + +snapshots["sbb-form-error A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Required" + } + ] +} +

    +`; +/* end snapshot sbb-form-error A11y tree Chrome */ + +snapshots["sbb-form-error A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Required" + } + ] +} +

    +`; +/* end snapshot sbb-form-error A11y tree Firefox */ + +snapshots["sbb-form-error A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Required" + } + ] +} +

    +`; +/* end snapshot sbb-form-error A11y tree Safari */ + diff --git a/src/components/form-error/form-error.spec.ts b/src/components/form-error/form-error.spec.ts index e6229a8af2e..12d74386905 100644 --- a/src/components/form-error/form-error.spec.ts +++ b/src/components/form-error/form-error.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import './form-error'; describe('sbb-form-error', () => { @@ -11,27 +14,8 @@ describe('sbb-form-error', () => { Required `); - expect(root).shadowDom.to.be.equal(` - - - - - - - - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html`Required`); }); diff --git a/src/components/form-field/form-field-clear/__snapshots__/form-field-clear.spec.snap.js b/src/components/form-field/form-field-clear/__snapshots__/form-field-clear.spec.snap.js new file mode 100644 index 00000000000..96e3de1e544 --- /dev/null +++ b/src/components/form-field/form-field-clear/__snapshots__/form-field-clear.spec.snap.js @@ -0,0 +1,173 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-form-field-clear renders Formfield Dom"] = +` + + + + + +`; +/* end snapshot sbb-form-field-clear renders Formfield Dom */ + +snapshots["sbb-form-field-clear renders Formfield ShadowDom"] = +`
    +
    + + +
    + + + + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    +`; +/* end snapshot sbb-form-field-clear renders Formfield ShadowDom */ + +snapshots["sbb-form-field-clear renders FormfieldClear ShadowDom"] = +` + + +`; +/* end snapshot sbb-form-field-clear renders FormfieldClear ShadowDom */ + +snapshots["sbb-form-field-clear renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "text", + "name": "Label" + }, + { + "role": "textbox", + "name": "Label", + "value": "Input value" + }, + { + "role": "button", + "name": "Clear input value" + } + ] +} +

    +`; +/* end snapshot sbb-form-field-clear renders A11y tree Chrome */ + +snapshots["sbb-form-field-clear renders A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "statictext", + "name": "​" + }, + { + "role": "text leaf", + "name": "Label" + }, + { + "role": "textbox", + "name": "Label", + "value": "Input value" + }, + { + "role": "button", + "name": "Clear input value" + } + ] +} +

    +`; +/* end snapshot sbb-form-field-clear renders A11y tree Firefox */ + +snapshots["sbb-form-field-clear renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "text", + "name": "Label" + }, + { + "role": "textbox", + "name": "Label", + "value": "Input value" + }, + { + "role": "button", + "name": "Clear input value" + } + ] +} +

    +`; +/* end snapshot sbb-form-field-clear renders A11y tree Safari */ + diff --git a/src/components/form-field/form-field-clear/form-field-clear.spec.ts b/src/components/form-field/form-field-clear/form-field-clear.spec.ts index 70784ce1c50..cdd15f940df 100644 --- a/src/components/form-field/form-field-clear/form-field-clear.spec.ts +++ b/src/components/form-field/form-field-clear/form-field-clear.spec.ts @@ -2,60 +2,41 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; +import type { SbbFormFieldElement } from '../form-field'; +import type { SbbFormFieldClearElement } from './form-field-clear'; import './form-field-clear'; import '../form-field'; describe('sbb-form-field-clear', () => { - it('renders', async () => { - const formField = await fixture(html` - - - - - `); - await waitForLitRender(formField); - - const formFieldClear = formField.querySelector('sbb-form-field-clear'); - - expect(formField).dom.to.be.equal(` - - - - - - - `); - - expect(formField).shadowDom.to.be.equal(` -
    -
    - -
    - - - - - - -
    - -
    -
    - -
    -
    - -
    -
    - `); - - expect(formFieldClear).shadowDom.to.be.equal(` - - - - `); + describe('renders', () => { + let root: SbbFormFieldElement; + let element: SbbFormFieldClearElement; + + beforeEach(async () => { + root = await fixture(html` + + + + + `); + element = root.querySelector('sbb-form-field-clear')!; + await waitForLitRender(root); + }); + + it('Formfield Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + + it('Formfield ShadowDom', async () => { + await expect(root).shadowDom.to.be.equalSnapshot(); + }); + + it('FormfieldClear ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); }); diff --git a/src/components/form-field/form-field/__snapshots__/form-field.spec.snap.js b/src/components/form-field/form-field/__snapshots__/form-field.spec.snap.js index b44ad795745..22ef9376a9c 100644 --- a/src/components/form-field/form-field/__snapshots__/form-field.spec.snap.js +++ b/src/components/form-field/form-field/__snapshots__/form-field.spec.snap.js @@ -236,3 +236,75 @@ snapshots["sbb-form-field renders select with optional flag and borderless"] = `; /* end snapshot sbb-form-field renders select with optional flag and borderless */ +snapshots["sbb-form-field A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "text", + "name": "Fill input" + }, + { + "role": "textbox", + "name": "Fill input" + } + ] +} +

    +`; +/* end snapshot sbb-form-field A11y tree Chrome */ + +snapshots["sbb-form-field A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "statictext", + "name": "​" + }, + { + "role": "text leaf", + "name": "Fill input" + }, + { + "role": "textbox", + "name": "Fill input" + } + ] +} +

    +`; +/* end snapshot sbb-form-field A11y tree Firefox */ + +snapshots["sbb-form-field A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "​" + }, + { + "role": "text", + "name": "Fill input" + }, + { + "role": "textbox", + "name": "Fill input" + } + ] +} +

    +`; +/* end snapshot sbb-form-field A11y tree Safari */ + diff --git a/src/components/form-field/form-field/form-field.spec.ts b/src/components/form-field/form-field/form-field.spec.ts index 032f159b320..1bca75495f9 100644 --- a/src/components/form-field/form-field/form-field.spec.ts +++ b/src/components/form-field/form-field/form-field.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './form-field'; @@ -158,4 +159,14 @@ describe('sbb-form-field', () => { `); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html` + + + + + `, + ); }); diff --git a/src/components/header/header/__snapshots__/header.spec.snap.js b/src/components/header/header/__snapshots__/header.spec.snap.js new file mode 100644 index 00000000000..e0bb08b19b1 --- /dev/null +++ b/src/components/header/header/__snapshots__/header.spec.snap.js @@ -0,0 +1,85 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-header renders"] = +`
    +
    + + + +
    +
    +`; +/* end snapshot sbb-header renders */ + +snapshots["sbb-header renders actions and logo Dom"] = +` + + +
    + + +
    +
    +`; +/* end snapshot sbb-header renders actions and logo Dom */ + +snapshots["sbb-header renders actions and logo ShadowDom"] = +`
    +
    + + + +
    +
    +`; +/* end snapshot sbb-header renders actions and logo ShadowDom */ + +snapshots["sbb-header renders actions and logo A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-header renders actions and logo A11y tree Chrome */ + +snapshots["sbb-header renders actions and logo A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-header renders actions and logo A11y tree Firefox */ + +snapshots["sbb-header renders actions and logo A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-header renders actions and logo A11y tree Safari */ + diff --git a/src/components/header/header/header.spec.ts b/src/components/header/header/header.spec.ts index 45cbcc83165..0e132c56d0c 100644 --- a/src/components/header/header/header.spec.ts +++ b/src/components/header/header/header.spec.ts @@ -1,69 +1,47 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbHeaderElement } from './header'; import './header'; describe('sbb-header', () => { it('renders', async () => { const root = await fixture(html``); - expect(root).dom.to.be.equal( - ` - - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -
    - - -
    -
    - `, - ); + expect(root).dom.to.be.equal(``); + await expect(root).shadowDom.to.be.equalSnapshot(); }); - it('renders actions and logo', async () => { - const root = await fixture(html` - - -
    - -
    -
    - `); + describe('renders actions and logo', () => { + let element: SbbHeaderElement; + + beforeEach(async () => { + element = await fixture(html` + + +
    + +
    +
    + `); + await waitForLitRender(element); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); - expect(root).dom.to.be.equal( - ` - - -
    - -
    -
    - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -
    - - -
    -
    - `, - ); + testA11yTreeSnapshot(); }); }); diff --git a/src/components/icon/__snapshots__/icon.spec.snap.js b/src/components/icon/__snapshots__/icon.spec.snap.js index 9f337a98d23..ea3fa061013 100644 --- a/src/components/icon/__snapshots__/icon.spec.snap.js +++ b/src/components/icon/__snapshots__/icon.spec.snap.js @@ -52,3 +52,33 @@ snapshots["sbb-icon registers a custom namespace"] = `; /* end snapshot sbb-icon registers a custom namespace */ +snapshots["sbb-icon A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-icon A11y tree Firefox */ + +snapshots["sbb-icon A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-icon A11y tree Safari */ + diff --git a/src/components/icon/icon.spec.ts b/src/components/icon/icon.spec.ts index 4dbade117e6..757274ef59c 100644 --- a/src/components/icon/icon.spec.ts +++ b/src/components/icon/icon.spec.ts @@ -4,6 +4,7 @@ import { html } from 'lit/static-html.js'; import type { SbbIconConfig } from '../core/config'; import { readConfig } from '../core/config'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import type { SbbIconElement } from './icon'; @@ -120,4 +121,6 @@ describe('sbb-icon', () => { // Reset icon config delete (globalThis as any).sbbConfig.icon; // FIXME any type }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/journey-header/__snapshots__/journey-header.spec.snap.js b/src/components/journey-header/__snapshots__/journey-header.spec.snap.js new file mode 100644 index 00000000000..c7f96304ed7 --- /dev/null +++ b/src/components/journey-header/__snapshots__/journey-header.spec.snap.js @@ -0,0 +1,155 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-journey-header renders"] = +` + + + + Connection from + + A + + + + + to + + B + + + +`; +/* end snapshot sbb-journey-header renders */ + +snapshots["sbb-journey-header renders H1 L-sized round-trip negative"] = +` + + + + Connection from + + B + + + + + to + + C + + and back to B. + + + + +`; +/* end snapshot sbb-journey-header renders H1 L-sized round-trip negative */ + +snapshots["sbb-journey-header A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Connection from  B  to  C and back to B.", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-journey-header A11y tree Chrome */ + +snapshots["sbb-journey-header A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Connection from  B  to  C and back to B.", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-journey-header A11y tree Firefox */ + +snapshots["sbb-journey-header A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Connection from" + }, + { + "role": "text", + "name": " " + }, + { + "role": "text", + "name": "B" + }, + { + "role": "text", + "name": " " + }, + { + "role": "text", + "name": "to" + }, + { + "role": "text", + "name": " " + }, + { + "role": "text", + "name": "C" + }, + { + "role": "text", + "name": "and back to B." + } + ] +} +

    +`; +/* end snapshot sbb-journey-header A11y tree Safari */ + diff --git a/src/components/journey-header/journey-header.spec.ts b/src/components/journey-header/journey-header.spec.ts index e8bf6511cb9..ee95808be3d 100644 --- a/src/components/journey-header/journey-header.spec.ts +++ b/src/components/journey-header/journey-header.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './journey-header'; @@ -17,25 +18,7 @@ describe('sbb-journey-header', () => { `); - expect(root).shadowDom.to.be.equal(` - - - - - Connection from - - A - - - - - to - - B - - - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders H1 L-sized round-trip negative', async () => { @@ -56,27 +39,18 @@ describe('sbb-journey-header', () => { `); - expect(root).shadowDom.to.be.equal(` - - - - - Connection from - - B - - - - - to - - C - - and back to B. - - - - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/journey-summary/__snapshots__/journey-summary.spec.snap.js b/src/components/journey-summary/__snapshots__/journey-summary.spec.snap.js new file mode 100644 index 00000000000..53e39e9fe6c --- /dev/null +++ b/src/components/journey-summary/__snapshots__/journey-summary.spec.snap.js @@ -0,0 +1,128 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-journey-summary renders"] = +`
    +
    +
    + + Via + + +
    +
    + + , + +
    + + +
    +
    +`; +/* end snapshot sbb-journey-summary renders */ + +snapshots["sbb-journey-summary renders without vias"] = +`
    +
    +
    + + , + +
    + + +
    +
    +`; +/* end snapshot sbb-journey-summary renders without vias */ + +snapshots["sbb-journey-summary renders with second journey"] = +`
    +
    +
    + + , + +
    + + +
    +
    + + +
    +
    + + Via + + +
    +
    + + , + +
    + + +
    +
    +
    +`; +/* end snapshot sbb-journey-summary renders with second journey */ + diff --git a/src/components/journey-summary/journey-summary.spec.ts b/src/components/journey-summary/journey-summary.spec.ts index b7fdf73d864..f90a8171c0e 100644 --- a/src/components/journey-summary/journey-summary.spec.ts +++ b/src/components/journey-summary/journey-summary.spec.ts @@ -48,37 +48,7 @@ describe('sbb-journey-summary', () => { expect(root).dom.to.be.equal(` `); - expect(root).shadowDom.to.be.equal(` -
    -
    -
    - - Via - - -
    -
    - - , - -
    - -
    -
    - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders without vias', async () => { @@ -92,27 +62,7 @@ describe('sbb-journey-summary', () => { expect(root).dom.to.be.equal(` `); - expect(root).shadowDom.to.be.equal(` -
    -
    -
    - - , - -
    - -
    -
    - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with second journey', async () => { @@ -128,56 +78,6 @@ describe('sbb-journey-summary', () => { expect(root).dom.to.be.equal(` `); - expect(root).shadowDom.to.be.equal(` -
    -
    -
    - - , - -
    - -
    -
    - -
    -
    - - Via - - -
    -
    - - , - -
    - -
    -
    -
    - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); diff --git a/src/components/link-list/__snapshots__/link-list.spec.snap.js b/src/components/link-list/__snapshots__/link-list.spec.snap.js index d53482db5d8..d214b69ed22 100644 --- a/src/components/link-list/__snapshots__/link-list.spec.snap.js +++ b/src/components/link-list/__snapshots__/link-list.spec.snap.js @@ -394,3 +394,33 @@ snapshots["sbb-link-list rendered without a title in shadow DOM"] = `; /* end snapshot sbb-link-list rendered without a title in shadow DOM */ +snapshots["sbb-link-list rendered with a slotted title A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-link-list rendered with a slotted title A11y tree Chrome */ + +snapshots["sbb-link-list rendered with a slotted title A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-link-list rendered with a slotted title A11y tree Firefox */ + +snapshots["sbb-link-list rendered with a slotted title A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-link-list rendered with a slotted title A11y tree Safari */ + diff --git a/src/components/link-list/link-list.spec.ts b/src/components/link-list/link-list.spec.ts index 38dc3146f9d..5a6a03c58c3 100644 --- a/src/components/link-list/link-list.spec.ts +++ b/src/components/link-list/link-list.spec.ts @@ -1,6 +1,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import type { SbbLinkElement } from '../link'; import type { SbbLinkListElement } from './link-list'; @@ -51,6 +52,8 @@ describe('sbb-link-list', () => { it('in shadow DOM', async () => { await expect(element).shadowDom.to.equalSnapshot(); }); + + testA11yTreeSnapshot(); }); describe('rendered with a title from properties', () => { diff --git a/src/components/loading-indicator/__snapshots__/loading-indicator.spec.snap.js b/src/components/loading-indicator/__snapshots__/loading-indicator.spec.snap.js new file mode 100644 index 00000000000..b1a7c69a845 --- /dev/null +++ b/src/components/loading-indicator/__snapshots__/loading-indicator.spec.snap.js @@ -0,0 +1,123 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-loading-indicator renders with variant `window`"] = +` + + + + + + + + + + + + + + + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `window` */ + +snapshots["sbb-loading-indicator renders with variant `window` and color smoke"] = +` + + + + + + + + + + + + + + + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `window` and color smoke */ + +snapshots["sbb-loading-indicator renders with variant `window` and color white"] = +` + + + + + + + + + + + + + + + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `window` and color white */ + +snapshots["sbb-loading-indicator renders with variant `circle`"] = +` + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `circle` */ + +snapshots["sbb-loading-indicator renders with variant `circle` and color smoke"] = +` + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `circle` and color smoke */ + +snapshots["sbb-loading-indicator renders with variant `circle` and color white"] = +` + + + +`; +/* end snapshot sbb-loading-indicator renders with variant `circle` and color white */ + +snapshots["sbb-loading-indicator A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-loading-indicator A11y tree Chrome */ + +snapshots["sbb-loading-indicator A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-loading-indicator A11y tree Firefox */ + +snapshots["sbb-loading-indicator A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-loading-indicator A11y tree Safari */ + diff --git a/src/components/loading-indicator/loading-indicator.spec.ts b/src/components/loading-indicator/loading-indicator.spec.ts index 4c2377053d4..7bb274b64f5 100644 --- a/src/components/loading-indicator/loading-indicator.spec.ts +++ b/src/components/loading-indicator/loading-indicator.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import './loading-indicator'; describe('sbb-loading-indicator', () => { @@ -14,23 +17,7 @@ describe('sbb-loading-indicator', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - - - - - - - - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with variant `window` and color smoke', async () => { @@ -41,27 +28,10 @@ describe('sbb-loading-indicator', () => { expect(root).dom.to.be.equal( ` - `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - - - - - - - - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with variant `window` and color white', async () => { @@ -75,23 +45,7 @@ describe('sbb-loading-indicator', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - - - - - - - - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with variant `circle`', async () => { @@ -105,13 +59,7 @@ describe('sbb-loading-indicator', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with variant `circle` and color smoke', async () => { @@ -125,13 +73,7 @@ describe('sbb-loading-indicator', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with variant `circle` and color white', async () => { @@ -145,12 +87,11 @@ describe('sbb-loading-indicator', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/map-container/__snapshots__/map-container.spec.snap.js b/src/components/map-container/__snapshots__/map-container.spec.snap.js new file mode 100644 index 00000000000..a1c0d1fc8cf --- /dev/null +++ b/src/components/map-container/__snapshots__/map-container.spec.snap.js @@ -0,0 +1,77 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-map-container renders the container with button"] = +`
    +
    + + + + + + Show map + +
    +
    + + +
    +
    +`; +/* end snapshot sbb-map-container renders the container with button */ + +snapshots["sbb-map-container renders the container without button"] = +`
    +
    + + +
    +
    + + +
    +
    +`; +/* end snapshot sbb-map-container renders the container without button */ + +snapshots["sbb-map-container A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

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

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-map-container A11y tree Safari */ + diff --git a/src/components/map-container/map-container.spec.ts b/src/components/map-container/map-container.spec.ts index de6d347c0c3..c71ae7e94a0 100644 --- a/src/components/map-container/map-container.spec.ts +++ b/src/components/map-container/map-container.spec.ts @@ -1,6 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import type { SbbMapContainerElement } from './map-container'; import '.'; @@ -16,32 +18,9 @@ describe('sbb-map-container', () => { `, ); - expect(element).shadowDom.to.be.equal( - ` -
    -
    - - - Show map -
    -
    - -
    -
    - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); + it('renders the container without button', async () => { element = await fixture(html``); @@ -51,17 +30,11 @@ describe('sbb-map-container', () => { `, ); - expect(element).shadowDom.to.be.equal( - ` -
    -
    - -
    -
    - -
    -
    - `, - ); + await expect(element).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/message/__snapshots__/message.spec.snap.js b/src/components/message/__snapshots__/message.spec.snap.js new file mode 100644 index 00000000000..95784b127a2 --- /dev/null +++ b/src/components/message/__snapshots__/message.spec.snap.js @@ -0,0 +1,163 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-message renders without optional slots"] = +`
    + + + + + Title. + + + + + + + + +
    +`; +/* end snapshot sbb-message renders without optional slots */ + +snapshots["sbb-message renders Dom"] = +` + + +

    + Subtitle. +

    +

    + Error code: 0001 +

    + + +
    +`; +/* end snapshot sbb-message renders Dom */ + +snapshots["sbb-message renders ShadowDom"] = +`
    + + + + + Title. + + + + + + + + +
    +`; +/* end snapshot sbb-message renders ShadowDom */ + +snapshots["sbb-message renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title.", + "level": 3 + }, + { + "role": "text", + "name": "Subtitle." + }, + { + "role": "text", + "name": "Error code: 0001" + }, + { + "role": "button", + "name": "" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title.", + "level": 3 + }, + { + "role": "text leaf", + "name": "Subtitle." + }, + { + "role": "text leaf", + "name": "Error code: 0001" + }, + { + "role": "button", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-message renders A11y tree Firefox */ + +snapshots["sbb-message renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Title." + }, + { + "role": "text", + "name": "Subtitle." + }, + { + "role": "text", + "name": "Error code: 0001" + }, + { + "role": "button", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-message renders A11y tree Safari */ + diff --git a/src/components/message/message.spec.ts b/src/components/message/message.spec.ts index 6d31c867c96..ac4e3311dd9 100644 --- a/src/components/message/message.spec.ts +++ b/src/components/message/message.spec.ts @@ -1,48 +1,37 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; -import '.'; -describe('sbb-message', () => { - it('renders', async () => { - const root = await fixture( - html` - -

    Subtitle.

    -

    Error code: 0001

    - -
    `, - ); +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; - expect(root).dom.to.be.equal( - ` - +import type { SbbMessageElement } from './message'; +import './message'; +import '../image'; +import '../button'; + +describe('sbb-message', () => { + describe('renders', () => { + let root: SbbMessageElement; + beforeEach(async () => { + root = await fixture( + html` -

    - Subtitle. -

    -

    - Error code: 0001 -

    - -
    - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    - - - - Title. - - - - - -
    - `, - ); +

    Subtitle.

    +

    Error code: 0001

    + +
    `, + ); + }); + + it('Dom', async () => { + await expect(root).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(root).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); it('renders without optional slots', async () => { @@ -55,27 +44,12 @@ describe('sbb-message', () => { expect(root).dom.to.be.equal( ` -

    Subtitle.

    `, ); - expect(root).shadowDom.to.be.equal( - ` -
    - - - - Title. - - - - - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); diff --git a/src/components/notification/__snapshots__/notification.spec.snap.js b/src/components/notification/__snapshots__/notification.spec.snap.js index 566415d0728..ea926bb7e47 100644 --- a/src/components/notification/__snapshots__/notification.spec.snap.js +++ b/src/components/notification/__snapshots__/notification.spec.snap.js @@ -183,3 +183,33 @@ snapshots["sbb-notification renders without the close button"] = `; /* end snapshot sbb-notification renders without the close button */ +snapshots["sbb-notification A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-notification A11y tree Firefox */ + +snapshots["sbb-notification A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-notification A11y tree Safari */ + diff --git a/src/components/notification/notification.spec.ts b/src/components/notification/notification.spec.ts index 30a8522680d..6ae157c92f3 100644 --- a/src/components/notification/notification.spec.ts +++ b/src/components/notification/notification.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './notification'; import '../link'; @@ -16,7 +17,6 @@ describe('sbb-notification', () => { >The quick brown fox jumps over the lazy dog.`, ); - await waitForLitRender(root); expect(root).dom.to.be.equal( @@ -34,7 +34,6 @@ describe('sbb-notification', () => { >The quick brown fox jumps over the lazy dog.`, ); - await waitForLitRender(root); expect(root).dom.to.be.equal( @@ -53,7 +52,6 @@ describe('sbb-notification', () => { The quick brown fox jumps over the lazy dog. `, ); - await waitForLitRender(root); expect(root).dom.to.be.equal( @@ -74,7 +72,6 @@ describe('sbb-notification', () => { >The quick brown fox jumps over the lazy dog.`, ); - await waitForLitRender(root); expect(root).dom.to.be.equal( @@ -85,4 +82,11 @@ describe('sbb-notification', () => { ); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html`Lorem ipsum ...`, + ); }); diff --git a/src/components/option/optgroup/__snapshots__/optgroup.spec.snap.js b/src/components/option/optgroup/__snapshots__/optgroup.spec.snap.js new file mode 100644 index 00000000000..ba7ae1fc1d6 --- /dev/null +++ b/src/components/option/optgroup/__snapshots__/optgroup.spec.snap.js @@ -0,0 +1,272 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-optgroup autocomplete renders Chrome-Firefox Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-optgroup autocomplete renders Chrome-Firefox Dom */ + +snapshots["sbb-optgroup autocomplete renders Chrome-Firefox ShadowDom"] = +`
    + + +
    + + + +`; +/* end snapshot sbb-optgroup autocomplete renders Chrome-Firefox ShadowDom */ + +snapshots["sbb-optgroup autocomplete renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-optgroup autocomplete renders A11y tree Chrome */ + +snapshots["sbb-optgroup autocomplete renders disabled Chrome-Firefox Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-optgroup autocomplete renders disabled Chrome-Firefox Dom */ + +snapshots["sbb-optgroup autocomplete renders disabled Chrome-Firefox ShadowDom"] = +`
    + + +
    + + + +`; +/* end snapshot sbb-optgroup autocomplete renders disabled Chrome-Firefox ShadowDom */ + +snapshots["sbb-optgroup autocomplete renders A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-optgroup autocomplete renders A11y tree Firefox */ + +snapshots["sbb-optgroup autocomplete renders Safari Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-optgroup autocomplete renders Safari Dom */ + +snapshots["sbb-optgroup autocomplete renders Safari ShadowDom"] = +`
    + + +
    + + + +`; +/* end snapshot sbb-optgroup autocomplete renders Safari ShadowDom */ + +snapshots["sbb-optgroup autocomplete renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "listbox", + "name": "", + "orientation": "vertical" + } + ] +} +

    +`; +/* end snapshot sbb-optgroup autocomplete renders A11y tree Safari */ + +snapshots["sbb-optgroup autocomplete renders disabled Safari Dom"] = +` + + 1 + + + 2 + + +`; +/* end snapshot sbb-optgroup autocomplete renders disabled Safari Dom */ + +snapshots["sbb-optgroup autocomplete renders disabled Safari ShadowDom"] = +`
    + + +
    + + + +`; +/* end snapshot sbb-optgroup autocomplete renders disabled Safari ShadowDom */ + diff --git a/src/components/option/optgroup/optgroup.spec.ts b/src/components/option/optgroup/optgroup.spec.ts index 0a1d5a8eda8..7d09fdea1f4 100644 --- a/src/components/option/optgroup/optgroup.spec.ts +++ b/src/components/option/optgroup/optgroup.spec.ts @@ -1,15 +1,21 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { isSafari } from '../../core/dom'; +import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbOptGroupElement } from './optgroup'; import '../../autocomplete'; import '../option'; import './optgroup'; -import { isSafari } from '../../core/dom'; describe('sbb-optgroup', () => { - describe('autocomplete', function () { - it('renders', async () => { - const root = ( + describe('autocomplete', () => { + describe('renders', () => { + let elem: SbbOptGroupElement; + + beforeEach(async () => { await fixture(html` @@ -18,30 +24,38 @@ describe('sbb-optgroup', () => {
    - `) - ).querySelector('sbb-optgroup'); - const groupRoleAttr = 'aria-disabled="false" aria-label="Label" role="group"'; + `); + elem = document.querySelector('sbb-optgroup')!; + await waitForLitRender(elem); + }); + + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); - expect(root).dom.to.be.equal(` - - 1 - 2 - - `); - expect(root).shadowDom.to.be.equal(` -
    - -
    - - - `); + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + testA11yTreeSnapshot(); }); - it('renders disabled', async () => { - const root = ( + describe('renders disabled', () => { + let elem: SbbOptGroupElement; + + beforeEach(async () => { await fixture(html` @@ -50,29 +64,30 @@ describe('sbb-optgroup', () => {
    - `) - ).querySelector('sbb-optgroup'); - const groupRoleAttr = 'aria-disabled="true" aria-label="Label" role="group"'; + `); + elem = document.querySelector('sbb-optgroup')!; + await waitForLitRender(elem); + }); + + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); - expect(root).dom.to.be.equal(` - - 1 - 2 - - `); + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); - expect(root).shadowDom.to.be.equal(` -
    - -
    - - - `); + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); }); }); }); diff --git a/src/components/option/option/__snapshots__/option.spec.snap.js b/src/components/option/option/__snapshots__/option.spec.snap.js new file mode 100644 index 00000000000..fb4798f6aa9 --- /dev/null +++ b/src/components/option/option/__snapshots__/option.spec.snap.js @@ -0,0 +1,87 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-option autocomplete renders selected and active"] = +`
    +
    + + + + + + + + Option 1 + +
    +
    +`; +/* end snapshot sbb-option autocomplete renders selected and active */ + +snapshots["sbb-option autocomplete renders disabled"] = +`
    +
    + + + + + + + + Option 1 + +
    +
    +`; +/* end snapshot sbb-option autocomplete renders disabled */ + +snapshots["sbb-option autocomplete A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Option 1" + } + ] +} +

    +`; +/* end snapshot sbb-option autocomplete A11y tree Chrome */ + +snapshots["sbb-option autocomplete A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "option", + "name": "Option 1", + "selected": true + } + ] +} +

    +`; +/* end snapshot sbb-option autocomplete A11y tree Firefox */ + +snapshots["sbb-option autocomplete A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "option", + "name": "Option 1", + "selected": true + } + ] +} +

    +`; +/* end snapshot sbb-option autocomplete A11y tree Safari */ + diff --git a/src/components/option/option/option.spec.ts b/src/components/option/option/option.spec.ts index c3f819e1380..700b990db1d 100644 --- a/src/components/option/option/option.spec.ts +++ b/src/components/option/option/option.spec.ts @@ -1,12 +1,15 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + import '../../autocomplete'; import './option'; describe('sbb-option', () => { describe('autocomplete', () => { it('renders selected and active', async () => { - const root = ( + const option = ( await fixture(html` Option 1 @@ -15,28 +18,16 @@ describe('sbb-option', () => { `) ).querySelector('sbb-option'); - expect(root).dom.to.be.equal(` + expect(option).dom.to.be.equal(` Option 1 `); - expect(root).shadowDom.to.be.equal(` -
    -
    - - - - - - Option 1 - -
    -
    - `); + await expect(option).shadowDom.to.be.equalSnapshot(); }); it('renders disabled', async () => { - const root = ( + const option = ( await fixture(html` Option 1 @@ -45,24 +36,17 @@ describe('sbb-option', () => { `) ).querySelector('sbb-option'); - expect(root).dom.to.be.equal(` + expect(option).dom.to.be.equal(` Option 1 `); - expect(root).shadowDom.to.be.equal(` -
    -
    - - - - - - Option 1 - -
    -
    - `); + await expect(option).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html`Option 1`, + ); }); }); diff --git a/src/components/radio-button/radio-button-group/__snapshots__/radio-button-group.spec.snap.js b/src/components/radio-button/radio-button-group/__snapshots__/radio-button-group.spec.snap.js new file mode 100644 index 00000000000..57e0acca907 --- /dev/null +++ b/src/components/radio-button/radio-button-group/__snapshots__/radio-button-group.spec.snap.js @@ -0,0 +1,54 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-radio-button-group renders - Dom"] = +` + +`; +/* end snapshot sbb-radio-button-group renders - Dom */ + +snapshots["sbb-radio-button-group renders - ShadowDom"] = +`
    + + +
    +
    + + +
    +`; +/* end snapshot sbb-radio-button-group renders - ShadowDom */ + +snapshots["sbb-radio-button-group A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-radio-button-group A11y tree Chrome */ + +snapshots["sbb-radio-button-group A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-radio-button-group A11y tree Firefox */ + +snapshots["sbb-radio-button-group A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-radio-button-group A11y tree Safari */ + diff --git a/src/components/radio-button/radio-button-group/radio-button-group.spec.ts b/src/components/radio-button/radio-button-group/radio-button-group.spec.ts index 8038487db25..200e6e58870 100644 --- a/src/components/radio-button/radio-button-group/radio-button-group.spec.ts +++ b/src/components/radio-button/radio-button-group/radio-button-group.spec.ts @@ -1,26 +1,25 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbRadioButtonGroupElement } from './radio-button-group'; import './radio-button-group'; describe('sbb-radio-button-group', () => { - it('renders', async () => { - const root = await fixture(html``); + let element: SbbRadioButtonGroupElement; + + beforeEach(async () => { + element = await fixture(html``); + }); - expect(root).dom.to.be.equal( - ` - - - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    - -
    -
    - -
    - `, - ); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/radio-button/radio-button/__snapshots__/radio-button.spec.snap.js b/src/components/radio-button/radio-button/__snapshots__/radio-button.spec.snap.js new file mode 100644 index 00000000000..16db82dd82e --- /dev/null +++ b/src/components/radio-button/radio-button/__snapshots__/radio-button.spec.snap.js @@ -0,0 +1,83 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-radio-button renders - Dom"] = +` + +`; +/* end snapshot sbb-radio-button renders - Dom */ + +snapshots["sbb-radio-button renders - ShadowDom"] = +` +`; +/* end snapshot sbb-radio-button renders - ShadowDom */ + +snapshots["sbb-radio-button A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-radio-button A11y tree Chrome */ + +snapshots["sbb-radio-button A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "radio", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-radio-button A11y tree Firefox */ + +snapshots["sbb-radio-button A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-radio-button A11y tree Safari */ + diff --git a/src/components/radio-button/radio-button/radio-button.spec.ts b/src/components/radio-button/radio-button/radio-button.spec.ts index 64fab9827c6..df3ea3d367e 100644 --- a/src/components/radio-button/radio-button/radio-button.spec.ts +++ b/src/components/radio-button/radio-button/radio-button.spec.ts @@ -1,26 +1,25 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbRadioButtonElement } from './radio-button'; import './radio-button'; describe('sbb-radio-button', () => { - it('renders', async () => { - const root = await fixture(html``); + let element: SbbRadioButtonElement; + + beforeEach(async () => { + element = await fixture(html``); + }); - expect(root).dom.to.be.equal( - ` - - - `, - ); - expect(root).shadowDom.to.be.equal( - ` - - `, - ); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/screenreader-only/__snapshots__/screenreader-only.spec.snap.js b/src/components/screenreader-only/__snapshots__/screenreader-only.spec.snap.js index 6c617969308..2e126893951 100644 --- a/src/components/screenreader-only/__snapshots__/screenreader-only.spec.snap.js +++ b/src/components/screenreader-only/__snapshots__/screenreader-only.spec.snap.js @@ -13,3 +13,45 @@ snapshots["with Shadow DOM"] = `; /* end snapshot with Shadow DOM */ +snapshots["sbb-screenreader-only renders with Light DOM"] = +` + +`; +/* end snapshot sbb-screenreader-only renders with Light DOM */ + +snapshots["sbb-screenreader-only renders with Shadow DOM"] = +` + +`; +/* end snapshot sbb-screenreader-only renders with Shadow DOM */ + +snapshots["sbb-screenreader-only renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-screenreader-only renders A11y tree Firefox */ + +snapshots["sbb-screenreader-only renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-screenreader-only renders A11y tree Safari */ + diff --git a/src/components/screenreader-only/screenreader-only.spec.ts b/src/components/screenreader-only/screenreader-only.spec.ts index aaa4ef72431..2550edf1653 100644 --- a/src/components/screenreader-only/screenreader-only.spec.ts +++ b/src/components/screenreader-only/screenreader-only.spec.ts @@ -1,10 +1,18 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbScreenreaderOnlyElement } from './screenreader-only'; import './screenreader-only'; describe('sbb-screenreader-only', () => { describe('renders', async () => { - const root = await fixture(html``); + let root: SbbScreenreaderOnlyElement; + + beforeEach(async () => { + root = await fixture(html``); + }); it('with Light DOM', async () => { await expect(root).dom.to.be.equalSnapshot(); @@ -13,5 +21,7 @@ describe('sbb-screenreader-only', () => { it('with Shadow DOM', async () => { await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(); }); }); diff --git a/src/components/select/__snapshots__/select.spec.snap.js b/src/components/select/__snapshots__/select.spec.snap.js new file mode 100644 index 00000000000..c1b701a304e --- /dev/null +++ b/src/components/select/__snapshots__/select.spec.snap.js @@ -0,0 +1,467 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-select renders Chrome-Firefox Dom"] = +` + + Option 1 + + + Option 2 + + + Option 3 + + +`; +/* end snapshot sbb-select renders Chrome-Firefox Dom */ + +snapshots["sbb-select renders Chrome-Firefox ShadowDom"] = +` +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +`; +/* end snapshot sbb-select renders Chrome-Firefox ShadowDom */ + +snapshots["sbb-select renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

    +`; +/* end snapshot sbb-select renders A11y tree Chrome */ + +snapshots["sbb-select renders multiple Chrome-Firefox Dom"] = +` + + Option 1 + + + Option 2 + + + Option 3 + + +`; +/* end snapshot sbb-select renders multiple Chrome-Firefox Dom */ + +snapshots["sbb-select renders multiple Chrome-Firefox ShadowDom"] = +` +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +`; +/* end snapshot sbb-select renders multiple Chrome-Firefox ShadowDom */ + +snapshots["sbb-select renders multiple A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

    +`; +/* end snapshot sbb-select renders A11y tree Firefox */ + +snapshots["sbb-select renders multiple A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

    +`; +/* end snapshot sbb-select renders multiple A11y tree Firefox */ + +snapshots["sbb-select renders Safari Dom"] = +` + + Option 1 + + + Option 2 + + + Option 3 + + +`; +/* end snapshot sbb-select renders Safari Dom */ + +snapshots["sbb-select renders Safari ShadowDom"] = +` +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +`; +/* end snapshot sbb-select renders Safari ShadowDom */ + +snapshots["sbb-select renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

    +`; +/* end snapshot sbb-select renders A11y tree Safari */ + +snapshots["sbb-select renders multiple Safari Dom"] = +` + + Option 1 + + + Option 2 + + + Option 3 + + +`; +/* end snapshot sbb-select renders multiple Safari Dom */ + +snapshots["sbb-select renders multiple Safari ShadowDom"] = +` +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +`; +/* end snapshot sbb-select renders multiple Safari ShadowDom */ + +snapshots["sbb-select renders multiple A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "combobox", + "name": "", + "haspopup": "listbox" + } + ] +} +

    +`; +/* end snapshot sbb-select renders multiple A11y tree Safari */ + diff --git a/src/components/select/select.spec.ts b/src/components/select/select.spec.ts index a9da8a24bff..c9896ef8950 100644 --- a/src/components/select/select.spec.ts +++ b/src/components/select/select.spec.ts @@ -1,86 +1,86 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; -import '../option'; -import './select'; import { isSafari } from '../core/dom'; +import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbSelectElement } from './select'; +import './select'; +import '../option'; describe('sbb-select', () => { - it('renders', async () => { - const root = await fixture(html` - - Option 1 - Option 2 - Option 3 - - `); - const listboxAttr = 'id="sbb-select-1" role="listbox"'; - - expect(root.shadowRoot!.host).to.have.attribute('dir', 'ltr'); - expect(root.shadowRoot!.host).to.have.attribute('data-state', 'closed'); - expect(root).shadowDom.to.be.equal(` - -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    - `); + describe('renders', () => { + let elem: SbbSelectElement; + + beforeEach(async () => { + elem = await fixture(html` + + Option 1 + Option 2 + Option 3 + + `); + await waitForLitRender(elem); + }); + + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + testA11yTreeSnapshot(); }); - it('renders multiple', async () => { - const root = await fixture(html` - - Option 1 - Option 2 - Option 3 - - `); - const listboxAttr = 'id="sbb-select-2" role="listbox"'; - - expect(root.shadowRoot!.host).to.have.attribute('dir', 'ltr'); - expect(root.shadowRoot!.host).to.have.attribute('data-state', 'closed'); - expect(root.shadowRoot!.host).to.have.attribute('data-multiple'); - expect(root.shadowRoot!.host).to.have.attribute('multiple'); - expect(root).shadowDom.to.be.equal(` - -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    - `); + describe('renders multiple', () => { + let elem: SbbSelectElement; + + beforeEach(async () => { + elem = await fixture(html` + + Option 1 + Option 2 + Option 3 + + `); + await waitForLitRender(elem); + }); + + (!isSafari() ? describe : describe.skip)('Chrome-Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + (isSafari() ? describe : describe.skip)('Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + testA11yTreeSnapshot(); }); }); diff --git a/src/components/selection-panel/selection-panel.spec.ts b/src/components/selection-panel/selection-panel.spec.ts index e525998ca15..21ec087eb3b 100644 --- a/src/components/selection-panel/selection-panel.spec.ts +++ b/src/components/selection-panel/selection-panel.spec.ts @@ -3,37 +3,42 @@ import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbSelectionPanelElement } from './selection-panel'; import './selection-panel'; import '../checkbox'; describe('sbb-selection-panel', () => { - // Note: for easier testing, we add the slot="badge" - // to which would not be needed in real. - const template = html` - - % - from CHF - 19.99 - - - Value one - Subtext - Suffix - -
    Inner content
    -
    `; + let element: SbbSelectionPanelElement; + + beforeEach(async () => { + // Note: for easier testing, we add the slot="badge" + // to which would not be needed in real. + element = await fixture(html` + + + % + from CHF + 19.99 + + + Value one + Subtext + Suffix + +
    Inner content
    +
    + `); + await waitForLitRender(element); + }); it('renders - Dom', async () => { - const root = await fixture(template); - await waitForLitRender(root); - await expect(root).dom.to.be.equalSnapshot(); + await expect(element).dom.to.be.equalSnapshot(); }); it('renders - ShadowDom', async () => { - const root = await fixture(template); - await waitForLitRender(root); - await expect(root).shadowDom.to.be.equalSnapshot(); + await expect(element).shadowDom.to.be.equalSnapshot(); }); - testA11yTreeSnapshot(undefined, template); + testA11yTreeSnapshot(); }); diff --git a/src/components/skiplink-list/__snapshots__/skiplink-list.spec.snap.js b/src/components/skiplink-list/__snapshots__/skiplink-list.spec.snap.js index fff23acc73c..3c654d017b5 100644 --- a/src/components/skiplink-list/__snapshots__/skiplink-list.spec.snap.js +++ b/src/components/skiplink-list/__snapshots__/skiplink-list.spec.snap.js @@ -122,3 +122,339 @@ snapshots["sbb-skiplink-list renders with title"] = `; /* end snapshot sbb-skiplink-list renders with title */ +snapshots["sbb-skiplink-list renders Dom"] = +` + + Link 1 + + + Link 2 + + + Link 3 + + +`; +/* end snapshot sbb-skiplink-list renders Dom */ + +snapshots["sbb-skiplink-list renders ShadowDom"] = +` +`; +/* end snapshot sbb-skiplink-list renders ShadowDom */ + +snapshots["sbb-skiplink-list renders with title Dom"] = +` + + Link 1 + + + Link 2 + + + Link 3 + + +`; +/* end snapshot sbb-skiplink-list renders with title Dom */ + +snapshots["sbb-skiplink-list renders with title ShadowDom"] = +` +`; +/* end snapshot sbb-skiplink-list renders with title ShadowDom */ + +snapshots["sbb-skiplink-list renders with title A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Skip to", + "level": 3 + }, + { + "role": "link", + "name": "Link 1", + "children": [ + { + "role": "link", + "name": "Link 1" + } + ] + }, + { + "role": "link", + "name": "Link 2", + "children": [ + { + "role": "link", + "name": "Link 2" + } + ] + }, + { + "role": "link", + "name": "Link 3", + "children": [ + { + "role": "link", + "name": "Link 3" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-skiplink-list renders with title A11y tree Chrome */ + +snapshots["sbb-skiplink-list renders with title A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Skip to", + "level": 3 + }, + { + "role": "link", + "name": "Link 1", + "children": [ + { + "role": "link", + "name": "Link 1", + "value": "https://www.sbb.ch/" + } + ] + }, + { + "role": "link", + "name": "Link 2", + "children": [ + { + "role": "link", + "name": "Link 2", + "value": "https://www.sbb.ch/" + } + ] + }, + { + "role": "link", + "name": "Link 3", + "children": [ + { + "role": "link", + "name": "Link 3", + "value": "https://www.sbb.ch/" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-skiplink-list renders with title A11y tree Firefox */ + +snapshots["sbb-skiplink-list renders with title A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Skip to" + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Link 1", + "children": [ + { + "role": "text", + "name": "Link 1" + } + ] + } + ] + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Link 2", + "children": [ + { + "role": "text", + "name": "Link 2" + } + ] + } + ] + }, + { + "role": "link", + "name": "", + "children": [ + { + "role": "link", + "name": "Link 3", + "children": [ + { + "role": "text", + "name": "Link 3" + } + ] + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-skiplink-list renders with title A11y tree Safari */ + diff --git a/src/components/skiplink-list/skiplink-list.spec.ts b/src/components/skiplink-list/skiplink-list.spec.ts index 8a813bcb06e..28be72fe397 100644 --- a/src/components/skiplink-list/skiplink-list.spec.ts +++ b/src/components/skiplink-list/skiplink-list.spec.ts @@ -1,50 +1,60 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbSkiplinkListElement } from './skiplink-list'; import './skiplink-list'; import '../link'; describe('sbb-skiplink-list', () => { - it('renders', async () => { - const root = await fixture(html` - - Link 1 - Link 2 - Link 3 - - `); - - expect(root).dom.to.be.equal( - ` - - Link 1 - Link 2 - Link 3 - - `, - ); - await expect(root).shadowDom.to.be.equalSnapshot(); + describe('renders', () => { + let element: SbbSkiplinkListElement; + + beforeEach(async () => { + element = await fixture(html` + + Link 1 + Link 2 + Link 3 + + `); + await waitForLitRender(element); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); }); - it('renders with title', async () => { - const root = await fixture(html` - - Link 1 - Link 2 - Link 3 - - `); - - expect(root).dom.to.be.equal( - ` - - Link 1 - Link 2 - Link 3 - - `, - ); - await expect(root).shadowDom.to.be.equalSnapshot(); + describe('renders with title', () => { + let element: SbbSkiplinkListElement; + + beforeEach(async () => { + element = await fixture(html` + + Link 1 + Link 2 + Link 3 + + `); + await waitForLitRender(element); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); it('should render named slots if data-ssr-child-count attribute is set', async () => { diff --git a/src/components/slider/__snapshots__/slider.spec.snap.js b/src/components/slider/__snapshots__/slider.spec.snap.js new file mode 100644 index 00000000000..142974a7dc1 --- /dev/null +++ b/src/components/slider/__snapshots__/slider.spec.snap.js @@ -0,0 +1,138 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-slider renders"] = +`
    +
    + + + +
    + +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +`; +/* end snapshot sbb-slider renders */ + +snapshots["sbb-slider renders with no icons and default min/max"] = +`
    +
    + + +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +`; +/* end snapshot sbb-slider renders with no icons and default min/max */ + +snapshots["sbb-slider A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "slider", + "name": "", + "valuetext": "", + "valuemin": 0, + "valuemax": 100, + "orientation": "horizontal", + "value": 1 + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "slider", + "name": "", + "valuetext": "1", + "value": "1" + } + ] +} +

    +`; +/* end snapshot sbb-slider A11y tree Firefox */ + +snapshots["sbb-slider A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "slider", + "name": "", + "valuemax": 100, + "orientation": "horizontal" + } + ] +} +

    +`; +/* end snapshot sbb-slider A11y tree Safari */ + diff --git a/src/components/slider/slider.spec.ts b/src/components/slider/slider.spec.ts index 0ccc9eee2cd..9bac9702a9a 100644 --- a/src/components/slider/slider.spec.ts +++ b/src/components/slider/slider.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './slider'; @@ -15,7 +16,6 @@ describe('sbb-slider', () => { value="100" >`, ); - await waitForLitRender(root); expect(root).dom.to.be.equal(` @@ -35,25 +35,7 @@ describe('sbb-slider', () => { `); - expect(root).shadowDom.to.be.equal(` -
    -
    - - -
    - -
    -
    -
    -
    -
    - - -
    -
    - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with no icons and default min/max', async () => { @@ -63,20 +45,8 @@ describe('sbb-slider', () => { `); - expect(root).shadowDom.to.be.equal(` -
    -
    - -
    - -
    -
    -
    -
    -
    - -
    -
    - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/status/__snapshots__/status.spec.snap.js b/src/components/status/__snapshots__/status.spec.snap.js index cbcde8cde8e..63601a24938 100644 --- a/src/components/status/__snapshots__/status.spec.snap.js +++ b/src/components/status/__snapshots__/status.spec.snap.js @@ -62,3 +62,65 @@ snapshots["sbb-status renders with the status title"] = `; /* end snapshot sbb-status renders with the status title */ +snapshots["sbb-status A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title", + "level": 3 + }, + { + "role": "text", + "name": "Status info text" + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Title", + "level": 3 + }, + { + "role": "text leaf", + "name": "Status info text " + } + ] +} +

    +`; +/* end snapshot sbb-status A11y tree Firefox */ + +snapshots["sbb-status A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Title" + }, + { + "role": "text", + "name": "Status info text" + } + ] +} +

    +`; +/* end snapshot sbb-status A11y tree Safari */ + diff --git a/src/components/status/status.spec.ts b/src/components/status/status.spec.ts index ad6a91894b3..7ad902ecad5 100644 --- a/src/components/status/status.spec.ts +++ b/src/components/status/status.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './status'; import '../icon'; @@ -33,4 +34,9 @@ describe('sbb-status', () => { `); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html` Status info text `, + ); }); diff --git a/src/components/tabs/tab-group/__snapshots__/tab-group.spec.snap.js b/src/components/tabs/tab-group/__snapshots__/tab-group.spec.snap.js new file mode 100644 index 00000000000..37b4ea0a09e --- /dev/null +++ b/src/components/tabs/tab-group/__snapshots__/tab-group.spec.snap.js @@ -0,0 +1,135 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-tab-group renders"] = +`
    + + +
    +
    + + +
    +`; +/* end snapshot sbb-tab-group renders */ + +snapshots["sbb-tab-group A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "tab", + "name": "Test tab label 1", + "selected": true + }, + { + "role": "tab", + "name": "Test tab label 2" + }, + { + "role": "tab", + "name": "Test tab label 3" + }, + { + "role": "tab", + "name": "Test tab label 4" + }, + { + "role": "tabpanel", + "name": "", + "children": [ + { + "role": "text", + "name": "Test tab content 1" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-tab-group A11y tree Chrome */ + +snapshots["sbb-tab-group A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "tab", + "name": "Test tab label 1", + "selected": true + }, + { + "role": "tab", + "name": "Test tab label 2" + }, + { + "role": "tab", + "name": "Test tab label 3" + }, + { + "role": "tab", + "name": "Test tab label 4" + }, + { + "role": "tabpanel", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Test tab content 1" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-tab-group A11y tree Firefox */ + +snapshots["sbb-tab-group A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "tab", + "name": "Test tab label 1", + "selected": true + }, + { + "role": "tab", + "name": "Test tab label 2" + }, + { + "role": "tab", + "name": "Test tab label 3" + }, + { + "role": "tab", + "name": "Test tab label 4" + }, + { + "role": "tabpanel", + "name": "", + "children": [ + { + "role": "text", + "name": "Test tab content 1" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-tab-group A11y tree Safari */ + diff --git a/src/components/tabs/tab-group/tab-group.spec.ts b/src/components/tabs/tab-group/tab-group.spec.ts index d494c2d4722..cfd2c2dfeb0 100644 --- a/src/components/tabs/tab-group/tab-group.spec.ts +++ b/src/components/tabs/tab-group/tab-group.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbTabGroupElement } from './tab-group'; import '.'; @@ -28,17 +29,7 @@ describe('sbb-tab-group', () => { const root = await fixture(html``); expect(root).dom.to.be.equal(``); - expect(root).shadowDom.to.be.equal( - ` -
    - -
    - -
    - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('activates tab by index', async () => { @@ -81,4 +72,6 @@ describe('sbb-tab-group', () => { expect(tab).to.have.attribute('active'); }); }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/tabs/tab-title/__snapshots__/tab-title.spec.snap.js b/src/components/tabs/tab-title/__snapshots__/tab-title.spec.snap.js index 9266a5b0058..00464e7525f 100644 --- a/src/components/tabs/tab-title/__snapshots__/tab-title.spec.snap.js +++ b/src/components/tabs/tab-title/__snapshots__/tab-title.spec.snap.js @@ -69,3 +69,53 @@ snapshots["sbb-tab-title renders an H1 heading tag if the provided level is grea `; /* end snapshot sbb-tab-title renders an H1 heading tag if the provided level is greater than 6 */ +snapshots["sbb-tab-title A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Tab title", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-tab-title A11y tree Chrome */ + +snapshots["sbb-tab-title A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Tab title", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-tab-title A11y tree Firefox */ + +snapshots["sbb-tab-title A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Tab title" + } + ] +} +

    +`; +/* end snapshot sbb-tab-title A11y tree Safari */ + diff --git a/src/components/tabs/tab-title/tab-title.spec.ts b/src/components/tabs/tab-title/tab-title.spec.ts index 100b1d2dc8d..8783b958eef 100644 --- a/src/components/tabs/tab-title/tab-title.spec.ts +++ b/src/components/tabs/tab-title/tab-title.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './tab-title'; @@ -30,4 +31,6 @@ describe('sbb-tab-title', () => { expect(root).dom.to.be.equal(``); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html`Tab title`); }); diff --git a/src/components/tag/tag-group/__snapshots__/tag-group.spec.snap.js b/src/components/tag/tag-group/__snapshots__/tag-group.spec.snap.js new file mode 100644 index 00000000000..6bf209f3b33 --- /dev/null +++ b/src/components/tag/tag-group/__snapshots__/tag-group.spec.snap.js @@ -0,0 +1,129 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-tag-group renders - Dom"] = +` + + First tag + + + Second tag + +
    +
    + + Third tag + +
    +`; +/* end snapshot sbb-tag-group renders - Dom */ + +snapshots["sbb-tag-group renders - ShadowDom"] = +`
    +
      +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    + +
    +`; +/* end snapshot sbb-tag-group renders - ShadowDom */ + +snapshots["sbb-tag-group A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "First tag" + }, + { + "role": "text", + "name": "Second tag" + }, + { + "role": "text", + "name": "Third tag" + } + ] +} +

    +`; +/* end snapshot sbb-tag-group A11y tree Chrome */ + +snapshots["sbb-tag-group A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "First tag" + }, + { + "role": "text leaf", + "name": "Second tag" + }, + { + "role": "text leaf", + "name": "Third tag" + } + ] +} +

    +`; +/* end snapshot sbb-tag-group A11y tree Firefox */ + +snapshots["sbb-tag-group A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "First tag" + }, + { + "role": "text", + "name": "Second tag" + }, + { + "role": "text", + "name": "Third tag" + } + ] +} +

    +`; +/* end snapshot sbb-tag-group A11y tree Safari */ + diff --git a/src/components/tag/tag-group/tag-group.spec.ts b/src/components/tag/tag-group/tag-group.spec.ts index 42171dba5bb..39ccb64c123 100644 --- a/src/components/tag/tag-group/tag-group.spec.ts +++ b/src/components/tag/tag-group/tag-group.spec.ts @@ -1,10 +1,17 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + +import type { SbbTagGroupElement } from './tag-group'; import './tag-group'; describe('sbb-tag-group', () => { - it('renders', async () => { - const root = await fixture(html` + let element: SbbTagGroupElement; + + beforeEach(async () => { + element = await fixture(html` First tag Second tag @@ -12,45 +19,16 @@ describe('sbb-tag-group', () => { Third tag `); + await waitForLitRender(element); + }); - expect(root).dom.to.be.equal( - ` - - - First tag - - - Second tag - -
    - - Third tag - -
    - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - -
    - `, - ); + it('renders - Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); }); + + it('renders - ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); diff --git a/src/components/tag/tag/__snapshots__/tag.spec.snap.js b/src/components/tag/tag/__snapshots__/tag.spec.snap.js index 5b350f4917b..d5eb644d9a1 100644 --- a/src/components/tag/tag/__snapshots__/tag.spec.snap.js +++ b/src/components/tag/tag/__snapshots__/tag.spec.snap.js @@ -81,3 +81,52 @@ snapshots["sbb-tag renders slotted icon and amount"] = `; /* end snapshot sbb-tag renders slotted icon and amount */ +snapshots["sbb-tag A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Label", + "pressed": false + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "toggle button", + "name": "Label" + } + ] +} +

    +`; +/* end snapshot sbb-tag A11y tree Firefox */ + +snapshots["sbb-tag A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "Label" + } + ] +} +

    +`; +/* end snapshot sbb-tag A11y tree Safari */ + diff --git a/src/components/tag/tag/tag.spec.ts b/src/components/tag/tag/tag.spec.ts index 3b699ca50a1..a0d3a70fdd2 100644 --- a/src/components/tag/tag/tag.spec.ts +++ b/src/components/tag/tag/tag.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './tag'; @@ -76,4 +77,6 @@ describe('sbb-tag', () => { ); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html`Label`); }); diff --git a/src/components/teaser-hero/__snapshots__/teaser-hero.spec.snap.js b/src/components/teaser-hero/__snapshots__/teaser-hero.spec.snap.js new file mode 100644 index 00000000000..975977d313b --- /dev/null +++ b/src/components/teaser-hero/__snapshots__/teaser-hero.spec.snap.js @@ -0,0 +1,206 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-teaser-hero should render without link"] = +` + +

    + + +

    +
    + + + + +
    +`; +/* end snapshot sbb-teaser-hero should render without link */ + +snapshots["sbb-teaser-hero should render with slots"] = +` + +

    + + +

    + + + + +
    + + +
    +`; +/* end snapshot sbb-teaser-hero should render with slots */ + +snapshots["sbb-teaser-hero should render all properties Dom"] = +` + Break out and explore castles and palaces. + +`; +/* end snapshot sbb-teaser-hero should render all properties Dom */ + +snapshots["sbb-teaser-hero should render all properties ShadowDom"] = +` + +

    + + +

    + + + Find out more + + +
    + + + + + + . Link target opens in new window. + +
    +`; +/* end snapshot sbb-teaser-hero should render all properties ShadowDom */ + +snapshots["sbb-teaser-hero should render all properties A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "label", + "children": [ + { + "role": "link", + "name": "Break out and explore castles and palaces. Find out more . Link target opens in new window." + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-teaser-hero should render all properties A11y tree Chrome */ + +snapshots["sbb-teaser-hero should render all properties A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "link", + "name": "label", + "children": [ + { + "role": "link", + "name": "Break out and explore castles and palaces. Find out more . Link target opens in new window.", + "value": "https://www.sbb.ch/" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-teaser-hero should render all properties A11y tree Firefox */ + +snapshots["sbb-teaser-hero should render all properties A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "label", + "children": [ + { + "role": "link", + "name": "Break out and explore castles and palaces. Find out more . Link target opens in new window.", + "children": [ + { + "role": "text", + "name": "Break out and explore castles and palaces." + }, + { + "role": "text", + "name": "Find out more" + }, + { + "role": "image", + "name": "SBB CFF FFS Employee" + }, + { + "role": "text", + "name": ". " + }, + { + "role": "text", + "name": "Link target opens in new window." + } + ] + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-teaser-hero should render all properties A11y tree Safari */ + diff --git a/src/components/teaser-hero/teaser-hero.spec.ts b/src/components/teaser-hero/teaser-hero.spec.ts index 1523a1779f0..2464cd7c040 100644 --- a/src/components/teaser-hero/teaser-hero.spec.ts +++ b/src/components/teaser-hero/teaser-hero.spec.ts @@ -2,28 +2,20 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import sampleImages from '../core/images'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import type { SbbTeaserHeroElement } from './teaser-hero'; import './teaser-hero'; import '../link'; import '../image'; describe('sbb-teaser-hero', () => { - it('should render all properties', async () => { - const root = await fixture( - html`Break out and explore castles and palaces.`, - ); + describe('should render all properties', () => { + let element: SbbTeaserHeroElement; - expect(root).dom.to.be.equal( - ` - { + element = await fixture( + html` { link-content="Find out more" image-src="${sampleImages[1]}" image-alt="SBB CFF FFS Employee" - role="link" - tabindex="0" - dir="ltr" - > - Break out and explore castles and palaces. - - `, - ); - expect(root).shadowDom.to.be.equal( - ` - - -

    - -

    - - Find out more - -
    - - - - - . Link target opens in new window. - -
    - `, - ); + >Break out and explore castles and palaces.
    `, + ); + }); + + it('Dom', async () => { + await expect(element).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(element).shadowDom.to.be.equalSnapshot(); + }); + + testA11yTreeSnapshot(); }); it('should render without link', async () => { @@ -96,20 +57,7 @@ describe('sbb-teaser-hero', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - -

    - -

    -
    - - - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('should render with slots', async () => { @@ -133,35 +81,6 @@ describe('sbb-teaser-hero', () => { `, ); - expect(root).shadowDom.to.be.equal( - ` - - -

    - -

    - - - -
    - -
    - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); diff --git a/src/components/teaser/__snapshots__/teaser.spec.snap.js b/src/components/teaser/__snapshots__/teaser.spec.snap.js index b911da5ed45..c0d2dca0ac1 100644 --- a/src/components/teaser/__snapshots__/teaser.spec.snap.js +++ b/src/components/teaser/__snapshots__/teaser.spec.snap.js @@ -222,3 +222,76 @@ snapshots["sbb-teaser renders static - ShadowDOM"] = `; /* end snapshot sbb-teaser renders static - ShadowDOM */ +snapshots["sbb-teaser A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "SBB teaser", + "children": [ + { + "role": "link", + "name": "​" + } + ] + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "link", + "name": "SBB teaser", + "children": [ + { + "role": "link", + "name": "​", + "value": "https://github.com/lyne-design-system/lyne-components" + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-teaser A11y tree Firefox */ + +snapshots["sbb-teaser A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "link", + "name": "SBB teaser", + "children": [ + { + "role": "link", + "name": "​", + "children": [ + { + "role": "text", + "name": "​" + } + ] + } + ] + } + ] +} +

    +`; +/* end snapshot sbb-teaser A11y tree Safari */ + diff --git a/src/components/teaser/teaser.spec.ts b/src/components/teaser/teaser.spec.ts index df0bc1a1657..e05d2aa4fe5 100644 --- a/src/components/teaser/teaser.spec.ts +++ b/src/components/teaser/teaser.spec.ts @@ -4,6 +4,7 @@ import { html } from 'lit/static-html.js'; import { sbbSpread } from '../core/dom'; import images from '../core/images'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import type { SbbTeaserElement } from './teaser'; import './teaser'; @@ -86,4 +87,6 @@ describe('sbb-teaser', () => { const root: SbbTeaserElement = await fixture(createTeaser({ alignment: 'after-centered' })); await expect(root).shadowDom.to.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, createTeaser(argsAfterCentered)); }); diff --git a/src/components/time-input/__snapshots__/time-input.spec.snap.js b/src/components/time-input/__snapshots__/time-input.spec.snap.js new file mode 100644 index 00000000000..746f08bee1c --- /dev/null +++ b/src/components/time-input/__snapshots__/time-input.spec.snap.js @@ -0,0 +1,67 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-time-input renders"] = +` + + + + +`; +/* end snapshot sbb-time-input renders */ + +snapshots["sbb-time-input A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "textbox", + "name": "HH:MM" + } + ] +} +

    +`; +/* end snapshot sbb-time-input A11y tree Chrome */ + +snapshots["sbb-time-input A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "textbox", + "name": "HH:MM" + } + ] +} +

    +`; +/* end snapshot sbb-time-input A11y tree Firefox */ + +snapshots["sbb-time-input A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "textbox", + "name": "HH:MM" + } + ] +} +

    +`; +/* end snapshot sbb-time-input A11y tree Safari */ + diff --git a/src/components/time-input/time-input.spec.ts b/src/components/time-input/time-input.spec.ts index d43c935dec4..b075d4b0464 100644 --- a/src/components/time-input/time-input.spec.ts +++ b/src/components/time-input/time-input.spec.ts @@ -1,5 +1,8 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; + +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + import './time-input'; describe('sbb-time-input', () => { @@ -12,15 +15,17 @@ describe('sbb-time-input', () => { ); const elem = root.querySelector('sbb-time-input'); - expect(root).dom.to.be.equal(` - - - - - - `); + await expect(root).dom.to.be.equalSnapshot(); expect(elem).shadowDom.to.be.equal(`

    `); }); + + testA11yTreeSnapshot( + undefined, + html` + + + `, + ); }); diff --git a/src/components/title/__snapshots__/title.spec.snap.js b/src/components/title/__snapshots__/title.spec.snap.js new file mode 100644 index 00000000000..123216698ee --- /dev/null +++ b/src/components/title/__snapshots__/title.spec.snap.js @@ -0,0 +1,54 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-title A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Sample Title Text", + "level": 1 + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "heading", + "name": "Sample Title Text", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-title A11y tree Firefox */ + +snapshots["sbb-title A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "heading", + "name": "Sample Title Text", + "level": 1 + } + ] +} +

    +`; +/* end snapshot sbb-title A11y tree Safari */ + diff --git a/src/components/title/title.spec.ts b/src/components/title/title.spec.ts index bfda994a901..c203ffe33ca 100644 --- a/src/components/title/title.spec.ts +++ b/src/components/title/title.spec.ts @@ -1,8 +1,10 @@ -import './title'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import './title'; + describe('sbb-title', () => { it('renders', async () => { const root = await fixture( @@ -18,4 +20,9 @@ describe('sbb-title', () => {

    `); }); + + testA11yTreeSnapshot( + undefined, + html`Sample Title Text`, + ); }); diff --git a/src/components/toast/__snapshots__/toast.spec.snap.js b/src/components/toast/__snapshots__/toast.spec.snap.js new file mode 100644 index 00000000000..f1dfece1f48 --- /dev/null +++ b/src/components/toast/__snapshots__/toast.spec.snap.js @@ -0,0 +1,152 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-toast renders Chrome-Safari Dom"] = +` + + 'Lorem ipsum dolor' + + +`; +/* end snapshot sbb-toast renders Chrome-Safari Dom */ + +snapshots["sbb-toast renders Chrome-Safari ShadowDom"] = +`
    +
    +
    + + + +
    +
    + + +
    +
    + + + + +
    +
    +
    +`; +/* end snapshot sbb-toast renders Chrome-Safari ShadowDom */ + +snapshots["sbb-toast renders A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-toast renders A11y tree Chrome */ + +snapshots["sbb-toast renders Firefox Dom"] = +` + + 'Lorem ipsum dolor' + + +`; +/* end snapshot sbb-toast renders Firefox Dom */ + +snapshots["sbb-toast renders Firefox ShadowDom"] = +`
    +
    +
    + + + +
    +
    + + +
    +
    + + + + +
    +
    +
    +`; +/* end snapshot sbb-toast renders Firefox ShadowDom */ + +snapshots["sbb-toast renders A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-toast renders A11y tree Firefox */ + +snapshots["sbb-toast renders A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-toast renders A11y tree Safari */ + diff --git a/src/components/toast/toast.spec.ts b/src/components/toast/toast.spec.ts index a564809bf20..3505dab2e1d 100644 --- a/src/components/toast/toast.spec.ts +++ b/src/components/toast/toast.spec.ts @@ -3,49 +3,43 @@ import { html } from 'lit/static-html.js'; import { isFirefox } from '../core/dom'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import type { SbbToastElement } from './toast'; import './toast'; describe('sbb-toast', () => { - it('renders', async () => { - const root: SbbToastElement = await fixture(html` - 'Lorem ipsum dolor' - `); - - await waitForLitRender(root); - - expect(root).dom.to.be.equal(` - - 'Lorem ipsum dolor' - - `); - expect(root).shadowDom.to.be.equal(` -
    -
    -
    - - - -
    -
    - -
    -
    - - - - -
    -
    -
    - `); + describe('renders', () => { + let elem: SbbToastElement; + + beforeEach(async () => { + elem = await fixture(html` + 'Lorem ipsum dolor' + `); + await waitForLitRender(elem); + }); + + (!isFirefox() ? describe : describe.skip)('Chrome-Safari', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + (isFirefox() ? describe : describe.skip)('Firefox', async () => { + it('Dom', async () => { + await expect(elem).dom.to.be.equalSnapshot(); + }); + + it('ShadowDom', async () => { + await expect(elem).shadowDom.to.be.equalSnapshot(); + }); + }); + + testA11yTreeSnapshot(); }); }); diff --git a/src/components/toggle-check/__snapshots__/toggle-check.spec.snap.js b/src/components/toggle-check/__snapshots__/toggle-check.spec.snap.js new file mode 100644 index 00000000000..df5e6ffdb9a --- /dev/null +++ b/src/components/toggle-check/__snapshots__/toggle-check.spec.snap.js @@ -0,0 +1,229 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-toggle-check renders sbb-toggle-check"] = +` +`; +/* end snapshot sbb-toggle-check renders sbb-toggle-check */ + +snapshots["sbb-toggle-check label position renders label before toggle"] = +` +`; +/* end snapshot sbb-toggle-check label position renders label before toggle */ + +snapshots["sbb-toggle-check states checked state renders toggle in checked state"] = +` +`; +/* end snapshot sbb-toggle-check states checked state renders toggle in checked state */ + +snapshots["sbb-toggle-check states disabled state renders toggle in disabled state"] = +` +`; +/* end snapshot sbb-toggle-check states disabled state renders toggle in disabled state */ + +snapshots["sbb-toggle-check states disabled and checked state renders toggle in disabled and checked state"] = +` +`; +/* end snapshot sbb-toggle-check states disabled and checked state renders toggle in disabled and checked state */ + +snapshots["sbb-toggle-check A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-toggle-check A11y tree Chrome */ + +snapshots["sbb-toggle-check A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​" + } + ] +} +

    +`; +/* end snapshot sbb-toggle-check A11y tree Firefox */ + +snapshots["sbb-toggle-check A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "checkbox", + "name": "​", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-toggle-check A11y tree Safari */ + diff --git a/src/components/toggle-check/toggle-check.spec.ts b/src/components/toggle-check/toggle-check.spec.ts index 63089e44b4d..07ee172fe6b 100644 --- a/src/components/toggle-check/toggle-check.spec.ts +++ b/src/components/toggle-check/toggle-check.spec.ts @@ -2,44 +2,21 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../core/testing'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; import './toggle-check'; describe('sbb-toggle-check', () => { it('renders sbb-toggle-check', async () => { const root = await fixture(html``); + await waitForLitRender(root); expect(root).dom.to.be.equal(` `); - await waitForLitRender(root); - - expect(root).shadowDom.to.be.equal(` - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); describe('label position', () => { @@ -55,29 +32,7 @@ describe('sbb-toggle-check', () => { Check it `); - expect(root).shadowDom.to.be.equal(` - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); @@ -94,30 +49,7 @@ describe('sbb-toggle-check', () => { `, ); - expect(root).shadowDom.to.be.equal(` - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); @@ -131,30 +63,7 @@ describe('sbb-toggle-check', () => { `); - expect(root).shadowDom.to.be.equal(` - - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); @@ -164,38 +73,14 @@ describe('sbb-toggle-check', () => { await waitForLitRender(root); - expect(root).dom.to.be.equal( - ` + expect(root).dom.to.be.equal(` - - `, - ); - expect(root).shadowDom.to.be.equal(` - `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); }); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/toggle/toggle-option/__snapshots__/toggle-option.spec.snap.js b/src/components/toggle/toggle-option/__snapshots__/toggle-option.spec.snap.js index 0b2631553e0..e72f44996b0 100644 --- a/src/components/toggle/toggle-option/__snapshots__/toggle-option.spec.snap.js +++ b/src/components/toggle/toggle-option/__snapshots__/toggle-option.spec.snap.js @@ -72,3 +72,54 @@ snapshots["sbb-toggle-option renders with slotted sbb-icon"] = `; /* end snapshot sbb-toggle-option renders with slotted sbb-icon */ +snapshots["sbb-toggle-option A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-toggle-option A11y tree Chrome */ + +snapshots["sbb-toggle-option A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "radio", + "name": "", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-toggle-option A11y tree Firefox */ + +snapshots["sbb-toggle-option A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "", + "checked": true + } + ] +} +

    +`; +/* end snapshot sbb-toggle-option A11y tree Safari */ + diff --git a/src/components/toggle/toggle-option/toggle-option.spec.ts b/src/components/toggle/toggle-option/toggle-option.spec.ts index 0713be83c10..f70c11a51c5 100644 --- a/src/components/toggle/toggle-option/toggle-option.spec.ts +++ b/src/components/toggle/toggle-option/toggle-option.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import './toggle-option'; import '../../icon'; @@ -67,4 +68,9 @@ describe('sbb-toggle-option', () => { `); await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot( + undefined, + html``, + ); }); diff --git a/src/components/toggle/toggle/__snapshots__/toggle.spec.snap.js b/src/components/toggle/toggle/__snapshots__/toggle.spec.snap.js new file mode 100644 index 00000000000..1065dbcea9f --- /dev/null +++ b/src/components/toggle/toggle/__snapshots__/toggle.spec.snap.js @@ -0,0 +1,68 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-toggle A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "Value one", + "checked": true + }, + { + "role": "radio", + "name": "Value two", + "checked": false + } + ] +} +

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

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "radio", + "name": "Value one", + "checked": true + }, + { + "role": "radio", + "name": "Value two" + } + ] +} +

    +`; +/* end snapshot sbb-toggle A11y tree Firefox */ + +snapshots["sbb-toggle A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "radio", + "name": "Value one", + "checked": true + }, + { + "role": "radio", + "name": "Value two", + "checked": false + } + ] +} +

    +`; +/* end snapshot sbb-toggle A11y tree Safari */ + diff --git a/src/components/toggle/toggle/toggle.spec.ts b/src/components/toggle/toggle/toggle.spec.ts index 4dda9767601..b0ef31e41f5 100644 --- a/src/components/toggle/toggle/toggle.spec.ts +++ b/src/components/toggle/toggle/toggle.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import type { SbbToggleOptionElement } from '../toggle-option'; import type { SbbToggleElement } from './toggle'; @@ -164,4 +165,6 @@ describe('sbb-toggle', () => { expect(option).not.to.have.attribute('disabled'); }); }); + + testA11yTreeSnapshot(undefined, simpleToggleTemplate); }); diff --git a/src/components/tooltip/tooltip-trigger/__snapshots__/tooltip-trigger.spec.snap.js b/src/components/tooltip/tooltip-trigger/__snapshots__/tooltip-trigger.spec.snap.js new file mode 100644 index 00000000000..a909546e3ed --- /dev/null +++ b/src/components/tooltip/tooltip-trigger/__snapshots__/tooltip-trigger.spec.snap.js @@ -0,0 +1,81 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-tooltip-trigger renders"] = +` + + + + +`; +/* end snapshot sbb-tooltip-trigger renders */ + +snapshots["sbb-tooltip-trigger renders with custom content"] = +` + + + + +`; +/* end snapshot sbb-tooltip-trigger renders with custom content */ + +snapshots["sbb-tooltip-trigger A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-tooltip-trigger A11y tree Chrome */ + +snapshots["sbb-tooltip-trigger A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-tooltip-trigger A11y tree Firefox */ + +snapshots["sbb-tooltip-trigger A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +

    +`; +/* end snapshot sbb-tooltip-trigger A11y tree Safari */ + diff --git a/src/components/tooltip/tooltip-trigger/tooltip-trigger.spec.ts b/src/components/tooltip/tooltip-trigger/tooltip-trigger.spec.ts index 4280a35430a..e4b3c5fd536 100644 --- a/src/components/tooltip/tooltip-trigger/tooltip-trigger.spec.ts +++ b/src/components/tooltip/tooltip-trigger/tooltip-trigger.spec.ts @@ -2,6 +2,7 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; import { waitForLitRender } from '../../core/testing'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; import '../../icon'; import './tooltip-trigger'; @@ -15,19 +16,7 @@ describe('sbb-tooltip-trigger', () => { expect(root).dom.to.be.equal( ``, ); - expect(root).shadowDom.to.be.equal( - ` - - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); it('renders with custom content', async () => { @@ -40,17 +29,8 @@ describe('sbb-tooltip-trigger', () => { Custom Content `, ); - expect(root).shadowDom.to.be.equal( - ` - - - - `, - ); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/tooltip/tooltip/__snapshots__/tooltip.spec.snap.js b/src/components/tooltip/tooltip/__snapshots__/tooltip.spec.snap.js new file mode 100644 index 00000000000..807546de0bf --- /dev/null +++ b/src/components/tooltip/tooltip/__snapshots__/tooltip.spec.snap.js @@ -0,0 +1,62 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-tooltip renders"] = +`
    +
    +
    + + + No content + + + + + + +
    +
    +
    +`; +/* end snapshot sbb-tooltip renders */ + +snapshots["sbb-tooltip A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

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

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-tooltip A11y tree Firefox */ + +snapshots["sbb-tooltip A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-tooltip A11y tree Safari */ + diff --git a/src/components/tooltip/tooltip/tooltip.spec.ts b/src/components/tooltip/tooltip/tooltip.spec.ts index b740dcf11f8..2ef8b918520 100644 --- a/src/components/tooltip/tooltip/tooltip.spec.ts +++ b/src/components/tooltip/tooltip/tooltip.spec.ts @@ -1,47 +1,20 @@ import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; -import { i18nCloseTooltip } from '../../core/i18n'; +import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot'; + import './tooltip'; describe('sbb-tooltip', () => { it('renders', async () => { const root = await fixture(html``); - expect(root).dom.to.be.equal( - ` - - - - `, - ); - expect(root).shadowDom.to.be.equal( - ` -
    -
    -
    - - - No content - - - - - -
    -
    -
    - `, - ); + expect(root).dom.to.be.equal(` + + + `); + await expect(root).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); }); diff --git a/src/components/visual-checkbox/__snapshots__/visual-checkbox.spec.snap.js b/src/components/visual-checkbox/__snapshots__/visual-checkbox.spec.snap.js new file mode 100644 index 00000000000..5c1cc9765af --- /dev/null +++ b/src/components/visual-checkbox/__snapshots__/visual-checkbox.spec.snap.js @@ -0,0 +1,57 @@ +/* @web/test-runner snapshot v1 */ +export const snapshots = {}; + +snapshots["sbb-visual-checkbox renders unchecked"] = +` + + + +`; +/* end snapshot sbb-visual-checkbox renders unchecked */ + +snapshots["sbb-visual-checkbox renders checked"] = +` + + + +`; +/* end snapshot sbb-visual-checkbox renders checked */ + +snapshots["sbb-visual-checkbox renders indeterminate"] = +` + + + +`; +/* end snapshot sbb-visual-checkbox renders indeterminate */ + +snapshots["sbb-visual-checkbox A11y tree Chrome"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-visual-checkbox A11y tree Chrome */ + +snapshots["sbb-visual-checkbox A11y tree Firefox"] = +`

    + { + "role": "document", + "name": "" +} +

    +`; +/* end snapshot sbb-visual-checkbox A11y tree Firefox */ + +snapshots["sbb-visual-checkbox A11y tree Safari"] = +`

    + { + "role": "WebArea", + "name": "" +} +

    +`; +/* end snapshot sbb-visual-checkbox A11y tree Safari */ + diff --git a/src/components/visual-checkbox/visual-checkbox.spec.ts b/src/components/visual-checkbox/visual-checkbox.spec.ts index aebb269473c..55485b6b691 100644 --- a/src/components/visual-checkbox/visual-checkbox.spec.ts +++ b/src/components/visual-checkbox/visual-checkbox.spec.ts @@ -1,63 +1,25 @@ -import './visual-checkbox'; - import { expect, fixture } from '@open-wc/testing'; import { html } from 'lit/static-html.js'; +import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot'; + +import './visual-checkbox'; + describe('sbb-visual-checkbox', () => { it('renders unchecked', async () => { - expect(await fixture(html``)).shadowDom.to.be.equal(` - - - - - `); + const elem = await fixture(html``); + await expect(elem).shadowDom.to.be.equalSnapshot(); }); it('renders checked', async () => { - expect(await fixture(html``)).shadowDom.to - .be.equal(` - - - - - - - - `); + const elem = await fixture(html``); + await expect(elem).shadowDom.to.be.equalSnapshot(); }); it('renders indeterminate', async () => { - expect(await fixture(html``)) - .shadowDom.to.be.equal(` - - - - - - - - `); + const elem = await fixture(html``); + await expect(elem).shadowDom.to.be.equalSnapshot(); }); + + testA11yTreeSnapshot(undefined, html``); });