Skip to content

Commit

Permalink
test(modal): add a11y; visual tests (#1531)
Browse files Browse the repository at this point in the history
* test(modal): add a11y; visual tests

* Set reduceMotion on playwrightLaunchers

* Update modal baseline images

* Update non-modal baseline images 🤷‍♂️

* Revert "Update non-modal baseline images 🤷‍♂️"

This reverts commit cad9ff2.

* Update baseline modal images
  • Loading branch information
dancormier authored Oct 25, 2023
1 parent abac770 commit 330a123
Show file tree
Hide file tree
Showing 100 changed files with 395 additions and 6 deletions.
42 changes: 42 additions & 0 deletions lib/components/modal/modal.a11y.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { html } from "@open-wc/testing";
import { runComponentTests } from "../../test/test-utils";
import { IconClearSm } from "@stackoverflow/stacks-icons/icons";
import "../../index";

describe("modal", () => {
runComponentTests({
type: "a11y",
baseClass: `s-modal`,
variants: ["danger"],
modifiers: {
primary: ["celebration"],
secondary: ["full"],
},
children: {
default: `
<div class="s-modal--dialog" role="document">
<h1 class="s-modal--header" id="modal-title">Modal header</h1>
<p class="s-modal--body" id="modal-description">Modal body. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
<div class="d-flex gx8 s-modal--footer">
<button class="s-btn s-btn__filled" type="button">Confirm</button>
<button class="s-btn s-btn__muted" type="button">Cancel</button>
</div>
<button class="s-modal--close s-btn s-btn__muted" type="button" aria-label="Close">
${IconClearSm}
</button>
</div>
`,
},
tag: "aside",
attributes: {
"id": "example-modal",
"tabindex": "-1",
"aria-hidden": "false",
"aria-labelledby": "modal-title",
"class": "ps-relative p32",
},
template: ({ component, testid }) => html`
<div class="m8 ws6" data-testid="${testid}">${component}</div>
`,
});
});
12 changes: 8 additions & 4 deletions lib/components/modal/modal.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
--_mo-header-fc: var(--fc-dark);

// CONTEXTUAL STYLES
.dark-mode({
--_mo-dialog-bg: var(--black-225);
});

.highcontrast-dark-mode({
--_mo-dialog-bg: var(--black-200);
});

&[aria-hidden="false"] {
&,
.s-modal--dialog {
Expand Down Expand Up @@ -60,10 +68,6 @@
}

& &--dialog {
.dark-mode({
--_mo-dialog-bg: var(--black-225);
});

padding: var(--_mo-dialog-pt) var(--su24) var(--su24);

@scrollbar-styles();
Expand Down
42 changes: 42 additions & 0 deletions lib/components/modal/modal.visual.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { html } from "@open-wc/testing";
import { runComponentTests } from "../../test/test-utils";
import { IconClearSm } from "@stackoverflow/stacks-icons/icons";
import "../../index";

describe("modal", () => {
runComponentTests({
type: "visual",
baseClass: `s-modal`,
variants: ["danger"],
modifiers: {
primary: ["celebration"],
secondary: ["full"],
},
children: {
default: `
<div class="s-modal--dialog" role="document">
<h1 class="s-modal--header" id="modal-title">Modal header</h1>
<p class="s-modal--body" id="modal-description">Modal body. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
<div class="d-flex gx8 s-modal--footer">
<button class="s-btn s-btn__filled" type="button">Confirm</button>
<button class="s-btn s-btn__muted" type="button">Cancel</button>
</div>
<button class="s-modal--close s-btn s-btn__muted" type="button" aria-label="Close">
${IconClearSm}
</button>
</div>
`,
},
tag: "aside",
attributes: {
"id": "example-modal",
"tabindex": "-1",
"aria-hidden": "false",
"aria-labelledby": "modal-title",
"class": "ps-relative p32",
},
template: ({ component, testid }) => html`
<div class="m8 ws6" data-testid="${testid}">${component}</div>
`,
});
});
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 screenshots/Chromium/baseline/s-modal-dark-celebration.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 screenshots/Chromium/baseline/s-modal-dark-danger-full.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 screenshots/Chromium/baseline/s-modal-dark-danger.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 screenshots/Chromium/baseline/s-modal-dark-full.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 screenshots/Chromium/baseline/s-modal-dark.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.
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.
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 screenshots/Chromium/baseline/s-modal-highcontrast-dark.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.
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.
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 screenshots/Chromium/baseline/s-modal-highcontrast-light.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 screenshots/Chromium/baseline/s-modal-light-celebration.png
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-modal-light-danger-full.png
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-modal-light-danger.png
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-modal-light-full.png
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-modal-light.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-dark-celebration.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-dark-danger-full.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-dark-danger.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-dark-full.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-dark.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-highcontrast-dark.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-highcontrast-light.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-light-celebration.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-light-danger-full.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-light-danger.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-light-full.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-modal-light.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark-celebration-full.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark-celebration.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark-danger-full.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark-danger.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark-full.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-modal-dark.png
Loading

0 comments on commit 330a123

Please sign in to comment.