You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
4.4 KiB

/**
* RBAC 权限 E2E 测试(Playwright MCP 交互式)
*
* 测试:超级管理员登录、用户表格角色/来源列、角色标签、
* 创建弹窗角色选择器和备注字段、编辑弹窗角色选择器、
* 创建/删除用户 CRUD 全流程
*
* 前置条件:
* - 后端已启动(http://localhost:8888),Casbin 已初始化
* - 前端已启动(http://localhost:5173)
* - 超级管理员 admin@system.local / admin123 已由种子逻辑创建
*
* 执行方式: 通过 Playwright MCP 工具交互式执行
*
* 测试结果 (2026-02-14):
* - Step 1: Super admin 登录 ..................... PASS
* - Step 2: 验证角色/来源列表头 .................. PASS
* - Step 3: 验证角色/来源标签(超级管理员/系统)... PASS
* - Step 4: 验证创建弹窗包含角色选择器和备注字段 .. PASS
* - combobox: 普通用户 / 管理员 / 超级管理员
* - textbox: 备注
* - Step 5: 验证编辑弹窗角色选择器 ............... PASS
* - combobox 预选当前角色(超级管理员)
* - 包含所有角色选项
* - Step 6: 创建管理员用户(角色=管理员, 来源=手动创建)PASS
* - 新用户显示蓝色"管理员"标签
* - 新用户显示"手动创建"来源标签
* - Step 7: 删除测试用户 ......................... PASS
* - 确认弹窗正确显示用户名
* - 删除后用户列表正确更新
*
* 全部 7/7 PASS
*/
import { TEST_CONFIG, ROUTES, SELECTORS } from './config';
/**
* RBAC E2E 测试步骤(Playwright MCP 交互式执行)
*
* 以下为测试流程的文档化描述,实际执行通过 Playwright MCP 工具完成。
*/
export const rbacE2ESteps = {
name: 'RBAC 权限 E2E 测试',
steps: [
{
name: 'Step 1: Super admin 登录',
actions: [
'navigate to /login',
'fill email: admin@system.local',
'fill password: admin123',
'click login button',
'verify redirect to /dashboard',
'verify sidebar shows admin@system.local',
],
expected: 'Page URL = /dashboard, sidebar user = admin',
},
{
name: 'Step 2: 验证角色/来源列表头',
actions: [
'click 用户管理 sidebar link',
'verify table headers include: ID, 用户名, 邮箱, 角色, 来源, 手机号, 创建时间, 操作',
],
expected: 'columnheader "角色" and "来源" present',
},
{
name: 'Step 3: 验证角色/来源标签',
actions: [
'check user rows for role badge text (超级管理员/管理员/普通用户/访客)',
'check user rows for source badge text (系统/注册/SSO/手动创建)',
],
expected: 'seed admin shows "超级管理员" role and "系统" source badges',
},
{
name: 'Step 4: 验证创建弹窗包含角色选择器和备注字段',
actions: [
'click 添加用户 button',
'verify modal title = "添加用户"',
'verify combobox with options: 普通用户, 管理员, 超级管理员',
'verify textbox labeled 备注 present',
'click 取消',
],
expected: 'combobox with 3 role options + remark textbox in create modal',
},
{
name: 'Step 5: 验证编辑弹窗角色选择器',
actions: [
'click edit button on a user row',
'verify modal title = "编辑用户"',
'verify combobox pre-selects current role (超级管理员)',
'verify all 3 role options available',
'verify 备注 textbox present',
'click 取消',
],
expected: 'combobox with pre-selected role + remark textbox in edit modal',
},
{
name: 'Step 6: 创建管理员用户',
actions: [
'click 添加用户 button',
'fill username: testuser_rbac',
'fill email: testrbac@example.com',
'fill password: Test123456',
'select role: 管理员',
'fill remark: RBAC E2E 测试用户',
'click 创建',
'verify new row with role=管理员, source=手动创建',
],
expected: 'user list count +1, new user shows "管理员" and "手动创建" badges',
},
{
name: 'Step 7: 删除测试用户',
actions: [
'click delete button on testuser_rbac row',
'verify confirm dialog: "确定要删除用户 testuser_rbac 吗?"',
'click 确认删除',
'verify user list count -1',
],
expected: 'user removed from table, count updated',
},
],
};
export default rbacE2ESteps;