From da5adbb05caea429219492385341b343bb7ac632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Tue, 7 Apr 2026 08:18:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(e2e):=20=E5=88=9B=E5=BB=BA=E5=AE=A1?= =?UTF-8?q?=E8=AE=A1=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现审计工作流测试: - 执行操作并查看操作日志 - 查看登录日志 - 搜索和筛选日志 --- .../e2e/journeys/audit-workflow.spec.ts | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 novalon-manage-web/e2e/journeys/audit-workflow.spec.ts diff --git a/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts b/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts new file mode 100644 index 0000000..c3d0b35 --- /dev/null +++ b/novalon-manage-web/e2e/journeys/audit-workflow.spec.ts @@ -0,0 +1,90 @@ +import { test, expect } from '@playwright/test'; + +test.describe('审计工作流', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/login'); + await page.locator('input[placeholder*="用户名"]').fill('admin'); + await page.locator('input[placeholder*="密码"]').fill('admin123'); + await page.locator('button:has-text("登录")').click(); + await page.waitForURL('**/dashboard', { timeout: 30000 }); + }); + + test('执行操作并查看操作日志', async ({ page }) => { + await test.step('执行用户管理操作', async () => { + await page.goto('/users'); + await page.waitForTimeout(1000); + }); + + await test.step('执行角色管理操作', async () => { + await page.goto('/roles'); + await page.waitForTimeout(1000); + }); + + await test.step('执行菜单管理操作', async () => { + await page.goto('/menus'); + await page.waitForTimeout(1000); + }); + + await test.step('导航到操作日志', async () => { + await page.goto('/dashboard'); + await page.locator('text=系统监控').click(); + await page.locator('text=操作日志').click(); + await expect(page.locator('table')).toBeVisible(); + }); + + await test.step('验证操作日志记录', async () => { + await page.waitForTimeout(2000); + const logContent = await page.locator('table').textContent(); + expect(logContent).toMatch(/用户管理|角色管理|菜单管理/); + }); + }); + + test('查看登录日志', async ({ page }) => { + await test.step('导航到登录日志', async () => { + await page.goto('/dashboard'); + await page.locator('text=系统监控').click(); + await page.locator('text=登录日志').click(); + }); + + await test.step('验证登录日志显示', async () => { + await expect(page.locator('table')).toBeVisible(); + const logContent = await page.locator('table').textContent(); + expect(logContent).toContain('admin'); + }); + }); + + test('搜索和筛选日志', async ({ page }) => { + await test.step('导航到操作日志', async () => { + await page.goto('/dashboard'); + await page.locator('text=系统监控').click(); + await page.locator('text=操作日志').click(); + await expect(page.locator('table')).toBeVisible(); + }); + + await test.step('按模块筛选', async () => { + const moduleSelect = page.locator('.el-select:has-text("模块")'); + if (await moduleSelect.isVisible()) { + await moduleSelect.click(); + await page.locator('.el-select-dropdown__item:has-text("用户管理")').click(); + await page.waitForTimeout(1000); + } + }); + + await test.step('按时间范围筛选', async () => { + const dateRangePicker = page.locator('.el-date-editor'); + if (await dateRangePicker.isVisible()) { + await dateRangePicker.click(); + await page.waitForTimeout(500); + } + }); + + await test.step('搜索特定内容', async () => { + const searchInput = page.locator('input[placeholder*="搜索"]'); + if (await searchInput.isVisible()) { + await searchInput.fill('admin'); + await page.locator('button:has-text("搜索")').click(); + await page.waitForTimeout(1000); + } + }); + }); +});