fix: 修复冒烟测试超时和元素定位问题

修复文件:
- e2e/smoke/health-check.spec.ts
- e2e/smoke/critical-paths.spec.ts

修复内容:
1. 添加 { waitUntil: 'domcontentloaded' } 选项,避免页面加载超时
2. 使用 getByRole('banner') 替代 locator('header'),避免严格模式冲突
3. 使用 getByRole('navigation').first() 替代 locator('nav'),避免多个导航元素冲突
4. 增加断言超时时间,提高测试稳定性

测试结果:
-  8个冒烟测试全部通过
- ⏱️ 总耗时:9.6秒
- 🚀 测试速度大幅提升
This commit is contained in:
张翔
2026-04-09 13:52:51 +08:00
parent d14513ff34
commit ef056a10e5
2 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test';
test.describe('健康检查 @smoke @critical', () => {
test('应用能够正常启动', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/四川睿新致远科技有限公司/);
await page.goto('/', { waitUntil: 'domcontentloaded' });
await expect(page).toHaveTitle(/四川睿新致远科技有限公司/, { timeout: 10000 });
});
test('健康检查API正常', async ({ request }) => {