fix(e2e): 优化测试用例定位器和等待策略

问题:
- 表单字段定位器过于复杂且不稳定
- 对话框打开/关闭缺少等待逻辑
- 菜单导航路径错误
- 页面加载等待时间不足

修复:
- 简化表单字段定位器,使用索引定位
- 添加对话框状态等待(visible/hidden)
- 修正菜单导航路径(系统配置 -> 参数配置/字典管理)
- 增加页面加载等待和超时设置
- 统一菜单导航的等待策略

优势:
- 提高测试稳定性
- 减少元素定位失败
- 确保页面完全加载后再操作
- 更清晰的测试代码结构
This commit is contained in:
张翔
2026-04-07 13:34:57 +08:00
parent d52a1f1204
commit 5938c70b63
3 changed files with 42 additions and 16 deletions
@@ -49,8 +49,12 @@ test.describe('系统配置工作流', () => {
test('字典管理流程', async ({ page }) => {
await test.step('导航到字典管理', async () => {
await page.goto('/dashboard');
await page.locator('text=系统管理').click();
await page.waitForLoadState('networkidle');
await page.locator('text=系统配置').click();
await page.waitForTimeout(500);
await page.locator('text=字典管理').click();
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(/.*dict/, { timeout: 10000 });
});
await test.step('查看字典列表', async () => {
@@ -70,8 +74,12 @@ test.describe('系统配置工作流', () => {
test('参数管理流程', async ({ page }) => {
await test.step('导航到参数管理', async () => {
await page.goto('/dashboard');
await page.locator('text=系统管理').click();
await page.locator('text=参数管理').click();
await page.waitForLoadState('networkidle');
await page.locator('text=系统配置').click();
await page.waitForTimeout(500);
await page.locator('text=参数配置').click();
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(/.*sys\/config/, { timeout: 10000 });
});
await test.step('查看参数列表', async () => {