Files
gym-manage/e2e-tests/journeys/exception-log-workflow.spec.ts
张翔 44215d3b2d test(e2e): 改进 Playwright 测试框架和 E2E 测试
- 更新 Playwright 配置,添加认证状态管理和 setup 项目
- 优化 E2E 测试用例,简化测试流程
- 添加 auth-debug.spec.ts 用于调试认证问题
- 添加 playwright/.auth/user.json 认证状态文件
2026-04-18 13:06:07 +08:00

74 lines
2.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { ExceptionLogPage } from '../pages/ExceptionLogPage';
test.describe('异常日志工作流', () => {
let exceptionLogPage: ExceptionLogPage;
test.beforeEach(async ({ page }) => {
exceptionLogPage = new ExceptionLogPage(page);
});
test('查看异常日志列表', async ({ page }) => {
await test.step('导航到异常日志页面', async () => {
await exceptionLogPage.goto();
});
await test.step('验证表格显示', async () => {
await expect(exceptionLogPage.table).toBeVisible({ timeout: 10000 });
});
await test.step('验证数据加载', async () => {
const rowCount = await exceptionLogPage.getLogCount();
console.log(`异常日志列表包含 ${rowCount} 条记录`);
expect(rowCount).toBeGreaterThanOrEqual(0);
});
});
test('搜索异常日志', async ({ page }) => {
await test.step('导航到异常日志页面', async () => {
await exceptionLogPage.goto();
});
await test.step('输入搜索关键词', async () => {
const searchKeyword = 'NullPointerException';
await exceptionLogPage.search(searchKeyword);
});
await test.step('验证搜索结果', async () => {
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(1000);
const rowCount = await exceptionLogPage.getLogCount();
console.log(`搜索结果包含 ${rowCount} 条记录`);
});
});
test('查看异常日志详情', async ({ page }) => {
await test.step('导航到异常日志页面', async () => {
await exceptionLogPage.goto();
});
await test.step('等待数据加载', async () => {
await expect(exceptionLogPage.table).toBeVisible({ timeout: 10000 });
});
await test.step('点击查看详情按钮', async () => {
const detailButton = page.locator('button:has-text("详情")').or(page.locator('.detail-button')).first();
if (await detailButton.isVisible({ timeout: 3000 }).catch(() => false)) {
await detailButton.click();
await test.step('验证详情对话框显示', async () => {
const dialog = page.locator('.el-dialog');
await expect(dialog).toBeVisible({ timeout: 5000 });
console.log('异常日志详情对话框已打开');
});
await test.step('关闭详情对话框', async () => {
await exceptionLogPage.closeDetailDialog();
});
} else {
console.log('当前没有异常日志记录,跳过详情查看测试');
}
});
});
});