-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(select): add a11y, visual tests (#1498)
* test(select): add a11y; visual tests * Gimme a "F"! Gimme a "O"! Gimme a "R"! Gimme a… What's that spell? Formatting 😫 * Update baseline images * Update baseline images * Update tests and baseline images * Update baseline images
- Loading branch information
1 parent
e3f479c
commit 3fd2a49
Showing
122 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { html } from "@open-wc/testing"; | ||
import { runA11yTests } from "../../test/a11y-test-utils"; | ||
import "../../index"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const template = ({ component, testid, className }: any) => html` | ||
<div class="d-inline-flex p8 ${className}" data-testid="${testid}"> | ||
${component} | ||
</div> | ||
`; | ||
|
||
const child = (attr?: string): string => { | ||
return ` | ||
<label for="select-menu">Transportation method</label> | ||
<select id="select-menu" ${attr}> | ||
<option value="" selected>Please select one…</option> | ||
<option value="walk">Walk</option> | ||
<option value="bike">Bicycle</option> | ||
<option value="car">Automobile</option> | ||
<option value="rail">Train</option> | ||
<option value="fly">Plane</option> | ||
</select>`; | ||
}; | ||
|
||
describe("select", () => { | ||
// default, sizes | ||
runA11yTests({ | ||
baseClass: "s-select", | ||
modifiers: { | ||
primary: ["sm", "md", "lg", "xl"], | ||
}, | ||
children: { | ||
default: child(), | ||
}, | ||
template, | ||
}); | ||
|
||
// modifier classes | ||
[ | ||
{ | ||
class: "is-disabled", | ||
attr: 'disabled=""', | ||
}, | ||
{ | ||
class: "is-readonly", | ||
attr: 'readonly=""', | ||
}, | ||
{ | ||
class: "has-success", | ||
}, | ||
{ | ||
class: "has-error", | ||
}, | ||
{ | ||
class: "has-warning", | ||
}, | ||
].forEach((state) => { | ||
runA11yTests({ | ||
baseClass: `s-select state-${state.class}`, | ||
children: { | ||
default: child(state.attr), | ||
}, | ||
template: ({ component, testid }) => | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
template({ component, testid, className: state.class }), | ||
options: { | ||
includeNullModifier: false, | ||
}, | ||
skippedTestids: [/readonly/], // Skipping readonly since it doesn't need to meet APCA contrast minimums | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { html } from "@open-wc/testing"; | ||
import { runVisualTests } from "../../test/visual-test-utils"; | ||
import "../../index"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const template = ({ component, testid, className }: any) => html` | ||
<div class="d-inline-flex p8 ${className}" data-testid="${testid}"> | ||
${component} | ||
</div> | ||
`; | ||
|
||
const child = (attr?: string): string => { | ||
return `<select id="select-menu" ${attr}> | ||
<option value="" selected>Please select one…</option> | ||
<option value="walk">Walk</option> | ||
<option value="bike">Bicycle</option> | ||
<option value="car">Automobile</option> | ||
<option value="rail">Train</option> | ||
<option value="fly">Plane</option> | ||
</select>`; | ||
}; | ||
|
||
describe("select", () => { | ||
// default, sizes | ||
runVisualTests({ | ||
baseClass: "s-select", | ||
modifiers: { | ||
primary: ["sm", "md", "lg", "xl"], | ||
}, | ||
children: { | ||
default: child(), | ||
}, | ||
template, | ||
}); | ||
|
||
// modifier classes | ||
[ | ||
{ | ||
class: "is-disabled", | ||
attr: 'disabled=""', | ||
}, | ||
{ | ||
class: "is-readonly", | ||
attr: 'readonly=""', | ||
}, | ||
{ | ||
class: "has-success", | ||
}, | ||
{ | ||
class: "has-error", | ||
}, | ||
{ | ||
class: "has-warning", | ||
}, | ||
].forEach((state) => { | ||
runVisualTests({ | ||
baseClass: "s-select", | ||
modifiers: { | ||
global: [`state-${state.class}`], | ||
}, | ||
children: { | ||
selected: child(state.attr), | ||
}, | ||
template: ({ component, testid }) => | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
template({ component, testid, className: state.class }), | ||
options: { | ||
includeNullModifier: false, | ||
}, | ||
}); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-dark-state-has-error-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-dark-state-has-success-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-dark-state-has-warning-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-dark-state-is-disabled-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-dark-state-is-readonly-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-dark-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-dark-md.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-dark-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...shots/Chromium/baseline/s-select-highcontrast-dark-state-has-error-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/Chromium/baseline/s-select-highcontrast-dark-state-has-success-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/Chromium/baseline/s-select-highcontrast-dark-state-has-warning-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/Chromium/baseline/s-select-highcontrast-dark-state-is-disabled-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ots/Chromium/baseline/s-select-highcontrast-dark-state-is-readonly-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-dark-xl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-light-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-light-md.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-light-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...hots/Chromium/baseline/s-select-highcontrast-light-state-has-error-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ts/Chromium/baseline/s-select-highcontrast-light-state-has-success-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ts/Chromium/baseline/s-select-highcontrast-light-state-has-warning-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...ts/Chromium/baseline/s-select-highcontrast-light-state-is-disabled-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...ts/Chromium/baseline/s-select-highcontrast-light-state-is-readonly-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-light-xl.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-highcontrast-light.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-light-state-has-error-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-light-state-has-success-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-light-state-has-warning-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-light-state-is-disabled-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Chromium/baseline/s-select-light-state-is-readonly-selected.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-dark-state-has-error-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-dark-state-has-success-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-dark-state-has-warning-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-dark-state-is-disabled-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-dark-state-is-readonly-selected.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-dark-lg.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-dark-md.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-dark-sm.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...nshots/Firefox/baseline/s-select-highcontrast-dark-state-has-error-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...hots/Firefox/baseline/s-select-highcontrast-dark-state-has-success-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...hots/Firefox/baseline/s-select-highcontrast-dark-state-has-warning-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...hots/Firefox/baseline/s-select-highcontrast-dark-state-is-disabled-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...hots/Firefox/baseline/s-select-highcontrast-dark-state-is-readonly-selected.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-dark-xl.png
Oops, something went wrong.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-light-lg.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-light-md.png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
screenshots/Firefox/baseline/s-select-highcontrast-light-sm.png
Oops, something went wrong.
Oops, something went wrong.