73 lines
3.9 KiB
TypeScript
73 lines
3.9 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import { menuTypeLabel } from '../src/pages/account/menu-manage-model.ts'
|
|
|
|
// module 13 task 252:菜单管理页面对齐 admin panel-columns(列表列/类型/上级/创建时间/删除确认/排序)。
|
|
|
|
test('test_task_252_menus_list_normal_primary_path', () => {
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
assert.match(page, /菜单类型/, '需有“菜单类型”列')
|
|
assert.match(page, /menuTypeLabel/, '菜单类型展示走中文映射')
|
|
assert.match(page, /上级菜单/, '需有“上级菜单”列')
|
|
})
|
|
|
|
test('test_task_252_menus_list_normal_variant_input', () => {
|
|
// 正常变体:权限标识/路由不作为列表列展示(运维从对话框维护),列宽自适应;删除确认含菜单名。
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
assert.equal(/<el-table-column[^>]*prop="columnKey"/.test(page), false, '权限标识不应作为列表列')
|
|
assert.equal(/<el-table-column[^>]*prop="routePath"/.test(page), false, '路由不应作为列表列')
|
|
assert.match(page, /menuForm\.columnKey/, '权限标识字段仍在编辑表单内')
|
|
assert.match(page, /menuForm\.routePath/, '路由字段仍在编辑表单内')
|
|
assert.match(page, /确定删除菜单/, '删除确认需含“确定删除菜单”')
|
|
assert.match(page, /menuDeleteReason/, '删除需过前置校验')
|
|
})
|
|
|
|
test('test_task_252_menus_list_normal_repeated_operation_is_idempotent', () => {
|
|
// 类型映射幂等(对齐 admin.js:admin→后台,其余→软件)。
|
|
assert.equal(menuTypeLabel('admin'), '后台')
|
|
assert.equal(menuTypeLabel('APP'), '软件')
|
|
assert.equal(menuTypeLabel('app'), menuTypeLabel('app'))
|
|
})
|
|
|
|
test('test_task_252_menus_list_boundary_empty_input', () => {
|
|
// 边界:未知类型归软件;创建/编辑标题区分。
|
|
assert.equal(menuTypeLabel(null), '软件')
|
|
assert.equal(menuTypeLabel(undefined), '软件')
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
assert.match(page, /新增菜单/, '页头新增菜单入口')
|
|
assert.match(page, /editingNode.*编辑菜单|编辑菜单/, '编辑态标题')
|
|
})
|
|
|
|
test('test_task_252_menus_list_boundary_single_item', () => {
|
|
// 边界:父菜单列对根节点给占位,不崩。
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
assert.match(page, /parentNameOf/, '上级菜单列经 parentNameOf 映射')
|
|
})
|
|
|
|
test('test_task_252_menus_list_boundary_limit_or_missing_field', () => {
|
|
// 边界上限:创建/编辑表单含名称/标识/父菜单/路由/排序。
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
for (const field of ['menuForm.name', 'menuForm.columnKey', 'menuForm.parentId', 'menuForm.routePath', 'menuForm.sortOrder']) {
|
|
assert.ok(page.includes(field), `表单需含 ${field}`)
|
|
}
|
|
})
|
|
|
|
test('test_task_252_menus_list_invalid_input_rejected', () => {
|
|
// 异常:有子节点禁删、父级环校验文案在模型内。
|
|
const model = readSource('src/pages/account/menu-manage-model.ts')
|
|
assert.match(model, /请先删除该菜单下的子菜单/)
|
|
assert.match(model, /不能选择自己的子菜单作为父菜单/)
|
|
assert.match(model, /created_at/, '节点解析需含创建时间')
|
|
})
|
|
|
|
test('test_task_252_menus_list_dependency_failure_returns_actionable_message', () => {
|
|
// 依赖:排序能力收敛到 sort_order 字段(列表/编辑弹窗维护),页面不再提供上移/下移即时排序。
|
|
const api = readSource('src/pages/account/menu-manage-api.ts')
|
|
assert.match(api, /column\/reorder/, 'adapter 仍支持 column/reorder')
|
|
const page = readSource('src/pages/account/MenusPage.vue')
|
|
assert.equal(/上移|下移/.test(page), false, '页面无上移/下移')
|
|
assert.match(page, /menuForm\.sortOrder/, '编辑弹窗维护 sort_order')
|
|
assert.equal(/moveMenuRow/.test(page), false, '无 moveMenuRow 残码')
|
|
})
|