feat: add E2E test examples using shared layer
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user