Files
everything-is-suitable/everything-is-suitable-uniapp/e2e/web-compatibility-simple.spec.ts
T
zhangxiang 3a428d8977 test: 补充 Phase 3 专项测试并更新测试报告
新增性能基准测试、安全验证、国际化完整性验证等专项测试;
修复 E2E 测试选择器与当前 UI 不匹配问题;
补充多语言 locale 缺失的 key;
更新 Playwright 配置支持跨浏览器测试;
同步更新测试报告与 README 进度章节。

单元测试 408/408 通过,E2E 测试 39/39 通过(4 种浏览器),
专项测试 47/47 通过,整体覆盖率 77.5%。
2026-08-12 20:10:39 +08:00

57 lines
1.8 KiB
TypeScript

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