@newjersey/njwds 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/README.md +10 -0
- package/dist/css/button.css +1 -1
- package/dist/css/button.css.map +1 -1
- package/dist/css/icon.css +1 -1
- package/dist/css/icon.css.map +1 -1
- package/dist/css/styles.css +2 -2
- package/dist/css/styles.css.map +1 -1
- package/package.json +18 -5
- package/src/components/02-buttons/buttons.njk +4 -4
- package/src/sass/_uswds-theme-custom-styles.scss +12 -326
- package/src/sass/_uswds-theme.scss +2 -2
- package/src/sass/button.scss +3 -68
- package/src/sass/icon.scss +2 -69
- package/src/sass/styles.scss +1 -65
- package/src/sass/theme/nj-banner/index.scss +1 -0
- package/src/sass/theme/nj-banner/nj-banner.scss +57 -0
- package/src/sass/theme/nj-button/index.scss +6 -0
- package/src/sass/theme/nj-button/nj-button-icon.scss +12 -0
- package/src/sass/theme/nj-button/nj-button-outline.scss +55 -0
- package/src/sass/theme/nj-button/nj-button-primary.scss +22 -0
- package/src/sass/theme/nj-button/nj-button-secondary.scss +15 -0
- package/src/sass/theme/nj-button/nj-button-unstyled.scss +48 -0
- package/src/sass/theme/nj-button/nj-button.scss +12 -0
- package/src/sass/theme/nj-error-message/index.scss +1 -0
- package/src/sass/theme/nj-error-message/nj-error-message.scss +19 -0
- package/src/sass/theme/nj-forms/index.scss +1 -0
- package/src/sass/theme/nj-forms/nj-forms.scss +39 -0
- package/src/sass/theme/nj-header/index.scss +1 -0
- package/src/sass/theme/nj-header/nj-header.scss +8 -0
- package/src/sass/theme/nj-hero/index.scss +1 -0
- package/src/sass/theme/nj-hero/nj-hero.scss +6 -0
- package/src/sass/theme/nj-icon/index.scss +1 -0
- package/src/sass/theme/nj-icon/nj-icon.scss +21 -0
- package/src/sass/theme/nj-intro/index.scss +1 -0
- package/src/sass/theme/nj-intro/nj-intro.scss +5 -0
- package/src/sass/theme/nj-nav/index.scss +1 -0
- package/src/sass/theme/nj-nav/nj-nav.scss +7 -0
- package/src/sass/theme/nj-prose/index.scss +1 -0
- package/src/sass/theme/nj-prose/nj-prose.scss +14 -0
- package/src/sass/theme/nj-section/index.scss +1 -0
- package/src/sass/theme/nj-section/nj-section.scss +6 -0
- package/src/tests/__screenshots__/banner/banner.visual.spec.ts/banner-narrow.png +0 -0
- package/src/tests/__screenshots__/banner/banner.visual.spec.ts/banner-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-danger.visual.spec.ts/button-danger-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-danger.visual.spec.ts/button-danger-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-dark.visual.spec.ts/button-dark-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-dark.visual.spec.ts/button-dark-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary-danger.visual.spec.ts/button-secondary-danger-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary-danger.visual.spec.ts/button-secondary-danger-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary-dark.visual.spec.ts/button-secondary-dark-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary-dark.visual.spec.ts/button-secondary-dark-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary.visual.spec.ts/button-secondary-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-secondary.visual.spec.ts/button-secondary-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary-danger.visual.spec.ts/button-tertiary-danger-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary-danger.visual.spec.ts/button-tertiary-danger-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary-dark.visual.spec.ts/button-tertiary-dark-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary-dark.visual.spec.ts/button-tertiary-dark-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary.visual.spec.ts/button-tertiary-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button-tertiary.visual.spec.ts/button-tertiary-wide.png +0 -0
- package/src/tests/__screenshots__/button/visual/button.visual.spec.ts/button-narrow.png +0 -0
- package/src/tests/__screenshots__/button/visual/button.visual.spec.ts/button-wide.png +0 -0
- package/src/tests/banner/banner.accessibility.spec.ts +28 -0
- package/src/tests/banner/banner.visual.spec.ts +35 -0
- package/src/tests/button/accessibility/button-danger.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-dark.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-secondary-danger.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-secondary-dark.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-secondary.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-tertiary-danger.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-tertiary-dark.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button-tertiary.accessibility.spec.ts +30 -0
- package/src/tests/button/accessibility/button.accessibility.spec.ts +30 -0
- package/src/tests/button/visual/button-danger.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-dark.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-secondary-danger.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-secondary-dark.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-secondary.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-tertiary-danger.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-tertiary-dark.visual.spec.ts +35 -0
- package/src/tests/button/visual/button-tertiary.visual.spec.ts +35 -0
- package/src/tests/button/visual/button.visual.spec.ts +35 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
// The base URL for your locally served components.
|
|
5
|
+
const BASE_URL = "http://localhost:3000";
|
|
6
|
+
|
|
7
|
+
// The specific page URL for the Button component preview.
|
|
8
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(light)`;
|
|
9
|
+
|
|
10
|
+
// Group all accessibility tests for the Button component under a single describe block.
|
|
11
|
+
test.describe("Button, secondary - accessibility", () => {
|
|
12
|
+
// Primary axe-core scan for this component.
|
|
13
|
+
test("has no detectable a11y violations", async ({ page }) => {
|
|
14
|
+
// Open the page at the URL defined above.
|
|
15
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
16
|
+
// finished before running the accessibility scan.
|
|
17
|
+
await page.goto(PAGE_URL);
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
|
|
20
|
+
// .include(".usa-button") ensures the scan is scoped to the Button itself.
|
|
21
|
+
const accessibilityScanResults = await new AxeBuilder({ page })
|
|
22
|
+
.include(".usa-button")
|
|
23
|
+
.analyze();
|
|
24
|
+
|
|
25
|
+
// If axe finds any violations, this test will fail, and Playwright will
|
|
26
|
+
// report detailed information about each issue (impact, rule, affected nodes).
|
|
27
|
+
// The empty array assertion ensures only a clean, violation-free component passes.
|
|
28
|
+
expect(accessibilityScanResults.violations).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
// The base URL for your locally served components.
|
|
5
|
+
const BASE_URL = "http://localhost:3000";
|
|
6
|
+
|
|
7
|
+
// The specific page URL for the Button component preview.
|
|
8
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(danger)`;
|
|
9
|
+
|
|
10
|
+
// Group all accessibility tests for the Button component under a single describe block.
|
|
11
|
+
test.describe("Button, tertiary danger - accessibility", () => {
|
|
12
|
+
// Primary axe-core scan for this component.
|
|
13
|
+
test("has no detectable a11y violations", async ({ page }) => {
|
|
14
|
+
// Open the page at the URL defined above.
|
|
15
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
16
|
+
// finished before running the accessibility scan.
|
|
17
|
+
await page.goto(PAGE_URL);
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
|
|
20
|
+
// .include(".usa-button") ensures the scan is scoped to the Button itself.
|
|
21
|
+
const accessibilityScanResults = await new AxeBuilder({ page })
|
|
22
|
+
.include(".usa-button")
|
|
23
|
+
.analyze();
|
|
24
|
+
|
|
25
|
+
// If axe finds any violations, this test will fail, and Playwright will
|
|
26
|
+
// report detailed information about each issue (impact, rule, affected nodes).
|
|
27
|
+
// The empty array assertion ensures only a clean, violation-free component passes.
|
|
28
|
+
expect(accessibilityScanResults.violations).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
// The base URL for your locally served components.
|
|
5
|
+
const BASE_URL = "http://localhost:3000";
|
|
6
|
+
|
|
7
|
+
// The specific page URL for the Button component preview.
|
|
8
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(dark)`;
|
|
9
|
+
|
|
10
|
+
// Group all accessibility tests for the Button component under a single describe block.
|
|
11
|
+
test.describe("Button, tertiary dark - accessibility", () => {
|
|
12
|
+
// Primary axe-core scan for this component.
|
|
13
|
+
test("has no detectable a11y violations", async ({ page }) => {
|
|
14
|
+
// Open the page at the URL defined above.
|
|
15
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
16
|
+
// finished before running the accessibility scan.
|
|
17
|
+
await page.goto(PAGE_URL);
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
|
|
20
|
+
// .include(".usa-button") ensures the scan is scoped to the Button itself.
|
|
21
|
+
const accessibilityScanResults = await new AxeBuilder({ page })
|
|
22
|
+
.include(".usa-button")
|
|
23
|
+
.analyze();
|
|
24
|
+
|
|
25
|
+
// If axe finds any violations, this test will fail, and Playwright will
|
|
26
|
+
// report detailed information about each issue (impact, rule, affected nodes).
|
|
27
|
+
// The empty array assertion ensures only a clean, violation-free component passes.
|
|
28
|
+
expect(accessibilityScanResults.violations).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
// The base URL for your locally served components.
|
|
5
|
+
const BASE_URL = "http://localhost:3000";
|
|
6
|
+
|
|
7
|
+
// The specific page URL for the Button component preview.
|
|
8
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(light)`;
|
|
9
|
+
|
|
10
|
+
// Group all accessibility tests for the Button component under a single describe block.
|
|
11
|
+
test.describe("Button, tertiary - accessibility", () => {
|
|
12
|
+
// Primary axe-core scan for this component.
|
|
13
|
+
test("has no detectable a11y violations", async ({ page }) => {
|
|
14
|
+
// Open the page at the URL defined above.
|
|
15
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
16
|
+
// finished before running the accessibility scan.
|
|
17
|
+
await page.goto(PAGE_URL);
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
|
|
20
|
+
// .include(".usa-button") ensures the scan is scoped to the Button itself.
|
|
21
|
+
const accessibilityScanResults = await new AxeBuilder({ page })
|
|
22
|
+
.include(".usa-button")
|
|
23
|
+
.analyze();
|
|
24
|
+
|
|
25
|
+
// If axe finds any violations, this test will fail, and Playwright will
|
|
26
|
+
// report detailed information about each issue (impact, rule, affected nodes).
|
|
27
|
+
// The empty array assertion ensures only a clean, violation-free component passes.
|
|
28
|
+
expect(accessibilityScanResults.violations).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
// The base URL for your locally served components.
|
|
5
|
+
const BASE_URL = "http://localhost:3000";
|
|
6
|
+
|
|
7
|
+
// The specific page URL for the Button component preview.
|
|
8
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(light)`;
|
|
9
|
+
|
|
10
|
+
// Group all accessibility tests for the Button component under a single describe block.
|
|
11
|
+
test.describe("Button, primary - accessibility", () => {
|
|
12
|
+
// Primary axe-core scan for this component.
|
|
13
|
+
test("has no detectable a11y violations", async ({ page }) => {
|
|
14
|
+
// Open the page at the URL defined above.
|
|
15
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
16
|
+
// finished before running the accessibility scan.
|
|
17
|
+
await page.goto(PAGE_URL);
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
|
|
20
|
+
// .include(".usa-button") ensures the scan is scoped to the Button itself.
|
|
21
|
+
const accessibilityScanResults = await new AxeBuilder({ page })
|
|
22
|
+
.include(".usa-button")
|
|
23
|
+
.analyze();
|
|
24
|
+
|
|
25
|
+
// If axe finds any violations, this test will fail, and Playwright will
|
|
26
|
+
// report detailed information about each issue (impact, rule, affected nodes).
|
|
27
|
+
// The empty array assertion ensures only a clean, violation-free component passes.
|
|
28
|
+
expect(accessibilityScanResults.violations).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(danger)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, danger - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-danger-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(dark)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, dark - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-dark-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(danger)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, secondary danger - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-secondary-danger-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(dark)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, secondary dark - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-secondary-dark-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(light)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, secondary - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-secondary-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(danger)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, tertiary danger - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-tertiary-danger-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(dark)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, tertiary dark - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-tertiary-dark-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(light)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, tertiary - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-tertiary-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "http://localhost:3000";
|
|
4
|
+
const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(light)`;
|
|
5
|
+
|
|
6
|
+
const viewports = [
|
|
7
|
+
{ name: "narrow", width: 375, height: 800 },
|
|
8
|
+
{ name: "wide", width: 1280, height: 800 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
test.describe("Button, primary - visual regression", () => {
|
|
12
|
+
for (const viewport of viewports) {
|
|
13
|
+
test(`renders correctly (${viewport.name})`, async ({ page }) => {
|
|
14
|
+
await page.setViewportSize({
|
|
15
|
+
width: viewport.width,
|
|
16
|
+
height: viewport.height,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Stabilize rendering:
|
|
20
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
21
|
+
|
|
22
|
+
// Open the page at the URL defined above.
|
|
23
|
+
// Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
|
|
24
|
+
// finished before running the test.
|
|
25
|
+
await page.goto(PAGE_URL);
|
|
26
|
+
await page.waitForLoadState("networkidle");
|
|
27
|
+
|
|
28
|
+
// Full-page screenshot
|
|
29
|
+
await expect(page).toHaveScreenshot(`button-${viewport.name}.png`, {
|
|
30
|
+
fullPage: true,
|
|
31
|
+
maxDiffPixelRatio: 0.01, // allow a 1px difference
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|