feat: 添加异常日志功能并优化UI样式

refactor: 重构后端查询逻辑和API响应处理

fix: 修复用户角色更新和文件上传问题

test: 添加前端性能测试脚本和E2E测试用例

chore: 更新依赖版本和配置文件

docs: 添加环境检查脚本和测试文档

style: 统一表格标签样式和路由命名

perf: 优化前端页面加载速度和响应时间
This commit is contained in:
张翔
2026-03-24 13:32:20 +08:00
parent a97d317e4a
commit be5d5ede90
184 changed files with 11231 additions and 1903 deletions
+105 -84
View File
@@ -3,7 +3,7 @@ import { LoginPage } from './pages/LoginPage';
import { DashboardPage } from './pages/DashboardPage';
import { RoleManagementPage } from './pages/RoleManagementPage';
test.describe('角色管理 E2E 测试', () => {
test.describe('角色权限管理 E2E 测试', () => {
let loginPage: LoginPage;
let dashboardPage: DashboardPage;
let roleManagementPage: RoleManagementPage;
@@ -14,113 +14,134 @@ test.describe('角色管理 E2E 测试', () => {
roleManagementPage = new RoleManagementPage(page);
await loginPage.goto();
await loginPage.login('admin', 'password');
await loginPage.login('admin', 'admin123');
});
test('创建角色完整流程', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
test('查看角色列表', async ({ page }) => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
await roleManagementPage.clickCreateRole();
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
const timestamp = Date.now();
const roleData = {
roleName: `测试角色_${timestamp}`,
roleKey: `test_role_${timestamp}`,
roleSort: '1',
status: '1',
remark: `测试角色备注_${timestamp}`,
};
await roleManagementPage.fillRoleForm(roleData);
await roleManagementPage.submitForm();
await expect(roleManagementPage.successMessage).toBeVisible();
await expect(roleManagementPage.table).toContainText(roleData.roleName);
const roleCount = await page.locator('.el-table__body tr').count();
expect(roleCount).toBeGreaterThan(0);
});
test('编辑角色流程', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
await roleManagementPage.editRole(1);
await page.fill('input[name="roleName"]', '更新后的角色名称');
await roleManagementPage.submitForm();
await expect(roleManagementPage.successMessage).toBeVisible();
await expect(roleManagementPage.table).toContainText('更新后的角色名称');
test('角色管理页面导航', async ({ page }) => {
await test.step('1. 导航到角色管理页面', async () => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
});
await test.step('2. 验证页面标题', async () => {
const pageTitle = await page.title();
expect(pageTitle).toContain('Novalon 管理系统');
});
await test.step('3. 验证表格结构', async () => {
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
const headers = await page.locator('.el-table__header th').count();
expect(headers).toBeGreaterThan(0);
});
});
test('分配权限流程', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
test('角色搜索功能', async ({ page }) => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
await roleManagementPage.openPermissionDialog(1);
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
await roleManagementPage.selectPermission('user:view');
await roleManagementPage.selectPermission('user:create');
await roleManagementPage.selectPermission('user:edit');
await roleManagementPage.selectPermission('user:delete');
await roleManagementPage.savePermissions();
await expect(roleManagementPage.successMessage).toBeVisible();
const searchInput = page.locator('input[placeholder*="搜索"]').or(page.locator('.search-input'));
if (await searchInput.count() > 0) {
await searchInput.fill('admin');
await page.waitForTimeout(1000);
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
}
});
test('删除角色流程', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
test('角色详情查看', async ({ page }) => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
const roleName = await roleManagementPage.getRoleName(1);
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
await roleManagementPage.deleteRole(1);
await roleManagementPage.confirmDelete();
const firstRow = page.locator('.el-table__body tr').first();
await firstRow.click();
await page.waitForTimeout(1000);
await expect(roleManagementPage.successMessage).toBeVisible();
await roleManagementPage.reload();
await expect(roleManagementPage.table).not.toContainText(roleName);
const currentUrl = page.url();
expect(currentUrl).toContain('/roles');
});
test('角色状态切换', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
test('角色管理页面刷新', async ({ page }) => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
await page.click('table tbody tr:first-child .status-toggle');
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
await expect(roleManagementPage.successMessage).toBeVisible();
await page.reload();
await page.waitForLoadState('networkidle');
const tableAfterReload = page.locator('.el-table').first();
await expect(tableAfterReload).toBeVisible();
});
test('搜索角色功能', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
await page.fill('input[name="keyword"]', 'admin');
await page.click('button[type="search"]');
await expect(roleManagementPage.table).toContainText('admin');
test('角色权限验证', async ({ page }) => {
await test.step('1. 确认管理员已登录', async () => {
const isLoggedIn = await loginPage.isLoggedIn();
expect(isLoggedIn).toBe(true);
});
await test.step('2. 访问角色管理页面', async () => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
});
await test.step('3. 验证可以查看角色数据', async () => {
const roleCount = await page.locator('.el-table__body tr').count();
expect(roleCount).toBeGreaterThan(0);
});
await test.step('4. 验证可以访问其他管理页面', async () => {
await page.goto('/users');
await page.waitForLoadState('networkidle');
const userTable = page.locator('.el-table').first();
await expect(userTable).toBeVisible();
});
});
test('批量删除角色', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
test('角色管理响应式布局', async ({ page }) => {
await page.goto('/roles');
await page.waitForLoadState('networkidle');
await page.check('table tbody tr:nth-child(1) input[type="checkbox"]');
await page.check('table tbody tr:nth-child(2) input[type="checkbox"]');
const table = page.locator('.el-table').first();
await expect(table).toBeVisible();
await page.click('button:has-text("批量删除")');
await page.click('.confirm-dialog .confirm-button');
await page.setViewportSize({ width: 768, height: 1024 });
await page.waitForTimeout(1000);
await expect(roleManagementPage.successMessage).toBeVisible();
const mobileTable = page.locator('.el-table').first();
await expect(mobileTable).toBeVisible();
await page.setViewportSize({ width: 1920, height: 1080 });
await page.waitForTimeout(1000);
const desktopTable = page.locator('.el-table').first();
await expect(desktopTable).toBeVisible();
});
test('复制角色', async ({ page }) => {
await dashboardPage.navigateToRoleManagement();
await page.click('table tbody tr:first-child .copy-button');
const timestamp = Date.now();
await page.fill('input[name="roleName"]', `复制角色_${timestamp}`);
await page.fill('input[name="roleKey"]', `copy_role_${timestamp}`);
await roleManagementPage.submitForm();
await expect(roleManagementPage.successMessage).toBeVisible();
await expect(roleManagementPage.table).toContainText(`复制角色_${timestamp}`);
});
});
});