49 lines
2.6 KiB
TypeScript
49 lines
2.6 KiB
TypeScript
import { test } from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { existsSync, readFileSync } from 'node:fs'
|
||
import { join } from 'node:path'
|
||
import { adminPages } from '../src/router/routes.ts'
|
||
|
||
/** v1.4「京东数据库」后管页契约(蓝图 docs/ITERATION_PLAN.md §3.4 / §4 Phase 5)。
|
||
*
|
||
* 与 company-menu-route.test.ts 同一取材方式:routes 注册表 + 后端迁移文件对撞。
|
||
* Pending 期整组 skip(node:test 原生 skip,零假断言);Phase 5 落地后去掉 skip 跑绿。
|
||
* 四处接线(routes / company-scope / operation-guides / V196 菜单迁移)少一处即红,
|
||
* 对齐既有护栏 company-menu-route 与 align-operation-guide 的口径。
|
||
*/
|
||
|
||
const V196 = join(process.cwd(), '..', 'backend-java', 'src', 'main', 'resources', 'db',
|
||
'V196__jd_database_menu.sql')
|
||
const COMPANY_SCOPE = join(process.cwd(), 'src', 'config', 'company-scope.ts')
|
||
const OPERATION_GUIDES = join(process.cwd(), 'src', 'layout', 'operation-guides.ts')
|
||
|
||
const MENU_KEY = 'admin_jd_database'
|
||
const ROUTE = 'jd-center/database'
|
||
|
||
function readIfExists(path: string, what: string): string {
|
||
assert.ok(existsSync(path), `${what} 尚未落地(蓝图 §4 Phase 5):${path}`)
|
||
return readFileSync(path, 'utf8')
|
||
}
|
||
|
||
test('V196 菜单迁移钉住 column_key 与 route_path', { skip: 'Pending Phase 5: 京东数据库页面落地后激活' }, () => {
|
||
const sql = readIfExists(V196, 'V196 迁移')
|
||
assert.ok(sql.includes(MENU_KEY), 'V196 缺 column_key admin_jd_database')
|
||
assert.ok(sql.includes(ROUTE), 'V196 缺 route_path jd-center/database')
|
||
assert.ok(!sql.includes('user_column_permission'), '菜单迁移不得插授权行(V190 惯例)')
|
||
})
|
||
|
||
test('routes 注册表出现京东数据库页面且公司隔离', { skip: 'Pending Phase 5: 京东数据库页面落地后激活' }, () => {
|
||
const page = adminPages.find((item) => item.menuKey === MENU_KEY)
|
||
assert.ok(page, `routes.ts 缺 menuKey=${MENU_KEY} 的注册行`)
|
||
assert.equal(page.path, ROUTE, 'route_path 必须与 V196 菜单一致')
|
||
assert.equal(page.title, '京东数据库', '菜单标题以「京东数据库」为准')
|
||
assert.equal(page.companyScoped, true, '京东数据库按公司隔离(AC-6)')
|
||
})
|
||
|
||
test('company-scope 与 operation-guides 同轮接线', { skip: 'Pending Phase 5: 京东数据库页面落地后激活' }, () => {
|
||
assert.ok(readIfExists(COMPANY_SCOPE, 'company-scope.ts').includes(ROUTE),
|
||
'COMPANY_SCOPED_PAGES 缺京东数据库登记(company-tab 护栏会红)')
|
||
assert.ok(readIfExists(OPERATION_GUIDES, 'operation-guides.ts').includes('京东数据库'),
|
||
'operation-guides 缺京东数据库条目(align-operation-guide 护栏会红)')
|
||
})
|