Files

30 lines
1.0 KiB
TypeScript

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);
});
});