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
@@ -151,8 +151,8 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
expect(api.createJdCollectTask).toHaveBeenCalledTimes(1)
// 店铺名留空 → 按「京麦后台」占位(客户端从京麦后台现读真实店铺名落库);
// 不选类目=空数组(全店采集,后端归一化为 null 进 request_json)
expect(api.createJdCollectTask).toHaveBeenCalledWith('京麦后台', ['ONSALE', 'OFFSALE'], 0, [])
// 不选分类=双键空数组(全店采集,后端归一化为 null 进 request_json)
expect(api.createJdCollectTask).toHaveBeenCalledWith('京麦后台', ['ONSALE', 'OFFSALE'], 0, [], [], [])
expect(api.activateJdCollectTask).toHaveBeenCalledWith(88)
expect(api.enqueue).toHaveBeenCalledTimes(1)
const payload = api.enqueue.mock.calls[0][0]
@@ -162,7 +162,8 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
shopName: '京麦后台',
listTabs: ['ONSALE', 'OFFSALE'],
maxProducts: 0,
categoryPaths: [],
shopCategoryNames: [],
shopCategoryIds: [],
})
// 轮询已启动:批量进度端点拿到任务 88
expect(api.fetchJdCollectTaskProgressBatch).toHaveBeenCalled()
@@ -283,75 +284,54 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
expect(w.find('.feedback.error').exists()).toBe(false)
})
it('勾选类目后建单:categoryPaths 随建单请求体与推送载荷同链下发', async () => {
// 2026-11-16 用户口径「客户端前端也要同步加上京东类目」+「你直接爬」:面板换京麦
// 授权类目真树(逐级下钻、末级勾选)——下钻 运动户外 → 舞蹈体操鞋服/装备(客户
// 舞蹈服类目在京麦归运动户外支)→ 勾末级「艺考形体服」后建单请求体与推送载荷都要
// 带 ['艺考形体服'](客户端按行 categoryPath 等值过滤的源头;mock 类目用树内真实
// 末级名,贴合落库形状)。
api.fetchJdCollectCategories.mockResolvedValue([
{ name: '艺考形体服', productCount: 5 },
{ name: '啦啦队服', productCount: 3 },
])
it('勾选分类后建单:店内分类双键随建单请求体与推送载荷同链下发', async () => {
// 2026-11-16 客户口径「类目不需要只要分类」「选京麦的内部分类去采集」+「做成多选的」:
// 选项集=京麦「店内分类」快照(jd-shop-category.ts,getShopCategoryList 取证 9 个),
// checkbox 多选;建单请求体与推送载荷带 label+id 双键(行级填充形状未取证,客户端
// 任一键命中即命中)——mock 选中项用快照真实行(拉丁舞服/1024347572),贴合下发形状。
const w = await mountPage()
await w.find('.cat-trigger').trigger('click')
await w.findAll('.cat-col')[0].findAll('.cat-row').find((row) => row.text().includes('运动户外'))!.trigger('click')
let cols = w.findAll('.cat-col')
expect(cols).toHaveLength(2, '点亮一级后第二栏出现(真树下钻)')
await cols[1].findAll('.cat-row').find((row) => row.text().includes('舞蹈体操鞋服/装备'))!.trigger('click')
cols = w.findAll('.cat-col')
expect(cols).toHaveLength(3, '二级非末级:第三栏出末级子级')
const leafRow = cols[2].findAll('.cat-row').find((row) => row.text().includes('艺考形体服'))
expect(leafRow, '第三栏必须渲染出该支的末级(艺考形体服)').toBeTruthy()
await leafRow!.trigger('click')
const rows = w.findAll('.shop-cat-item')
expect(rows.length).toBeGreaterThan(0, '分类多选列表必须渲染快照选项')
const latinRow = rows.find((row) => row.text().includes('拉丁舞服'))
expect(latinRow, '快照里必须有「拉丁舞服」').toBeTruthy()
await latinRow!.find('input').setValue(true)
const uniformRow = rows.find((row) => row.text().includes('工作制服'))
await uniformRow!.find('input').setValue(true)
await flushPromises()
expect(w.find('.cat-trigger-text').text()).toBe('艺考形体服', '单选勾选后触发框显示类目名')
await w.find('.cat-mask').trigger('click')
await startCollect(w)
expect(api.createJdCollectTask).toHaveBeenCalledWith('京麦后台', ['ONSALE', 'OFFSALE'], 0, ['艺考形体服'])
expect(api.createJdCollectTask).toHaveBeenCalledWith('京麦后台', ['ONSALE', 'OFFSALE'], 0, [],
['拉丁舞服', '工作制服'], ['1024347572', '1024347567'])
const payload = api.enqueue.mock.calls[0][0]
expect(payload.data).toEqual({
taskId: 88,
shopName: '京麦后台',
listTabs: ['ONSALE', 'OFFSALE'],
maxProducts: 0,
categoryPaths: ['艺考形体服'],
shopCategoryNames: ['拉丁舞服', '工作制服'],
shopCategoryIds: ['1024347572', '1024347567'],
})
})
it('店铺分类只读块:页面加载即拉取并把管理员建的分类与商品数展示出来', async () => {
// 2026-11-16 客户口径「管理员弄了多少店铺分类 普通账户都能看到」:普通账号在
// 「获取店铺数据」页就能看到后管京东数据库建的分类全集;本页只读,不提供增删改。
api.fetchJdCollectGroups.mockResolvedValue([
{ id: 1, name: 'ASSS', sortOrder: 0, productCount: 20 },
{ id: 2, name: '家居日用', sortOrder: 1, productCount: 7 },
])
it('采集分类块:快照选项全量渲染并可取消勾选(清空恢复全店采集)', async () => {
const w = await mountPage()
expect(api.fetchJdCollectGroups).toHaveBeenCalledTimes(1)
const block = w.findAll('.category-block').find((el) => el.text().includes('自定义分类'))
expect(block, '必须有「自定义分类」展示块').toBeTruthy()
expect(block!.text()).toContain('自定义分类')
const chips = block!.findAll('.group-chip')
expect(chips.length).toBe(2)
expect(chips[0].text()).toContain('ASSS(20)')
expect(chips[1].text()).toContain('家居日用(7)')
expect(chips[0].attributes('title')).toContain('ASSS:20 个商品')
})
const block = w.findAll('.category-block').find((el) => el.text().includes('采集分类'))
expect(block, '必须有「采集分类(可选,多选)」块').toBeTruthy()
expect(block!.text()).toContain('采集分类(可选,多选)')
// 快照 9 项全渲染(客户端「能看见管理员/商家建的分类」口径落点就在这)
expect(block!.findAll('.shop-cat-item').length).toBe(9)
expect(block!.text()).toContain('不选=全店采集')
it('后台还没建分类:只读块落空态提示,采集主路照常', async () => {
const w = await mountPage()
const block = w.findAll('.category-block').find((el) => el.text().includes('自定义分类'))
expect(block, '空态也要有「自定义分类」块(不能整块消失让用户以为没这功能)').toBeTruthy()
expect(block!.text()).toContain('后台还没建自定义分类')
expect(block!.text()).toContain('管理员可在「京东数据库」的类目面板中新建自定义分类')
expect(block!.text()).not.toContain('京东数据库 → 店铺分类')
expect(block!.find('.group-chip').exists()).toBe(false)
// 拉取失败只 warning、不影响建单主路(catch 口径见 catch-silence-ratchet 319)
expect(w.find('.collect-btn').exists()).toBe(true)
const first = block!.findAll('.shop-cat-item')[0]
await first.find('input').setValue(true)
await flushPromises()
expect(block!.text()).toContain('只采选中 1 个分类的商品')
expect(block!.find('.shop-cat-clear').exists()).toBe(true, '选中后出「清空」')
await block!.find('.shop-cat-clear').trigger('click')
await flushPromises()
expect(block!.text()).toContain('不选=全店采集')
})
})