67 lines
3.5 KiB
TypeScript
67 lines
3.5 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
|
|
// module 13 task 251:用户管理补齐新建/编辑/角色+菜单授权弹窗(接线孤儿模块)。
|
|
|
|
test('test_task_251_user_dialog_normal_primary_path', () => {
|
|
const page = readSource('src/pages/account/UsersPage.vue')
|
|
assert.match(page, /新建用户/, '页头需有新建用户入口')
|
|
assert.match(page, /openCreate/, '新建按钮需绑定 openCreate')
|
|
assert.match(page, /CreateUserDialog/, '需挂载新建用户弹窗')
|
|
assert.match(page, /EditUserDialog/, '需挂载编辑用户弹窗')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_normal_variant_input', () => {
|
|
const create = readSource('src/pages/account/CreateUserDialog.vue')
|
|
assert.match(create, /submitCreateUser/, '创建提交走 user-create-adapter')
|
|
assert.match(create, /validateCreateUserForm/, '创建校验走 user-create-model')
|
|
assert.match(create, /普通账号/, '角色文案需含“普通账号”')
|
|
assert.match(create, /管理员/, '角色文案需含“管理员”')
|
|
assert.match(create, /UserMenuAuthTree/, '创建弹窗需含菜单授权树')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_normal_repeated_operation_is_idempotent', () => {
|
|
const edit = readSource('src/pages/account/EditUserDialog.vue')
|
|
assert.match(edit, /fillEditUserForm/, '编辑回填走 user-edit-model')
|
|
assert.match(edit, /submitEditUser/, '编辑提交走 user-edit-adapter')
|
|
assert.match(edit, /loadUserMenuAuth/, '编辑授权加载走 user-menu-auth-api')
|
|
assert.match(edit, /更新成功/, '编辑成功提示“更新成功”')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_boundary_empty_input', () => {
|
|
const model = readSource('src/pages/account/user-create-model.ts')
|
|
assert.match(model, /用户名至少/, '需有“用户名至少 N 个字符”')
|
|
assert.match(model, /密码至少/, '需有“密码至少 N 个字符”')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_boundary_single_item', () => {
|
|
// 超管用户不可编辑(行按钮禁用)。
|
|
const page = readSource('src/pages/account/UsersPage.vue')
|
|
assert.match(page, /editableOf/, '需有可编辑判定')
|
|
assert.match(page, /isEditableUser/, '可编辑判定应复用 user-edit-model')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_boundary_limit_or_missing_field', () => {
|
|
// 边界上限:角色下拉仅超管操作者可见(非超管隐藏角色项)。
|
|
const create = readSource('src/pages/account/CreateUserDialog.vue')
|
|
assert.match(create, /operatorSuper/, '角色可改应受 operatorSuper 控制')
|
|
const edit = readSource('src/pages/account/EditUserDialog.vue')
|
|
assert.match(edit, /operatorSuper/, '编辑角色项应受 operatorSuper 控制')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_invalid_input_rejected', () => {
|
|
// 异常:创建成功后需清空用户名/密码并保持弹窗;提交反馈走统一通道。
|
|
const create = readSource('src/pages/account/CreateUserDialog.vue')
|
|
assert.match(create, /form\.username\s*=\s*''/, '成功后清空用户名')
|
|
assert.match(create, /form\.password\s*=\s*''/, '成功后清空密码')
|
|
assert.match(create, /showAdminFeedback/, '反馈走 admin-feedback 统一通道')
|
|
})
|
|
|
|
test('test_task_251_user_dialog_dependency_failure_returns_actionable_message', () => {
|
|
// 依赖:编辑适配器 PUT /api/admin/user/{uid} 真实存在。
|
|
const adapter = readSource('src/pages/account/user-edit-adapter.ts')
|
|
assert.match(adapter, /http\.put/, '编辑需走 PUT')
|
|
assert.match(adapter, /\$\{EDIT_USER_ENDPOINT\}\/\$\{form\.uid\}/, '端点须为 /api/admin/user/{uid}')
|
|
})
|