test(e2e): 改进 Playwright 测试框架和 E2E 测试
- 更新 Playwright 配置,添加认证状态管理和 setup 项目 - 优化 E2E 测试用例,简化测试流程 - 添加 auth-debug.spec.ts 用于调试认证问题 - 添加 playwright/.auth/user.json 认证状态文件
This commit is contained in:
@@ -19,13 +19,16 @@ test.describe('审计工作流', () => {
|
||||
|
||||
await test.step('导航到操作日志', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('text=审计日志').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('text=审计日志').click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('.el-menu-item:has-text("操作日志")').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('.el-menu-item:has-text("操作日志")').click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await expect(page).toHaveURL(/.*oplog/, { timeout: 10000 });
|
||||
@@ -42,16 +45,19 @@ test.describe('审计工作流', () => {
|
||||
test('查看登录日志', async ({ page }) => {
|
||||
await test.step('导航到登录日志', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('text=审计日志').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('text=审计日志').click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('.el-menu-item:has-text("登录日志")').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('.el-menu-item:has-text("登录日志")').click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await expect(page).toHaveURL(/.*loginlog/, { timeout: 10000 });
|
||||
await expect(page).toHaveURL(/.*loginlog/, { timeout: 15000 });
|
||||
});
|
||||
|
||||
await test.step('验证登录日志显示', async () => {
|
||||
@@ -65,13 +71,16 @@ test.describe('审计工作流', () => {
|
||||
test('搜索和筛选日志', async ({ page }) => {
|
||||
await test.step('导航到操作日志', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('text=审计日志').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('text=审计日志').click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.locator('.el-menu-item:has-text("操作日志")').waitFor({ state: 'visible', timeout: 5000 });
|
||||
await page.locator('.el-menu-item:has-text("操作日志")').click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
Reference in New Issue
Block a user