7e54d7fb46
架构改进: - 引入审计日志服务层,实现业务逻辑与数据访问分离 - 添加 Spring Data 审计注解,自动填充创建人、创建时间等字段 - 修复切面范围,避免 Repository 和 Dao 层重复记录 代码优化: - 移除构造函数中的冗余 info 日志,降低生产环境日志量 - 恢复 SQL 文件格式,提高可读性 - 优化 E2E 测试等待策略,移除硬编码等待时间,提高测试稳定性 影响范围: - 后端:审计日志模块(Service、Repository、Aspect、Entity) - 前端:E2E 测试文件(4 个 workflow 测试) - 数据库:审计日志表结构
73 lines
2.5 KiB
TypeScript
73 lines
2.5 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('networkidle');
|
|
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('当前没有异常日志记录,跳过详情查看测试');
|
|
}
|
|
});
|
|
});
|
|
});
|