feat: add E2E test examples using shared layer

This commit is contained in:
张翔
2026-03-06 12:14:51 +08:00
parent 0c1716d97e
commit e164313b87
5 changed files with 136 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
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);
});
});