import { test, expect } from '@playwright/test'; test.describe('Web平台兼容性测试', () => { test.describe('TC-001: 页面加载测试', () => { test('所有页面应该能够加载', async ({ page }) => { const pages = [ '/#/pages/almanac-search/index', '/#/pages/ziwei/index', '/#/pages/fortune/index', ] for (const url of pages) { await page.goto(url); await page.waitForLoadState('networkidle'); await page.waitForTimeout(500); const bodyContent = await page.evaluate(() => document.body.innerText); expect(bodyContent.length).toBeGreaterThan(0); } }) }) test.describe('TC-002: 页面渲染测试', () => { test('页面加载时不应该有JS错误', async ({ page }) => { const errors: string[] = []; page.on('console', (msg) => { if (msg.type() === 'error') { errors.push(msg.text()); } }); await page.goto('/#/pages/almanac-search/index'); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1500); const criticalErrors = errors.filter(e => e.includes('TypeError') || e.includes('ReferenceError') || e.includes('SyntaxError') ); expect(criticalErrors.length).toBeLessThan(3); }) }) test.describe('TC-003: 响应式测试', () => { test('移动端视口下页面正常渲染', async ({ page }) => { await page.setViewportSize({ width: 375, height: 667 }); await page.goto('/#/pages/ziwei/index'); await page.waitForLoadState('networkidle'); await page.waitForTimeout(1000); const bodyContent = await page.evaluate(() => document.body.innerText); expect(bodyContent.length).toBeGreaterThan(0); }) }) })