Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3268,7 +3268,7 @@ h2 {
--blue-dark: #073d24;
--green: #157044;
--green-soft: #edf5ef;
--brass: #9b722d;
--brass: #7a541c;
--shadow: 0 26px 70px rgba(9, 34, 21, 0.09);
--radius: 4px;
--max: 1280px;
Expand Down
20 changes: 20 additions & 0 deletions tests/site-quality.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ test("homepage has no automated WCAG A or AA violations", async ({ page }) => {
await expectNoAxeViolations(page);
});

test("small brass labels retain WCAG AA contrast on white surfaces", async ({ page }) => {
await page.goto("/");

for (const label of [page.locator(".trust-grid article span").first(), page.locator(".popular").first()]) {
const contrast = await label.evaluate((element) => {
const values = getComputedStyle(element).color.match(/[\d.]+/g)?.slice(0, 3).map(Number);
if (!values || values.length !== 3) return 0;

const luminance = values
.map((value) => value / 255)
.map((value) => (value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4))
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);

return 1.05 / (luminance + 0.05);
});

expect(contrast).toBeGreaterThanOrEqual(4.5);
}
});

test("skip link moves keyboard focus to the main content", async ({ page }) => {
await page.goto("/");
await page.keyboard.press("Tab");
Expand Down