From 78b009845570f9c0230a1eefb816ab8dcb9c8513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Tue, 7 Apr 2026 13:02:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(e2e):=20=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E5=85=83=E7=B4=A0=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E5=99=A8=E5=92=8C=E7=AD=89=E5=BE=85=E6=97=B6=E9=97=B4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - 表单字段定位器使用placeholder,但实际字段没有placeholder - 测试用例查找不存在的"备注"字段 - 菜单导航缺少等待时间,导致页面加载不完整 - URL验证缺少超时设置 修复: - admin-complete-workflow.spec.ts: 使用label文本定位表单字段,移除备注字段 - audit-workflow.spec.ts: 添加页面加载等待和超时设置 - system-config-workflow.spec.ts: 添加页面加载等待和超时设置 优势: - 提高测试稳定性 - 减少因时序问题导致的失败 - 更准确的元素定位 --- .../e2e/journeys/admin-complete-workflow.spec.ts | 6 ++---- novalon-manage-web/e2e/journeys/audit-workflow.spec.ts | 8 +++++++- .../e2e/journeys/system-config-workflow.spec.ts | 5 ++++- novalon-manage-web/playwright/.auth/user.json | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/novalon-manage-web/e2e/journeys/admin-complete-workflow.spec.ts b/novalon-manage-web/e2e/journeys/admin-complete-workflow.spec.ts index d784d48..3124b8b 100644 --- a/novalon-manage-web/e2e/journeys/admin-complete-workflow.spec.ts +++ b/novalon-manage-web/e2e/journeys/admin-complete-workflow.spec.ts @@ -22,10 +22,8 @@ test.describe('管理员完整工作流', () => { }); await test.step('填写角色信息', async () => { - await page.locator('input[placeholder*="角色名称"]').fill(roleName); - await page.locator('input[placeholder*="角色标识"]').fill(roleKey); - await page.locator('input[placeholder*="排序"]').fill('1'); - await page.locator('textarea[placeholder*="备注"]').fill('测试角色'); + await page.locator('.el-dialog').locator('text=角色名称').locator('..').locator('input').fill(roleName); + await page.locator('.el-dialog').locator('text=角色标识').locator('..').locator('input').fill(roleKey); }); await test.step('提交表单', async () => { diff --git a/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts b/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts index 11835c4..257e169 100644 --- a/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts +++ b/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts @@ -19,9 +19,12 @@ test.describe('审计工作流', () => { await test.step('导航到操作日志', async () => { await page.goto('/dashboard'); + await page.waitForLoadState('networkidle'); await page.locator('text=审计中心').click(); + await page.waitForTimeout(500); await page.locator('text=操作日志').click(); - await expect(page.locator('table')).toBeVisible(); + await page.waitForLoadState('networkidle'); + await expect(page.locator('table')).toBeVisible({ timeout: 10000 }); }); await test.step('验证操作日志记录', async () => { @@ -34,8 +37,11 @@ test.describe('审计工作流', () => { test('查看登录日志', async ({ page }) => { await test.step('导航到登录日志', async () => { await page.goto('/dashboard'); + await page.waitForLoadState('networkidle'); await page.locator('text=审计中心').click(); + await page.waitForTimeout(500); await page.locator('text=登录日志').click(); + await page.waitForLoadState('networkidle'); }); await test.step('验证登录日志显示', async () => { diff --git a/novalon-manage-web/e2e/journeys/system-config-workflow.spec.ts b/novalon-manage-web/e2e/journeys/system-config-workflow.spec.ts index 07a17b0..512593d 100644 --- a/novalon-manage-web/e2e/journeys/system-config-workflow.spec.ts +++ b/novalon-manage-web/e2e/journeys/system-config-workflow.spec.ts @@ -4,9 +4,12 @@ test.describe('系统配置工作流', () => { test('查看系统配置', async ({ page }) => { await test.step('导航到系统配置', async () => { await page.goto('/dashboard'); + await page.waitForLoadState('networkidle'); await page.locator('text=系统配置').click(); + await page.waitForTimeout(500); await page.locator('text=参数配置').click(); - await expect(page).toHaveURL(/.*sys\/config/); + await page.waitForLoadState('networkidle'); + await expect(page).toHaveURL(/.*sys\/config/, { timeout: 10000 }); }); await test.step('验证配置列表显示', async () => { diff --git a/novalon-manage-web/playwright/.auth/user.json b/novalon-manage-web/playwright/.auth/user.json index 2b760e6..de41294 100644 --- a/novalon-manage-web/playwright/.auth/user.json +++ b/novalon-manage-web/playwright/.auth/user.json @@ -14,7 +14,7 @@ }, { "name": "token", - "value": "eyJhbGciOiJIUzM4NCJ9.eyJyb2xlcyI6W10sInVzZXJJZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzc1NTM2NDg2LCJleHAiOjE3NzU2MjI4ODZ9.8vPn7-X9UH8g6Bv8qakwamYyjnAXjD8u8NHtLtjSHmLhjfm8e7D4MV_yhjYS6rer" + "value": "eyJhbGciOiJIUzM4NCJ9.eyJyb2xlcyI6W10sInVzZXJJZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzc1NTM3MTg5LCJleHAiOjE3NzU2MjM1ODl9.4CVanBsGt6lzp3CTNeQJI8VRVFKVa2DFHffEUo_ybu55Tccy4taSGFYAgdCmTt5v" } ] }