import { test, expect } from '@playwright/test' test.describe('页面加载性能测试', () => { test.describe('TC-PERF-E2E-001: 黄历搜索页面加载', () => { test('页面首次加载时间应 < 3s', async ({ page }) => { const startTime = Date.now() await page.goto('/#/pages/almanac-search/index') await page.waitForLoadState('networkidle') await page.waitForTimeout(500) const loadTime = Date.now() - startTime // 验证页面加载完成 const pageContent = page.locator('.page-content') await expect(pageContent).toBeVisible({ timeout: 5000 }) expect(loadTime).toBeLessThan(3000) }) }) test.describe('TC-PERF-E2E-002: 紫微斗数页面加载', () => { test('页面首次加载时间应 < 3s', async ({ page }) => { const startTime = Date.now() await page.goto('/#/pages/ziwei/index') await page.waitForLoadState('networkidle') await page.waitForTimeout(500) const loadTime = Date.now() - startTime const sectionTitle = page.locator('.section-title').first() await expect(sectionTitle).toBeVisible({ timeout: 5000 }) expect(loadTime).toBeLessThan(3000) }) }) test.describe('TC-PERF-E2E-003: 运势分析页面加载', () => { test('页面首次加载时间应 < 3s', async ({ page }) => { const startTime = Date.now() await page.goto('/#/pages/fortune/index') await page.waitForLoadState('networkidle') await page.waitForTimeout(500) const loadTime = Date.now() - startTime const tabs = page.locator('[data-test="fortune-tabs"]') await expect(tabs).toBeVisible({ timeout: 5000 }) expect(loadTime).toBeLessThan(3000) }) }) test.describe('TC-PERF-E2E-004: 响应式性能', () => { test('移动端 375px 视口加载正常', async ({ page }) => { await page.setViewportSize({ width: 375, height: 667 }) const startTime = Date.now() await page.goto('/#/pages/almanac-search/index') await page.waitForLoadState('networkidle') await page.waitForTimeout(500) const loadTime = Date.now() - startTime const pageContent = page.locator('.page-content') await expect(pageContent).toBeVisible({ timeout: 5000 }) expect(loadTime).toBeLessThan(3000) }) test('平板 768px 视口加载正常', async ({ page }) => { await page.setViewportSize({ width: 768, height: 1024 }) const startTime = Date.now() await page.goto('/#/pages/almanac-search/index') await page.waitForLoadState('networkidle') await page.waitForTimeout(500) const loadTime = Date.now() - startTime const pageContent = page.locator('.page-content') await expect(pageContent).toBeVisible({ timeout: 5000 }) expect(loadTime).toBeLessThan(3000) }) }) })