test(phase-0): v1.4 京东数据库契约预置——通道接缝黄金 3 绿 + Pending 17 例 skip

This commit is contained in:
2026-11-14 02:27:34 +08:00
parent 64e94458c9
commit 10d73994f5
7 changed files with 371 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
/** v1.4 AC-1 用户端入口契约(蓝图 docs/ITERATION_PLAN.md §3.2 / §4 Phase 5)。
*
* 「京东采集」以工具台卡片 + 路由 + endpoints 组三件接入用户端(照工具台既有形状):
* 工具卡必须声明非空 permissionKeys(用户端工具按后端 app 菜单 column_key 过滤显隐),
* 路由 /jd-collect,endpoints.ts 有 jdCollect 组。Pending 期整组 skip;
* Phase 5 落地后去掉 skip 跑绿。
*/
const ROUTER = join(process.cwd(), 'src', 'router', 'index.ts')
const TOOL_CATALOG = join(process.cwd(), 'src', 'pages', 'amazon', 'tool-catalog.ts')
const ENDPOINTS = join(process.cwd(), 'src', 'shared', 'api', 'endpoints.ts')
function readIfExists(path: string, what: string): string {
assert.ok(existsSync(path), `${what} 尚未落地(蓝图 §4 Phase 5):${path}`)
return readFileSync(path, 'utf8')
}
test('路由注册京东采集页', { skip: 'Pending Phase 5: 京东采集入口落地后激活' }, () => {
assert.ok(readIfExists(ROUTER, 'router/index.ts').includes('/jd-collect'),
'router 缺 /jd-collect 路由')
})
test('工具台卡片声明京东工具且带权限键', { skip: 'Pending Phase 5: 京东采集入口落地后激活' }, () => {
const catalog = readIfExists(TOOL_CATALOG, 'tool-catalog.ts')
assert.ok(catalog.includes('jd-collect') || catalog.includes('京东采集'),
'TOOL_GROUPS 缺京东采集工具卡')
assert.ok(/jd[\s\S]{0,400}permissionKeys/.test(catalog),
'京东工具卡必须声明非空 permissionKeys(显隐按后端 app 菜单 key 过滤)')
})
test('endpoints 注册 jdCollect 端点组', { skip: 'Pending Phase 5: 京东采集入口落地后激活' }, () => {
assert.ok(readIfExists(ENDPOINTS, 'endpoints.ts').includes('jdCollect'),
'endpoints.ts 缺 jdCollect 端点组(建单/心跳/回传三件)')
})