08ea5fbe98
添加用户管理视图、API和状态管理文件
102 lines
3.8 KiB
TypeScript
102 lines
3.8 KiB
TypeScript
/**
|
|
* OperationLogManagement页面E2E测试
|
|
*
|
|
* 测试操作日志管理页面的所有功能和交互
|
|
*
|
|
* @tags @operation-log @e2e @view
|
|
*/
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
import { TestLogger } from '../core/test-logger.js';
|
|
|
|
test.describe('E2E: OperationLogManagement页面', () => {
|
|
let logger: TestLogger;
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
logger = new TestLogger();
|
|
// 先登录
|
|
await page.goto('http://localhost:5174/login');
|
|
await page.fill('input[placeholder="请输入用户名"]', 'admin');
|
|
await page.fill('input[placeholder="请输入密码"]', 'admin123');
|
|
await page.click('button:has-text("登录")');
|
|
await page.waitForURL('**/dashboard');
|
|
|
|
// 导航到操作日志页面
|
|
await page.click('.el-menu-item:has-text("操作日志")');
|
|
await page.waitForURL('**/operation-log');
|
|
});
|
|
|
|
test('应该显示操作日志页面 @smoke', async ({ page }) => {
|
|
await expect(page.locator('.operation-log, .el-table')).toBeVisible();
|
|
await expect(page.locator('.el-pagination')).toBeVisible();
|
|
});
|
|
|
|
test('应该显示日志列表 @smoke', async ({ page }) => {
|
|
await expect(page.locator('.el-table__row')).toHaveCount.greaterThan(0);
|
|
const headers = ['操作人', '操作类型', '操作内容', '操作时间', 'IP地址'];
|
|
for (const header of headers) {
|
|
await expect(page.locator(`.el-table__header:has-text("${header}")`)).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够搜索日志 @regression', async ({ page }) => {
|
|
const searchInput = page.locator('.search-input, input[placeholder*="搜索"]').first();
|
|
if (await searchInput.isVisible()) {
|
|
await searchInput.fill('admin');
|
|
await searchInput.press('Enter');
|
|
await page.waitForTimeout(500);
|
|
await expect(page.locator('.el-table__row')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够按日期筛选 @regression', async ({ page }) => {
|
|
const datePicker = page.locator('.el-date-picker, .date-range-picker').first();
|
|
if (await datePicker.isVisible()) {
|
|
await datePicker.click();
|
|
// 选择日期范围
|
|
const startDate = page.locator('.el-picker-panel .available').first();
|
|
await startDate.click();
|
|
const endDate = page.locator('.el-picker-panel .available').nth(5);
|
|
await endDate.click();
|
|
await page.waitForTimeout(500);
|
|
await expect(page.locator('.el-table__row')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够查看日志详情 @regression', async ({ page }) => {
|
|
const detailBtn = page.locator('.el-table__row .el-button:has-text("详情"), .el-table__row .detail-btn').first();
|
|
if (await detailBtn.isVisible()) {
|
|
await detailBtn.click();
|
|
await expect(page.locator('.el-dialog:has-text("日志详情")')).toBeVisible();
|
|
await expect(page.locator('.el-dialog .detail-content')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够导出日志 @regression', async ({ page }) => {
|
|
const exportBtn = page.locator('button:has-text("导出"), .export-btn').first();
|
|
if (await exportBtn.isVisible()) {
|
|
await exportBtn.click();
|
|
// 验证导出成功提示
|
|
await expect(page.locator('.el-message--success')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够分页 @regression', async ({ page }) => {
|
|
const nextBtn = page.locator('.el-pagination .btn-next').first();
|
|
if (await nextBtn.isVisible() && await nextBtn.isEnabled()) {
|
|
await nextBtn.click();
|
|
await page.waitForTimeout(500);
|
|
await expect(page.locator('.el-table__row')).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('应该能够清空筛选条件 @regression', async ({ page }) => {
|
|
const resetBtn = page.locator('button:has-text("重置"), .reset-btn').first();
|
|
if (await resetBtn.isVisible()) {
|
|
await resetBtn.click();
|
|
await page.waitForTimeout(500);
|
|
await expect(page.locator('.el-table__row')).toBeVisible();
|
|
}
|
|
});
|
|
});
|