feat(jd-collect): 建单页按京麦店内分类多选采集

客户口径「类目不需要只要分类」「做成多选的」:采集建单页下线类目级联与平台分组,
换京麦「店内分类」快照多选(getShopCategoryList 2026-11-16 取证 9 个,见
ops docs/jd-collect-api-contract.md §2.6)。建单请求体/页面推送/兜底拉取三处同键
shopCategoryNames+shopCategoryIds(label+id 双键,行级填充形状未取证,客户端任一
命中即命中);categoryPaths 标 @Deprecated 仅历史行兼容。超长归一化文案泛化为
normalizeStringSelection;历史行 VO 带回双键供重试/继续同源。
删除建单页唯一消费方的死件:JdCategoryCascader.vue/jd-category-tree.ts/其测试
(后管另有在用副本,不受影响)。

判据:JdCollectTaskServiceTest 三例(双键归一化/空白归 null/51 个拒)+
JdTaskPullSpiImplTest 七键载荷透传;前端 jd-collect-tab/jd-shop-category/mount
三支(快照消费、双键同链、绊线:级联组件与分组接口不得回流建单页)。
可读棘轮:JdCollectTab.vue 804→786 行(同款返回按钮 CSS 合并、死 .download 类删除)。
客户端侧(app_client jd_base 行级过滤)同窗另一仓提交。
This commit is contained in:
2026-11-16 20:14:40 +08:00
parent 61c361222d
commit e621deea58
16 changed files with 435 additions and 855 deletions
@@ -0,0 +1,54 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
/** 京麦「店内分类」快照契约(2026-11-16 真机取证,建单页采集分类多选的选项集)。
*
* 快照是纯前端静态数据(getShopCategoryList 的 label/value 对,扁平单层)。判据钉四件:
* ① 快照非空且形状齐(label/value 都非空字符串);② label 不重复(多选以 label 下发,
* 重名会让客户端过滤语义歧义);③ 取证出处注释在位(后人按原路重抓,防止当它错改);
* ④ 建单页消费快照(对手面 jd-collect-tab.test.ts 的发送口断言)。 */
const SNAPSHOT = join(process.cwd(), 'src', 'pages', 'jd', 'jd-shop-category.ts')
function readIfExists(path: string, what: string): string {
assert.ok(existsSync(path), `${what} 尚未落地:${path}`)
return readFileSync(path, 'utf8')
}
test('店内分类快照非空且每项 label/value 齐全', async () => {
const mod = await import('../src/pages/jd/jd-shop-category.ts')
const { JD_SHOP_CATEGORY_SNAPSHOT } = mod as {
JD_SHOP_CATEGORY_SNAPSHOT: { label: string; value: string }[]
}
assert.ok(Array.isArray(JD_SHOP_CATEGORY_SNAPSHOT) && JD_SHOP_CATEGORY_SNAPSHOT.length > 0,
'快照不得为空(2026-11-16 取证 9 个)')
for (const item of JD_SHOP_CATEGORY_SNAPSHOT) {
assert.ok(typeof item.label === 'string' && item.label.trim().length > 0,
`label 必须是非空字符串: ${JSON.stringify(item)}`)
assert.ok(typeof item.value === 'string' && item.value.trim().length > 0,
`value(京麦分类 id)必须是非空字符串: ${JSON.stringify(item)}`)
}
})
test('快照 label 不重复(多选按 label 下发,重名会让过滤语义歧义)', async () => {
const mod = await import('../src/pages/jd/jd-shop-category.ts')
const { JD_SHOP_CATEGORY_SNAPSHOT } = mod as {
JD_SHOP_CATEGORY_SNAPSHOT: { label: string }[]
}
const labels = JD_SHOP_CATEGORY_SNAPSHOT.map((item) => item.label)
assert.equal(new Set(labels).size, labels.length,
`label 有重复: ${labels.join(', ')}`)
})
test('取证出处与边界注释在位(防后人当它错改)', () => {
const body = readIfExists(SNAPSHOT, 'jd-shop-category.ts')
assert.ok(body.includes('getShopCategoryList'),
'快照文件必须写明数据来源接口(ShopCategoryReadViewService.getShopCategoryList)')
assert.ok(body.includes('2026-11-16'), '快照文件必须带取证日期')
assert.ok(body.includes('shopCategorys') || body.includes('shopCategoryPath'),
'快照文件必须写明行级过滤键(shopCategorys/shopCategoryPath/groupId)')
assert.ok(body.includes('0/450') || body.includes('没给商品挂分类'),
'快照文件必须写明「采样店铺 0 商品挂分类」的现状边界(选分类=0 行命中是已知形状)')
})