full upgrade to dev
This commit is contained in:
85
e2e/accessibility.spec.ts
Normal file
85
e2e/accessibility.spec.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Accessibility Tests
|
||||
* Basic accessibility checks
|
||||
*/
|
||||
test.describe('Accessibility Tests', () => {
|
||||
test('Home page has proper heading structure', async ({ page }) => {
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
// Check for h1
|
||||
const h1 = page.locator('h1');
|
||||
const h1Count = await h1.count();
|
||||
|
||||
// Should have at least one h1
|
||||
expect(h1Count).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('Images have alt text', async ({ page }) => {
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
const images = page.locator('img');
|
||||
const imageCount = await images.count();
|
||||
|
||||
if (imageCount > 0) {
|
||||
// Check first few images have alt text
|
||||
for (let i = 0; i < Math.min(5, imageCount); i++) {
|
||||
const img = images.nth(i);
|
||||
const alt = await img.getAttribute('alt');
|
||||
|
||||
// Alt should exist (can be empty for decorative images)
|
||||
expect(alt).not.toBeNull();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Links have descriptive text', async ({ page }) => {
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
const links = page.locator('a[href]');
|
||||
const linkCount = await links.count();
|
||||
|
||||
if (linkCount > 0) {
|
||||
// Check first few links have text or aria-label
|
||||
for (let i = 0; i < Math.min(5, linkCount); i++) {
|
||||
const link = links.nth(i);
|
||||
const text = await link.textContent();
|
||||
const ariaLabel = await link.getAttribute('aria-label');
|
||||
|
||||
// Should have text or aria-label
|
||||
expect(text?.trim().length || ariaLabel?.length).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Forms have labels', async ({ page }) => {
|
||||
await page.goto('/manage', { waitUntil: 'domcontentloaded' });
|
||||
|
||||
const inputs = page.locator('input, textarea, select');
|
||||
const inputCount = await inputs.count();
|
||||
|
||||
if (inputCount > 0) {
|
||||
// Check that inputs have associated labels or aria-labels
|
||||
for (let i = 0; i < Math.min(5, inputCount); i++) {
|
||||
const input = inputs.nth(i);
|
||||
const id = await input.getAttribute('id');
|
||||
const ariaLabel = await input.getAttribute('aria-label');
|
||||
const placeholder = await input.getAttribute('placeholder');
|
||||
const type = await input.getAttribute('type');
|
||||
|
||||
// Skip hidden inputs
|
||||
if (type === 'hidden') continue;
|
||||
|
||||
// Should have label, aria-label, or placeholder
|
||||
if (id) {
|
||||
const label = page.locator(`label[for="${id}"]`);
|
||||
const hasLabel = await label.count() > 0;
|
||||
expect(hasLabel || ariaLabel || placeholder).toBeTruthy();
|
||||
} else {
|
||||
expect(ariaLabel || placeholder).toBeTruthy();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user