import { test } from '@playwright/test'; import { AccessibilityTester } from '../../test-framework/shared/utils/accessibility/AccessibilityTester'; import { accessibilityThresholds } from '../../test-framework/shared/config/test-data'; test.describe('可访问性测试', () => { test('首页应该通过可访问性检查', async ({ page }) => { const tester = new AccessibilityTester(page); await page.goto('/'); const result = await tester.runAxeScan('首页', '/'); console.log(`可访问性得分: ${result.score}`); console.log(`违规数量: ${result.violations.length}`); expect(result.score).toBeGreaterThanOrEqual(accessibilityThresholds.score); expect(result.violations.length).toBeLessThanOrEqual(accessibilityThresholds.maxViolations); }); test('所有图片应该有Alt文本', async ({ page }) => { const tester = new AccessibilityTester(page); await page.goto('/'); const result = await tester.checkAltText(); console.log(`图片总数: ${result.total}`); console.log(`有Alt文本: ${result.withAlt}`); console.log(`无Alt文本: ${result.withoutAlt}`); expect(result.withoutAlt).toBe(0); }); });