feat(账号到期+公司超管): 级联过期判定、过期停任务巡检与两端续费提醒弹窗
需求两条:站点超管可开设其他公司的超级管理员(站点超管看全站、公司超管只看本公司、 组内管理员仍只看本组);账号要有过期时间,管理员过期后名下普通账户一并停用、 正在跑的任务也要停掉。落库只有 users.expires_at(V146,NULL=永不过期),级联一律现算, 不写"上级过期就把下级置成过期"那种续费也救不回来的数据。 - AccountExpiryService:生效到期 = min(自身, 本公司公司超管, 成员表组长, 创建人)。 登录拦 403(文案给续费提示)、每次请求鉴权拦 401(前端按下线踢回登录页),super_admin 永不适用。级联口径与数据可见范围同源(成员表基本未用、实际按 created_by_id 派生)。 - ExpiredAccountTaskStopService:每分钟把过期账号(含级联成员)名下 biz_file_task PENDING/SCHEDULED/RUNNING → FAILED,含未领取的 PENDING(防内部通道继续派发)。原因文案 刻意不以「客户端异常中断」开头,否则会被 TaskResumeService 自动复活。品牌采集与跟价循环 不在那张表上,经 ExpiredAccountTaskStopSpi 由各自模块停:品牌 pending/running→cancelled 且 UPDATE 的 WHERE 二次核对状态(抢到行后被客户端推进成完成的行不得误杀),跟价循环只置 stop_requested=1、沿用用户点「停止循环」那条收尾路径,绝不动 status。任务心跳接口保持匿名 不走 requireUser,所以过期账号的客户端仍能拿到 alive=false 协作停止。 - 角色 company_super_admin:由站点超管开设(唯一要显式选公司的建号场景),建号/授菜单/改用户/ 看数据四条链路都按"本公司"收口;公司超管之间、以及公司超管与站点超管互相碰不得。 - 续费提醒:剩余 <5 天在数富后台与用户端弹窗,只能收起不能关闭(无关闭按钮,收起态是右下角 浮标),续费到 ≥5 天自动消失。后台读 /api/admin/current-user 的 expiresAt/daysToExpire; 用户端无 Pinia,走 localStorage 的 account_expires_at(登录/check_login 落键、被顶下线清键, 换账号不残留)。只反映账号自身到期,弹窗不做任何级联推断。 - V146 撞掉了 V145 那批的一条护栏:它按"db/ 里不许出现 V146__ 前缀"编死号位,被一条正常的 前向迁移占用就红。改成钉动作——剥注释后的可执行 SQL 不得写 flyway_schema_history(回滚 一律是扫描路径外的人工补丁),并把盘点文档改 V146 时丢掉的 V145 文件名补回去。 验证(本会话亲跑,不是转述):后端定向 14 类 123/0(同一轮 mvn 里连批次③的 4 类 53 例、以及既有 ShopDataCrawl/SimilarAsin 两条回归对照 21 例一起跑,合计 197 例 0 红);admin-frontend-vue 本批定向 44/0(弹窗 7 + 公司建号/列表/入口/日期默认 21 + 角色 task-48/task-251 16),全量 1726 例里那 1 支红是另一条 会话刻意留的「公司 tab 接线缺口」尺子(点名 admin_task_center 等 6 页,与本批无关); frontend-vue 弹窗 9/0、全量 710/0。变异自证两批共 34 点:弹窗语义 16 点全杀(阈值 5、只能收起 不能关闭、挂载点含"注释掉挂载"、落键/清键链路),本批 SPI+迁移护栏 17 点全杀(含 G2 反向: 前向迁移只在注释里提 flyway_schema_history 必须照样绿),注入文件还原 dirty=0、探针残留 0。
This commit is contained in:
@@ -31,13 +31,16 @@ test('名单里的每个 menuKey 都在页面注册表上打了 superAdminOnly',
|
||||
}
|
||||
})
|
||||
|
||||
test('公司 API 模块的消费者集合恰好是公司管理两文件 + 公司 tab store(账号页已摘干净)', () => {
|
||||
test('公司 API 模块的消费者集合是公司管理两文件 + 用户页(建公司超管选公司,2026-10-05 唯一豁免)', () => {
|
||||
const found = filesWithSuffix(['.vue', '.ts'])
|
||||
.filter((rel) => readSource(rel).includes("from '@/api/companies'"))
|
||||
.sort()
|
||||
assert.deepEqual(found, [
|
||||
'src/pages/account/CompaniesPage.vue',
|
||||
'src/pages/account/CompanyEditorDialog.vue',
|
||||
// 2026-10-05 例外:站点超管建「公司超级管理员」必须选公司,UsersPage 因此拉公司目录。
|
||||
// 该用例的姊妹钉在 company-user-create.test.ts:公司下拉被「站点超管 + 公司超管角色」双重门控。
|
||||
'src/pages/account/UsersPage.vue',
|
||||
// 2026-10-05 公司 tab(spec §4):store 是目录的第二个消费者,仅超管侧 visibleForOperator 会发 GET。
|
||||
'src/stores/company-tab.ts',
|
||||
].sort())
|
||||
|
||||
@@ -9,31 +9,40 @@ import {
|
||||
import { OPERATION_GUIDES } from '../src/layout/operation-guides.ts'
|
||||
|
||||
/**
|
||||
* 建号不再让用户挑公司(2026-10-04 15:4x 定案)。
|
||||
* 建号公司口径(2026-10-05 修订):admin/normal 建号仍不让用户挑公司——请求体不带
|
||||
* company_id 时,`resolveTargetCompanyId` 落操作者自己的公司(下面的 Java 钉子仍然有效)。
|
||||
*
|
||||
* <p>归属这件事改由后端单点决定:请求体不带 company_id 时,`resolveTargetCompanyId` 落操作者自己的公司。
|
||||
* 所以"前端删掉下拉是安全的"这个结论完全靠那条后端分支撑着 —— 下面最后一用例把它钉成可执行断言,
|
||||
* 谁把那边改成"必填公司",这边立刻红。</p>
|
||||
* <p>唯一例外是<b>公司超级管理员</b>(2026-10-05 用户需求「admin 超管可以新建其他公司的
|
||||
* 超级管理员」):不显式选公司就会静默落进操作者自己的公司(公司 1),所以这一例必须
|
||||
* 让站点超管选公司、必选、并随请求体下发。除这一例外,公司维度仍然不回流界面。</p>
|
||||
*/
|
||||
|
||||
function form(overrides: Record<string, unknown> = {}) {
|
||||
return { ...createEmptyCreateUserForm(), username: 'zhangsan', password: 'secret123', ...overrides }
|
||||
}
|
||||
|
||||
test('空表单里没有公司这一项', () => {
|
||||
test('空表单默认没有公司、没有到期时间', () => {
|
||||
const blank = createEmptyCreateUserForm()
|
||||
assert.equal('companyId' in blank, false)
|
||||
assert.deepEqual(blank, { username: '', password: '', role: 'normal', columnIds: [], createdBy: null })
|
||||
assert.equal(blank.companyId ?? null, null, 'companyId 默认 null(仅公司超管角色使用)')
|
||||
assert.equal(blank.expiresAt, '', '到期时间默认空 = 永不过期')
|
||||
assert.deepEqual(
|
||||
{ ...blank, companyId: null, expiresAt: '' },
|
||||
{ username: '', password: '', role: 'normal', columnIds: [], createdBy: null, companyId: null, expiresAt: '' },
|
||||
)
|
||||
})
|
||||
|
||||
test('校验只看用户名与密码,不再要求选公司', () => {
|
||||
test('普通账号校验只看用户名与密码;公司超管必须选公司', () => {
|
||||
assert.deepEqual(validateCreateUserForm(form()), { valid: true, errors: {} })
|
||||
assert.equal(validateCreateUserForm(form({ username: 'a' })).errors.username !== undefined, true)
|
||||
assert.equal(validateCreateUserForm(form({ password: '123' })).errors.password !== undefined, true)
|
||||
const missingCompany = validateCreateUserForm(form({ role: 'company_super_admin' }))
|
||||
assert.equal(missingCompany.valid, false, '公司超级管理员必须指定所属公司')
|
||||
assert.equal(missingCompany.errors.companyId !== undefined, true)
|
||||
const withCompany = validateCreateUserForm(form({ role: 'company_super_admin', companyId: 2 }))
|
||||
assert.equal(withCompany.valid, true)
|
||||
})
|
||||
|
||||
// 反向钉:公司维度不得回流到界面(2026-10-04 定口径)
|
||||
test('请求体不带 companyId,其余字段照旧', () => {
|
||||
test('请求体:admin/normal 一律不带 companyId;公司超管必须带且选了公司才带', () => {
|
||||
assert.deepEqual(toCreateUserRequest(form({ columnIds: [3, 1] })), {
|
||||
username: 'zhangsan',
|
||||
password: 'secret123',
|
||||
@@ -44,17 +53,31 @@ test('请求体不带 companyId,其余字段照旧', () => {
|
||||
assert.equal(toCreateUserRequest(form({ role: 'normal', createdBy: 5 })).createdById, 5)
|
||||
assert.equal('createdById' in toCreateUserRequest(form({ role: 'admin', createdBy: 5 })), false)
|
||||
assert.equal('companyId' in toCreateUserRequest(form()), false,
|
||||
'不传 company_id 才会走后端"落操作者公司"那条分支')
|
||||
'不传 company_id 才会走后端"落操作者公司"那条分支(admin/normal 永远如此)')
|
||||
|
||||
// 2026-10-05 例外:公司超级管理员
|
||||
const companyAdmin = toCreateUserRequest(form({ role: 'company_super_admin', companyId: 2 }))
|
||||
assert.equal(companyAdmin.companyId, 2, '公司超管必须把选中的公司带给后端,否则会静默落操作者本公司')
|
||||
assert.equal(companyAdmin.role, 'company_super_admin')
|
||||
assert.equal('companyId' in toCreateUserRequest(form({ role: 'company_super_admin' })), false,
|
||||
'没选公司就不许带(校验层会先拦住,这里兜底不静默)')
|
||||
})
|
||||
|
||||
// 反向钉:公司维度不得回流到界面(2026-10-04 定口径)
|
||||
test('建号模型源码里公司口径已摘干净', () => {
|
||||
test('到期时间:空串不下发,有值随请求体走', () => {
|
||||
assert.equal('expiresAt' in toCreateUserRequest(form()), false, '留空 = 永不过期,不下发')
|
||||
assert.equal(toCreateUserRequest(form({ expiresAt: '2026-12-31 23:59:59' })).expiresAt,
|
||||
'2026-12-31 23:59:59')
|
||||
})
|
||||
|
||||
test('建号模型源码:公司口径只对「公司超管」这一例放行', () => {
|
||||
const mod = readSource('src/pages/account/user-create-model.ts')
|
||||
assert.equal(/companyId|CompanyItem|selectableCompanies|initialCompanyId|CreateOperatorScope/.test(mod), false,
|
||||
'公司相关的类型、可选项收窄函数、预选函数都应整体删除')
|
||||
assert.match(mod, /company_super_admin/, '角色白名单要包含公司超管')
|
||||
assert.match(mod, /role === 'company_super_admin' && form\.companyId != null/,
|
||||
'companyId 只在「角色=公司超管且已选公司」时下发——这是唯一豁免,别放宽成所有角色')
|
||||
const dialog = readSource('src/pages/account/CreateUserDialog.vue')
|
||||
assert.equal(/companyId|CompanyItem|所属公司|selectableCompanies/.test(dialog), false,
|
||||
'弹窗不再有公司选择;操作者角色门控(operatorSuper)保留,它管的是角色与所属管理员下拉')
|
||||
assert.match(dialog, /operatorSuper && form\.role === 'company_super_admin'/,
|
||||
'公司下拉必须同时被「站点超管 + 公司超管角色」双重门控,普通建号不能看到公司维度')
|
||||
assert.match(dialog, /公司超级管理员必须指定所属公司|请选择公司/, '公司下拉要有必选提示')
|
||||
assert.match(dialog, /operatorSuper/, '角色/所属管理员仍按操作者是否超管收窄')
|
||||
})
|
||||
|
||||
@@ -64,12 +87,14 @@ test('建号模型源码里公司口径已摘干净', () => {
|
||||
* 同理"停用后不能再用于新建账号"也不成立了——requireActive 只在显式传 company_id 时才走,
|
||||
* 而页面现在一律不传(接口直连的老调用方仍受它保护,那条由上一用例盯着)。
|
||||
*/
|
||||
test('「公司管理」引导文案说的是自动继承,不再让操作员挑公司', () => {
|
||||
test('「公司管理」引导文案说的是自动继承,并写清公司超管这一例外', () => {
|
||||
const guide = OPERATION_GUIDES.admin_companies.text
|
||||
assert.match(guide, /操作者自己所在的公司/, '要写清归属的真实口径:落在操作者本公司')
|
||||
assert.match(guide, /请用那个公司自己的管理员登录|用该公司自己的管理员登录/,
|
||||
'要给别家建号只能换账号登录——不写这句,超管会以为自己建的号能归到别家')
|
||||
for (const stale of ['建号时选哪家公司', '选哪家公司', '停用后不能再用于新建账号']) {
|
||||
assert.match(guide, /公司超级管理员/,
|
||||
'2026-10-05 起开设公司超管是唯一要在建号时选公司的例外,文案要说清,别让人以为下拉没了是坏了')
|
||||
for (const stale of ['建号时选哪家公司', '停用后不能再用于新建账号']) {
|
||||
assert.equal(guide.includes(stale), false, `文案仍含已失效的说法:${stale}`)
|
||||
}
|
||||
})
|
||||
@@ -93,7 +118,7 @@ function javaMethod(source: string, signature: string): string {
|
||||
return ''
|
||||
}
|
||||
|
||||
test('后端仍然把"没传公司"落成操作者自己公司(前端删下拉的前提)', () => {
|
||||
test('后端仍然把"没传公司"落成操作者自己公司(admin/normal 不带下拉的前提)', () => {
|
||||
const java = readSource(
|
||||
'../backend-java/src/main/java/com/nanri/aiimage/modules/admin/service/AdminUserService.java',
|
||||
)
|
||||
|
||||
@@ -59,12 +59,18 @@ test('顶栏不再渲染公司名', () => {
|
||||
assert.equal(topbarUserOf(null).hasUser, false)
|
||||
})
|
||||
|
||||
// 反向钉:公司维度不得回流到界面(2026-10-04 定口径)
|
||||
// 反向钉:公司维度不得回流到「列表/筛选/顶栏」(2026-10-04 定口径;2026-10-05 修订——
|
||||
// 唯一例外是建号弹窗里的「公司超级管理员」所属公司下拉,由 company-user-create.test.ts 单独钉住)
|
||||
test('账号页与顶栏的源码里公司维度已摘干净', () => {
|
||||
const page = readSource('src/pages/account/UsersPage.vue')
|
||||
assert.equal(/所属公司/.test(page), false, '账号页不该再出现「所属公司」标签')
|
||||
assert.equal(/companyId|companyName|companies/.test(page), false, '页面不再持有公司目录或公司筛选状态')
|
||||
assert.equal(/fetchCompanies/.test(page), false, '公司目录接口不该再被账号页调用')
|
||||
// 列表契约层面不许出现公司维度:查询参数 company_id、筛选状态、行级公司列。
|
||||
// (companyOptions/c.companyName 是 2026-10-05 建公司超管选公司的唯一豁免,不在此列。)
|
||||
assert.equal(/company_id|filters\.company|row\.company|companyId/.test(page), false,
|
||||
'列表查询/筛选/行渲染不允许出现公司维度')
|
||||
assert.match(page, /fetchCompanies/, '公司目录仅供建号弹窗的「公司超管」下拉使用(唯一豁免)')
|
||||
assert.match(page, /isSuperAdmin[\s\S]{0,200}fetchCompanies/,
|
||||
'拉公司目录必须按站点超管门控,非超管不发这个请求(后端 403 兜底)')
|
||||
|
||||
// 「删了列忘了改占位行 colspan」是这类改动最常留下的残行:按表头列数交叉核对
|
||||
// (`<th` 是 `<thead` 的前缀,必须带上后随字符才数得准)
|
||||
@@ -74,8 +80,10 @@ test('账号页与顶栏的源码里公司维度已摘干净', () => {
|
||||
for (const span of spans) assert.equal(span, headers, `占位行 colspan=${span} 与表头列数 ${headers} 不符`)
|
||||
|
||||
const dialog = readSource('src/pages/account/CreateUserDialog.vue')
|
||||
assert.equal(/所属公司|selectableCompanies|initialCompanyId|companyId/.test(dialog), false,
|
||||
'建号弹窗不该再有公司选择')
|
||||
assert.match(dialog, /operatorSuper && form\.role === 'company_super_admin'/,
|
||||
'建号弹窗的公司下拉只许在「站点超管 + 公司超管角色」时出现(例外口径见 company-user-create.test.ts)')
|
||||
assert.equal(/selectableCompanies|initialCompanyId/.test(dialog), false,
|
||||
'一次性预选/收窄的旧公司逻辑不许回流')
|
||||
|
||||
const layout = readSource('src/layout/AdminLayout.vue')
|
||||
assert.equal(/userVm\.company|admin-user-company/.test(layout), false, '顶栏旁白只剩用户名与角色')
|
||||
|
||||
@@ -34,6 +34,10 @@ const EXEMPT = new Set([
|
||||
'src/pages/tasks/ShopDataTasksPage.vue',
|
||||
'src/pages/tasks/ImageVideoTasksPage.vue',
|
||||
'src/pages/records/RecordsHistoryPage.vue',
|
||||
// 2026-10-05(V146):两处是「到期时间」表单字段而非列表筛选——留空 = 永不过期,
|
||||
// 是有业务语义的默认值,绝不能默认当天(默认当天等于建号即过期)。
|
||||
'src/pages/account/CreateUserDialog.vue',
|
||||
'src/pages/account/EditUserDialog.vue',
|
||||
])
|
||||
|
||||
/** 把日期筛选清回空值的写法(默认当天的页里初值或重置都不许出现)。
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { occurrences, readSource } from './helpers.ts'
|
||||
|
||||
/**
|
||||
* 数富后台「服务即将到期」续费提醒弹窗(V146,2026-10-05 需求)的口径护栏。
|
||||
*
|
||||
* 需求原话:仅剩不到 5 天开始提醒、只能缩小不能关闭、续费到超过 5 天才消失。
|
||||
* 这三条全靠 ExpiryNotice.vue 一个组件兑现,而组件是 SFC、node --test 编译不了,
|
||||
* 所以断言打在实际源码上:阈值、渲染条件、可点的按钮、收起态记的是什么键、挂在哪。
|
||||
*
|
||||
* 每个正则都必须在真源码上匹配得到(先确认真命中再断言),否则就是恒绿的摆设。
|
||||
*/
|
||||
const COMPONENT = 'src/components/ExpiryNotice.vue'
|
||||
const LAYOUT = 'src/layout/AdminLayout.vue'
|
||||
const TYPES = 'src/types/admin.ts'
|
||||
|
||||
/** SFC 的 <template> 段:从第一个 <template> 到最后一个 </template>(内层还有 v-if 包裹)。 */
|
||||
function templateOf(source: string): string {
|
||||
const start = source.indexOf('<template>')
|
||||
const end = source.lastIndexOf('</template>')
|
||||
assert.ok(start !== -1 && end > start, `${COMPONENT} 没有 <template> 段`)
|
||||
return source.slice(start, end)
|
||||
}
|
||||
|
||||
/** <script setup> 段。 */
|
||||
function scriptOf(source: string): string {
|
||||
const start = source.indexOf('<script setup')
|
||||
const end = source.indexOf('</script>')
|
||||
assert.ok(start !== -1 && end > start, `${COMPONENT} 没有 <script setup> 段`)
|
||||
return source.slice(start, end)
|
||||
}
|
||||
|
||||
/** 剥掉 HTML 注释:注释掉的 `<ExpiryNotice />` 在源码里照样匹配得上,挂载点断言必须是活代码。 */
|
||||
function withoutComments(source: string): string {
|
||||
return source.replace(/<!--[\s\S]*?-->/g, '')
|
||||
}
|
||||
|
||||
const source = readSource(COMPONENT)
|
||||
const template = templateOf(source)
|
||||
const script = scriptOf(source)
|
||||
|
||||
test('提醒阈值就是 5 天:THRESHOLD 取 props 兜底 5,且全文件没有第二个数字阈值', () => {
|
||||
assert.match(script, /const THRESHOLD = props\.threshold \?\? 5\b/, '阈值没写成 5 的兜底')
|
||||
// 排他:别处再写一个数字兜底,就等于偷偷加了第二套口径
|
||||
const numericFallbacks = script.match(/\?\?\s*\d+/g) ?? []
|
||||
assert.deepEqual(numericFallbacks, ['?? 5'], '数字兜底只能有阈值 5 这一个')
|
||||
})
|
||||
|
||||
test('渲染条件是「剩余 < 5」而不是「<= 5」:整 5 天不弹,第 4 天起才弹', () => {
|
||||
assert.match(
|
||||
script,
|
||||
/daysToExpire\.value !== null && daysToExpire\.value < THRESHOLD/,
|
||||
'visible 没按「有到期值且 < 阈值」判定',
|
||||
)
|
||||
assert.doesNotMatch(script, /daysToExpire\.value <= THRESHOLD/, '写成了 <=,整 5 天也会弹')
|
||||
})
|
||||
|
||||
test('没有关闭这条路:模板里只有「收起」和浮标两个可点项,没有任何对话框自带的关闭件', () => {
|
||||
assert.equal(occurrences(template, '@click="'), 2, '可点项必须恰好是收起 + 浮标恢复两个')
|
||||
assert.match(template, /@click="minimize"/, '收起按钮没接 minimize')
|
||||
assert.match(template, /@click="restore"/, '缩小态浮标没接 restore')
|
||||
assert.match(template, /收起\s*<\/button>/, '唯一的收起动作文案是「收起」')
|
||||
// 关闭语义的三种实际载体:对话框组件、显式 close 处理器、Element 的关闭开关
|
||||
assert.equal(occurrences(source, 'el-dialog'), 0, '用对话框会带来关闭件')
|
||||
assert.doesNotMatch(source, /@click="[^"]*close/i, '存在 close 点击处理器')
|
||||
assert.doesNotMatch(source, /show-close|close-on-click-modal|close-on-press-escape|:closable/, '存在任何关闭开关')
|
||||
})
|
||||
|
||||
test('收起态按「用户 id + 到期值」记键:续费换了到期值,键变了就自动回到展开', () => {
|
||||
assert.equal(occurrences(script, 'admin-expiry-notice-min:'), 1, '收起态键名只应有一处定义')
|
||||
assert.match(
|
||||
script,
|
||||
/`admin-expiry-notice-min:\$\{user\.value\.id\}:\$\{expiresAt\.value\}`/,
|
||||
'键里必须同时带用户 id 与到期值,缺到期值则续费后仍停在收起态',
|
||||
)
|
||||
// 全组件只写这一个键:任何形式的「已读/忽略」持久化都会让提醒在续费前被永久关掉
|
||||
assert.equal(occurrences(script, 'localStorage.setItem('), 1, '持久化写入只能有收起态这一处')
|
||||
assert.equal(occurrences(script, 'localStorage.removeItem('), 1, '只有恢复展开时清键')
|
||||
})
|
||||
|
||||
test('到期值变化会重新判定收起态:watch 键值且 immediate', () => {
|
||||
assert.match(script, /watch\(\s*minimizedKey,/, '没有监听 minimizedKey')
|
||||
assert.match(script, /minimized\.value = key \? localStorage\.getItem\(key\) === '1' : false/, '展开态直接由键值决定')
|
||||
assert.match(script, /\{ immediate: true \}/, '缺 immediate 则首屏不判定,刷新后不提醒')
|
||||
})
|
||||
|
||||
test('挂在后台布局上:AdminLayout 引了组件并且渲染,不挂就整站看不见', () => {
|
||||
const layout = withoutComments(readSource(LAYOUT))
|
||||
assert.match(layout, /import ExpiryNotice from '@\/components\/ExpiryNotice\.vue'/, '布局没引组件')
|
||||
assert.match(layout, /<ExpiryNotice\s*\/>/, '布局没渲染组件(注释掉等于没挂)')
|
||||
})
|
||||
|
||||
test('数据源键名与前端类型对齐:daysToExpire/expiresAt 来自 current-user,没有映射层', () => {
|
||||
const types = readSource(TYPES)
|
||||
assert.match(types, /daysToExpire\?: number \| null/, 'AdminUser 类型缺 daysToExpire')
|
||||
assert.match(types, /expiresAt\?: string/, 'AdminUser 类型缺 expiresAt')
|
||||
assert.match(readSource('src/api/session.ts'), /\/api\/admin\/current-user/, '会话数据源不是 current-user')
|
||||
// 组件读的是 store 上的这两个键,不是自己算时间
|
||||
assert.match(script, /session\.user/, '弹窗数据源是后台会话 store')
|
||||
assert.match(script, /user\.value\?\.daysToExpire/, '读 daysToExpire 而不是本地算')
|
||||
})
|
||||
@@ -36,10 +36,10 @@ test('test_task_251_user_dialog_boundary_empty_input', () => {
|
||||
})
|
||||
|
||||
test('test_task_251_user_dialog_boundary_single_item', () => {
|
||||
// 超管用户不可编辑(行按钮禁用)。
|
||||
// 超管用户不可编辑(行按钮禁用);2026-10-05 起判定结合操作者角色(公司超管目标仅站点超管可编辑)。
|
||||
const page = readSource('src/pages/account/UsersPage.vue')
|
||||
assert.match(page, /editableOf/, '需有可编辑判定')
|
||||
assert.match(page, /isEditableUser/, '可编辑判定应复用 user-edit-model')
|
||||
assert.match(page, /editableBy/, '可编辑判定应复用 user-edit-model')
|
||||
})
|
||||
|
||||
test('test_task_251_user_dialog_boundary_limit_or_missing_field', () => {
|
||||
|
||||
@@ -14,6 +14,8 @@ test('test_task_048_user_role_map_normal_primary_path', () => {
|
||||
assert.equal(roleDomainOf({ role: 'admin' }), 'admin')
|
||||
assert.equal(roleDomainOf({ role: 'normal' }), 'normal')
|
||||
assert.equal(roleDomainOf({ role: 'super_admin' }), 'super_admin')
|
||||
// 2026-10-05 新增角色:公司超级管理员(数据只看本公司,由站点超管开设)
|
||||
assert.equal(roleDomainOf({ role: 'company_super_admin' }), 'company_super_admin')
|
||||
})
|
||||
|
||||
test('test_task_048_user_role_map_normal_variant_input', () => {
|
||||
@@ -43,10 +45,11 @@ test('test_task_048_user_role_map_boundary_single_item', () => {
|
||||
})
|
||||
|
||||
test('test_task_048_user_role_map_boundary_limit_or_missing_field', () => {
|
||||
// 边界上限:超级管理员不可作为可编辑角色(null);候选不含 super_admin。
|
||||
// 边界上限:站点/公司超管不可作为可编辑角色(null);候选含公司超管但绝不含站点超管。
|
||||
assert.equal(selectRoleOf({ role: 'super_admin' }), null)
|
||||
assert.equal(selectRoleOf({ role: 'company_super_admin' }), null)
|
||||
const values = USER_ROLE_OPTIONS.map((o) => o.value)
|
||||
assert.deepEqual([...values].sort(), ['admin', 'normal'])
|
||||
assert.deepEqual([...values].sort(), ['admin', 'company_super_admin', 'normal'])
|
||||
assert.equal(values.includes('super_admin'), false)
|
||||
})
|
||||
|
||||
@@ -55,6 +58,8 @@ test('test_task_048_user_role_map_invalid_input_rejected', () => {
|
||||
assert.match(userRoleLockMessage('super_admin', { role: 'super_admin' }) || '', /超级管理员/)
|
||||
assert.match(userRoleLockMessage('admin', { role: 'normal' }) || '', /超管|管理员/)
|
||||
assert.equal(userRoleLockMessage('super_admin', { role: 'normal' }), undefined)
|
||||
// 2026-10-05:公司超管目标只有站点超管能编辑(改密码/到期时间做续费),角色锁定要单独说清
|
||||
assert.match(userRoleLockMessage('super_admin', { role: 'company_super_admin' }) || '', /公司超级管理员/)
|
||||
})
|
||||
|
||||
test('test_task_048_user_role_map_dependency_failure_returns_actionable_message', () => {
|
||||
@@ -64,4 +69,5 @@ test('test_task_048_user_role_map_dependency_failure_returns_actionable_message'
|
||||
assert.equal(roleDomainLabel('admin'), '管理员')
|
||||
assert.equal(roleDomainLabel('normal'), '普通用户')
|
||||
assert.equal(roleDomainLabel('super_admin'), '超级管理员')
|
||||
assert.equal(roleDomainLabel('company_super_admin'), '公司超级管理员')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user