fix(角色叫法): 管理员就叫管理员、normal 档统一「普通账号」
同一角色此前有两套叫法:admin 档在界面叫「管理员」、在后端 6 条 403 与 Swagger 说明里叫 「普通管理员」;normal 档在界面叫「普通用户」。清到第四轮才清净,所以把口径做进源码出口: 新增 task-048 的旧词扫描用例,两棵源码树(admin-frontend-vue/src 216 文件、 backend-java/src 1415 java 文件)里出现「普通管理员」「普通用户」即红,分母与出口文件成员 一起钉死,防"扫了个空集合"式假绿。 - 后端 6 条用户可见文案:PermissionMenuService 两判、ShopManageGroupService 一判、 ShopManageController 三条 @Operation 说明 - company_menu_grant_gate_mutation.py 的 DENIED_THROW 锚同步改,16 条锚命中数逐条复算=1 - 注释与 javadoc 同批收口(等长替换不动排版);NotificationControllerTest 那句讲的是 非后台账号,按本意改写而不是套「普通账号」
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readdirSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { readSource } from './helpers.ts'
|
||||
import {
|
||||
roleDomainOf,
|
||||
@@ -88,3 +90,72 @@ test('test_task_048_normal_role_wording_agrees_across_all_exits', () => {
|
||||
)
|
||||
assert.deepEqual(buttons, [['normal', word], ['admin', '管理员']], '编辑用户弹窗的角色按钮文案')
|
||||
})
|
||||
|
||||
/**
|
||||
* 2026-10-05 定稿:admin 档只叫「管理员」,normal 档只叫「普通账号」。
|
||||
* 旧叫法「普通管理员」「普通用户」当天清了三轮才清干净(列表列、下拉、角色域、弹窗按钮四份出口
|
||||
* 各写一套,后端还留着 6 条 403 与 Swagger 说明),所以钉成尺子而不是记在脑子里。
|
||||
* 判据只扫两棵源码树的源码扩展名:`.playwright-cli/*.yml` 那批 09-12 的页面快照里印着旧词,
|
||||
* 那是历史证据不是口径;`tests/` 也不扫——本文件的禁用清单自己就要写这两个词。
|
||||
*/
|
||||
const RETIRED_ROLE_WORDS = ['普通管理员', '普通用户'] as const
|
||||
|
||||
/** 扫描面。minFiles 是 2026-10-05 实测分母(216 / 1415)的下限,mustInclude 钉"该扫到的文件真在集合里"。 */
|
||||
const ROLE_WORD_SCOPE: ReadonlyArray<{
|
||||
readonly dir: string
|
||||
readonly exts: readonly string[]
|
||||
readonly minFiles: number
|
||||
readonly mustInclude: readonly string[]
|
||||
}> = [
|
||||
{
|
||||
dir: 'src',
|
||||
exts: ['.ts', '.tsx', '.vue', '.js'],
|
||||
minFiles: 200,
|
||||
mustInclude: ['src/types/admin.ts', 'src/pages/account/user-role-map.ts', 'src/pages/account/EditUserDialog.vue'],
|
||||
},
|
||||
{
|
||||
dir: '../backend-java/src',
|
||||
exts: ['.java'],
|
||||
minFiles: 1300,
|
||||
mustInclude: [
|
||||
'../backend-java/src/main/java/com/nanri/aiimage/modules/permission/service/PermissionMenuService.java',
|
||||
'../backend-java/src/main/java/com/nanri/aiimage/modules/admin/service/AdminUserService.java',
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
function walkSourceFiles(dir: string, exts: readonly string[], out: string[] = []): string[] {
|
||||
for (const entry of readdirSync(join(process.cwd(), dir), { withFileTypes: true })) {
|
||||
const rel = `${dir}/${entry.name}`
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name.startsWith('.')) continue
|
||||
walkSourceFiles(rel, exts, out)
|
||||
} else if (exts.some((ext) => entry.name.endsWith(ext))) {
|
||||
out.push(rel)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
test('test_task_048_retired_role_words_are_gone_from_source_trees', () => {
|
||||
const problems: string[] = []
|
||||
for (const scope of ROLE_WORD_SCOPE) {
|
||||
const files = walkSourceFiles(scope.dir, scope.exts)
|
||||
assert.ok(
|
||||
files.length >= scope.minFiles,
|
||||
`${scope.dir} 只扫到 ${files.length} 个文件(下限 ${scope.minFiles}):目录或扩展名写错了,这条尺子没在判任何东西`,
|
||||
)
|
||||
for (const needle of scope.mustInclude) {
|
||||
assert.ok(files.includes(needle), `${scope.dir} 的扫描集合里没有 ${needle},取样面漏了出口文件`)
|
||||
}
|
||||
for (const rel of files) {
|
||||
const lines = readSource(rel).split('\n')
|
||||
lines.forEach((line, index) => {
|
||||
for (const word of RETIRED_ROLE_WORDS) {
|
||||
if (line.includes(word)) problems.push(`${rel}:${index + 1} 出现旧叫法「${word}」→ ${line.trim().slice(0, 60)}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
assert.deepEqual(problems, [], '角色旧叫法回流:' + problems.join(' | '))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user