fix(账号文案): normal 的中文口径四出口对平为「普通账号」,并加对平护栏

「编辑用户」弹窗写「普通账号」,而同一页的角色列/顶部栏(roleLabel)、新建下拉
(USER_ROLE_OPTIONS)、roleDomainLabel 三份映射写「普通用户」——同一页自相矛盾,且
没有任何尺子拦得住(各写各的,改一处不会让别处红)。口径按 2026-10-05 定为「普通账号」。

改三处 src:types/admin.ts roleLabel('normal')、user-role-map.ts 的 USER_ROLE_OPTIONS
与 ROLE_DOMAIN_LABELS。EditUserDialog 的两个角色按钮本来就写「普通账号」,一字未动。

新增 test_task_048_normal_role_wording_agrees_across_all_exits 把四出口对平:三份映射表
按值断言,弹窗那侧钉模板形状(<el-radio-button value="xxx">文案< 逐条 deepEqual),
不钉 token——只出现过"普通账号"四个字是判不出按钮丢没丢的。

变异自证 3 发全杀:① roleLabel('normal') 退回「普通用户」⇒ 红;② 弹窗按钮文案改成
「普通用户」⇒ 红,且报出 actual [['normal','普通用户'],['admin','管理员']];
③ 弹窗按钮写法换成 :value="'normal'"(正则抓不到那一条)⇒ 红,actual 只剩 admin 一条
——这一发是证明它不是恒绿:形状对不上时缺的那条会以"少一条"现形,而不是静默通过。
三次注入均按原字节还原,EditUserDialog.vue 的 git diff 为空。

验证:node --test 全量 1738 例 0 红、vue-tsc --noEmit rc=0、浏览器实测三处可见出口
(列表角色列 / 新建下拉 / 编辑弹窗)均显示「普通账号」。
This commit is contained in:
2026-10-05 22:44:21 +08:00
parent 2dc13d0274
commit 7ef328c46c
3 changed files with 21 additions and 4 deletions
@@ -16,14 +16,14 @@ export interface UserRoleOption {
export const USER_ROLE_OPTIONS: readonly UserRoleOption[] = [
{ value: 'company_super_admin', label: '公司超级管理员' },
{ value: 'admin', label: '管理员' },
{ value: 'normal', label: '普通用户' },
{ value: 'normal', label: '普通账号' },
]
const ROLE_DOMAIN_LABELS: Record<RoleDomain, string> = {
super_admin: '超级管理员',
company_super_admin: '公司超级管理员',
admin: '管理员',
normal: '普通用户',
normal: '普通账号',
}
/** 行字段 → 角色域:优先 role;为空时按 is_admin 布尔推断(1=管理员);未知归 normal。 */
+1 -1
View File
@@ -70,7 +70,7 @@ export function roleLabel(role: string | null | undefined): string {
case 'admin':
return '管理员'
case 'normal':
return '普通用户'
return '普通账号'
default:
return ''
}
+18 -1
View File
@@ -8,6 +8,7 @@ import {
roleDomainLabel,
USER_ROLE_OPTIONS,
} from '../src/pages/account/user-role-map.ts'
import { roleLabel } from '../src/types/admin.ts'
test('test_task_048_user_role_map_normal_primary_path', () => {
// 正常主路径:role 字段直接映射为角色域。
@@ -67,7 +68,23 @@ test('test_task_048_user_role_map_dependency_failure_returns_actionable_message'
const mod = readSource('src/pages/account/user-role-map.ts')
assert.equal(/axios|http\./.test(mod), false, '角色映射保持纯逻辑')
assert.equal(roleDomainLabel('admin'), '管理员')
assert.equal(roleDomainLabel('normal'), '普通用户')
assert.equal(roleDomainLabel('normal'), '普通账号')
assert.equal(roleDomainLabel('super_admin'), '超级管理员')
assert.equal(roleDomainLabel('company_super_admin'), '公司超级管理员')
})
test('test_task_048_normal_role_wording_agrees_across_all_exits', () => {
// 2026-10-05 定口径:normal 一律显示「普通账号」。这句文案此前有四份出口 —— 列表角色列与顶部栏
// 走 roleLabel、新建下拉走 USER_ROLE_OPTIONS、还有 roleDomainLabel,而编辑弹窗的两个角色按钮是
// 硬编码在模板里的。前三份写「普通用户」、第四份写「普通账号」,同一页自相矛盾且没有尺子拦得住。
// 这条把四出口对平:任何一处换词、或弹窗那侧改成别的写法,都会红。
const word = '普通账号'
assert.equal(roleLabel('normal'), word, '用户列表角色列与顶部栏(roleLabel)')
assert.equal(roleDomainLabel('normal'), word, '角色域展示文案(roleDomainLabel)')
assert.equal(USER_ROLE_OPTIONS.find((o) => o.value === 'normal')?.label, word, '新建用户下拉候选')
const dialog = readSource('src/pages/account/EditUserDialog.vue')
const buttons = [...dialog.matchAll(/<el-radio-button\s+value="([a-z_]+)">([^<]*)</g)].map(
(m) => [m[1], m[2]] as const,
)
assert.deepEqual(buttons, [['normal', word], ['admin', '管理员']], '编辑用户弹窗的角色按钮文案')
})