diff --git a/admin-frontend-vue/src/pages/account/user-role-map.ts b/admin-frontend-vue/src/pages/account/user-role-map.ts index 164ddc637..b8533598d 100644 --- a/admin-frontend-vue/src/pages/account/user-role-map.ts +++ b/admin-frontend-vue/src/pages/account/user-role-map.ts @@ -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 = { super_admin: '超级管理员', company_super_admin: '公司超级管理员', admin: '管理员', - normal: '普通用户', + normal: '普通账号', } /** 行字段 → 角色域:优先 role;为空时按 is_admin 布尔推断(1=管理员);未知归 normal。 */ diff --git a/admin-frontend-vue/src/types/admin.ts b/admin-frontend-vue/src/types/admin.ts index cce968d5c..cfa3552d2 100644 --- a/admin-frontend-vue/src/types/admin.ts +++ b/admin-frontend-vue/src/types/admin.ts @@ -70,7 +70,7 @@ export function roleLabel(role: string | null | undefined): string { case 'admin': return '管理员' case 'normal': - return '普通用户' + return '普通账号' default: return '' } diff --git a/admin-frontend-vue/tests/task-48.test.ts b/admin-frontend-vue/tests/task-48.test.ts index 0fb492b79..e60d848a6 100644 --- a/admin-frontend-vue/tests/task-48.test.ts +++ b/admin-frontend-vue/tests/task-48.test.ts @@ -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(/([^<]*) [m[1], m[2]] as const, + ) + assert.deepEqual(buttons, [['normal', word], ['admin', '管理员']], '编辑用户弹窗的角色按钮文案') +})