Files
crawler-plugin/frontend-vue/tests/jd-collect-tab.test.ts
T

40 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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('路由注册京东采集页', () => {
assert.ok(readIfExists(ROUTER, 'router/index.ts').includes('/jd-collect'),
'router 缺 /jd-collect 路由')
})
test('工具台卡片声明京东工具且带权限键', () => {
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 端点组', () => {
assert.ok(readIfExists(ENDPOINTS, 'endpoints.ts').includes('jdCollect'),
'endpoints.ts 缺 jdCollect 端点组(建单/心跳/回传三件)')
})