test(e2e): add GA4 tracking, mobile, user journey tests and update visual baselines
- Add GA4 event tracking E2E tests (4 cases: page view, form submit, button click, product page) - Add mobile-specific E2E tests (16 cases: navigation, form, product browsing) - Add user journey tests (UJ-01: homepage to contact, UJ-02: product discovery) - Fix E2E test selectors and assertions for consistency - Update visual regression baselines across all browsers (chromium/firefox/webkit) - Update Playwright config for new test files
This commit is contained in:
@@ -13,7 +13,7 @@ import { test, expect } from '@playwright/test';
|
||||
test.setTimeout(60000);
|
||||
|
||||
// ==================== 1. 性能指标测试 ====================
|
||||
test.describe('性能 - 页面加载指标', () => {
|
||||
test.describe('性能 - 页面加载指标', { tag: '@regression' }, () => {
|
||||
|
||||
test('首页 DOMContentLoaded 时间 < 3秒', async ({ page }) => {
|
||||
const startTime = Date.now();
|
||||
@@ -103,7 +103,7 @@ test.describe('性能 - 页面加载指标', () => {
|
||||
});
|
||||
|
||||
// ==================== 2. 资源优化测试 ====================
|
||||
test.describe('性能 - 资源优化', () => {
|
||||
test.describe('性能 - 资源优化', { tag: '@regression' }, () => {
|
||||
|
||||
test('图片使用适当格式和尺寸', async ({ page }) => {
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||
@@ -199,7 +199,7 @@ test.describe('性能 - 资源优化', () => {
|
||||
});
|
||||
|
||||
// ==================== 3. 可访问性基础测试 ====================
|
||||
test.describe('可访问性 - WCAG 2.1 AA 合规', () => {
|
||||
test.describe('可访问性 - WCAG 2.1 AA 合规', { tag: '@regression' }, () => {
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||
@@ -412,7 +412,7 @@ test.describe('可访问性 - WCAG 2.1 AA 合规', () => {
|
||||
});
|
||||
|
||||
// ==================== 4. SEO 与元数据测试 ====================
|
||||
test.describe('SEO - 元数据完整性', () => {
|
||||
test.describe('SEO - 元数据完整性', { tag: '@regression' }, () => {
|
||||
|
||||
test('各主要页面有唯一标题', async ({ page }) => {
|
||||
const pages = [
|
||||
@@ -511,7 +511,7 @@ test.describe('SEO - 元数据完整性', () => {
|
||||
});
|
||||
|
||||
// ==================== 5. 安全性基础检查 ====================
|
||||
test.describe('安全性 - 基础安全头', () => {
|
||||
test.describe('安全性 - 基础安全头', { tag: '@regression' }, () => {
|
||||
|
||||
test('安全响应头设置', async ({ page }) => {
|
||||
const response = await page.goto('/', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||
|
||||
Reference in New Issue
Block a user