test: add Playwright + axe specs for home, archive, single

This commit is contained in:
Keith Solomon
2026-08-16 13:48:53 -05:00
parent 6dcd1233be
commit 7d381e2d2e
3 changed files with 89 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
const { test, expect } = require('@playwright/test');
const AxeBuilder = require('@axe-core/playwright').default;
test.use({ viewport: { width: 1920, height: 1080 } });
test.describe('home', () => {
test('home renders Carbon Blue hero + recent projects + zero axe violations', async ({ page }, testInfo) => {
await page.goto('/');
await page.screenshot({ path: 'test-results/home.png', fullPage: true });
// Hero region must be present.
await expect(page.locator('.home-hero')).toBeVisible();
// Either the grid OR the empty state must be present.
const grid = page.locator('.home-recent__grid');
const empty = page.locator('.home-recent__empty');
await expect(grid.or(empty)).toBeVisible();
const results = await new AxeBuilder({ page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22a', 'wcag22aa'])
.analyze();
await testInfo.attach('axe', {
body: JSON.stringify(results, null, 2),
contentType: 'application/json',
});
expect(results.violations).toEqual([]);
});
});