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
+29
View File
@@ -0,0 +1,29 @@
import { test } from '@playwright/test';
import { SEOValidator } from '../../test-framework/shared/utils/seo/SEOValidator';
import { seoThresholds } from '../../test-framework/shared/config/test-data';
test.describe('SEO测试', () => {
test('首页应该通过SEO验证', async ({ page }) => {
const validator = new SEOValidator(page);
await page.goto('/');
const result = await validator.validateSEO();
console.log(`SEO得分: ${result.score}`);
console.log(`Meta标签: ${JSON.stringify(result.metaTags)}`);
console.log(`标题结构: ${JSON.stringify(result.headings)}`);
expect(result.score).toBeGreaterThanOrEqual(seoThresholds.score);
});
test('应该有正确的标题结构', async ({ page }) => {
const validator = new SEOValidator(page);
await page.goto('/');
const headings = await validator.validateHeadings();
expect(headings.hasH1).toBe(true);
expect(headings.multipleH1).toBe(false);
expect(headings.headingStructure).toBe(true);
});
});