feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* MenuManagement页面E2E测试
|
||||
*
|
||||
* 测试菜单管理页面的所有功能和交互
|
||||
*
|
||||
* @tags @menu-management @e2e @view
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TestLogger } from '../core/test-logger.js';
|
||||
|
||||
test.describe('E2E: MenuManagement页面', () => {
|
||||
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('**/menu-management');
|
||||
});
|
||||
|
||||
test('应该显示菜单管理页面 @smoke', async ({ page }) => {
|
||||
await expect(page.locator('.menu-management, .el-tree')).toBeVisible();
|
||||
});
|
||||
|
||||
test('应该显示菜单树 @smoke', async ({ page }) => {
|
||||
await expect(page.locator('.el-tree-node')).toHaveCount.greaterThan(0);
|
||||
});
|
||||
|
||||
test('应该能够展开/收起菜单节点 @regression', async ({ page }) => {
|
||||
const expandIcon = page.locator('.el-tree-node__expand-icon').first();
|
||||
if (await expandIcon.isVisible()) {
|
||||
await expandIcon.click();
|
||||
await page.waitForTimeout(300);
|
||||
// 验证子节点显示
|
||||
await expect(page.locator('.el-tree-node__children')).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('应该能够打开新增菜单对话框 @critical', async ({ page }) => {
|
||||
const addBtn = page.locator('button:has-text("新增"), .add-btn').first();
|
||||
await addBtn.click();
|
||||
await expect(page.locator('.el-dialog:has-text("新增菜单")')).toBeVisible();
|
||||
});
|
||||
|
||||
test('应该能够创建新菜单 @critical', async ({ page }) => {
|
||||
const addBtn = page.locator('button:has-text("新增"), .add-btn').first();
|
||||
await addBtn.click();
|
||||
await page.fill('.el-dialog input[placeholder*="菜单名称"]', '测试菜单');
|
||||
await page.fill('.el-dialog input[placeholder*="路由路径"]', '/test');
|
||||
const submitBtn = page.locator('.el-dialog button:has-text("确定")').first();
|
||||
await submitBtn.click();
|
||||
await expect(page.locator('.el-message--success')).toBeVisible();
|
||||
});
|
||||
|
||||
test('应该能够编辑菜单 @critical', async ({ page }) => {
|
||||
const editBtn = page.locator('.el-tree-node .el-button:has-text("编辑"), .el-tree-node .edit-btn').first();
|
||||
if (await editBtn.isVisible()) {
|
||||
await editBtn.click();
|
||||
await expect(page.locator('.el-dialog:has-text("编辑菜单")')).toBeVisible();
|
||||
const nameInput = page.locator('.el-dialog input[placeholder*="菜单名称"]').first();
|
||||
await nameInput.clear();
|
||||
await nameInput.fill('更新菜单');
|
||||
const submitBtn = page.locator('.el-dialog button:has-text("确定")').first();
|
||||
await submitBtn.click();
|
||||
await expect(page.locator('.el-message--success')).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('应该能够删除菜单 @critical', async ({ page }) => {
|
||||
const deleteBtn = page.locator('.el-tree-node .el-button:has-text("删除"), .el-tree-node .delete-btn').first();
|
||||
if (await deleteBtn.isVisible()) {
|
||||
await deleteBtn.click();
|
||||
await expect(page.locator('.el-message-box:has-text("确认删除")')).toBeVisible();
|
||||
const confirmBtn = page.locator('.el-message-box button:has-text("确定")').first();
|
||||
await confirmBtn.click();
|
||||
await expect(page.locator('.el-message--success')).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('应该能够拖拽排序菜单 @regression', async ({ page }) => {
|
||||
const dragNode = page.locator('.el-tree-node__content').first();
|
||||
const targetNode = page.locator('.el-tree-node__content').nth(1);
|
||||
|
||||
if (await dragNode.isVisible() && await targetNode.isVisible()) {
|
||||
await dragNode.dragTo(targetNode);
|
||||
await page.waitForTimeout(500);
|
||||
// 验证排序成功
|
||||
await expect(page.locator('.el-message--success')).toBeVisible();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user