feat(jd-collect): 进度/历史透传轮次游标 shopCatName/shopCatMerged——任务卡显示「正在采集分类」(多轮页码归 1 消歧,2026-11-21 方案 C 客户端侧配套)

客户端多选店内分类改逐分类轮次采集后,游标新增两键。HistoryItemVo/ProgressVo 加字段(注释与建单多选集合 shopCategoryNames 明确区分:这是「当前正在采的那一个」);BoardService#fillProgress 与 TaskService#queryProgress 读侧白名单逐键取(shopCatMerged 宽松布尔:true 字符串也认)。前端 toJdTaskView extraLines 加「正在采集分类:X(合并兜底时缀 等(页面筛选未生效,兜底翻页中))」。判据:JdCollectBoardServiceTest 游标键透传两支(selectList mock 必须 ArrayList 包 List.of——history 服务原地排序,不可变列表打爆)+jd-collect-progress.mount.test.ts 两支+jd-collect-tab.test.ts 源码绊线;门禁 mvn -o test-compile rc0+目标 49 绿、vue-tsc rc0、node --test 15 绿、vitest 24 绿。
This commit is contained in:
2026-11-21 12:07:05 +08:00
parent a2aeae9974
commit c59296da72
9 changed files with 143 additions and 0 deletions
+23
View File
@@ -283,3 +283,26 @@ test('采集状态多选:售卖中/已下架可勾选,空选禁止建单', (
assert.ok(body.includes('请至少勾选一个采集状态'),
'空选必须给「至少勾选一个」提示(按钮禁用之外的第二道)')
})
/** 2026-11-21 逐分类轮次采集(方案 C):多选店内分类时客户端逐轮驱动页面级筛选拿真
* 分母,任务卡用游标 shopCatName 显示「正在采集分类」消解多轮页码归 1 的歧义;
* 合并兜底轮(页面筛选未生效)必须明确标注,别让用户以为只采了一个分类。 */
test('任务卡展示轮次游标:正在采集分类 + 合并兜底标注', () => {
const page = readIfExists(
join(process.cwd(), 'src', 'pages', 'jd', 'JdCollectTab.vue'),
'JdCollectTab.vue',
)
const types = readIfExists(
join(process.cwd(), 'src', 'shared', 'api', 'types', 'modules', 'jd-collect.ts'),
'jd-collect.ts',
)
assert.ok(types.includes('shopCatName'), '历史行 VO 必须带轮次游标键 shopCatName')
assert.ok(types.includes('shopCatMerged'), '历史行 VO 必须带合并兜底标记 shopCatMerged')
const toJdTaskView = page.indexOf('function toJdTaskView')
assert.ok(toJdTaskView > 0, 'JdCollectTab.vue 缺 toJdTaskView')
const body = page.slice(toJdTaskView, page.indexOf('// ---- 本模块的状态语义'))
assert.ok(body.includes('正在采集分类:${item.shopCatName}'),
'toJdTaskView 必须在 extraLines 展示「正在采集分类」(页码归 1 消歧)')
assert.ok(body.includes('等(页面筛选未生效,兜底翻页中)'),
'合并兜底轮必须带「页面筛选未生效」标注')
})
@@ -231,6 +231,42 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
expect(w.find('.file-progress-meta').text()).toContain('已采集 30/100 个商品(30%)')
})
it('轮次采集时任务卡片显示「正在采集分类」,页码归 1 不再像重跑(2026-11-21 方案 C)', async () => {
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: 15, itemsReceived: 8, rowCount: 8, page: 1,
shopCatName: '礼服/演出服', batches: 2 })),
)
const w = await mountPage()
await startCollect(w)
await flushPromises()
const text = w.find('.task-item').text()
expect(text).toContain('正在采集分类:礼服/演出服')
expect(text).toContain('断点游标:第 1 页')
expect(text).not.toContain('兜底翻页中')
})
it('合并兜底轮标注「页面筛选未生效」;非轮次任务不出现该行', async () => {
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: 6, itemsReceived: 4, rowCount: 4, page: 1,
shopCatName: '工作制服', shopCatMerged: true, batches: 1 })),
)
const w = await mountPage()
await startCollect(w)
await flushPromises()
expect(w.find('.task-item').text())
.toContain('正在采集分类:工作制服 等(页面筛选未生效,兜底翻页中)')
// 非轮次任务(游标无 shopCatName):不出现该行,其余文案不受影响
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: 300, itemsReceived: 30, rowCount: 30, page: 3, batches: 4 })),
)
const w2 = await mountPage()
await startCollect(w2)
await flushPromises()
expect(w2.find('.task-item').text()).not.toContain('正在采集分类')
})
it('没有分母(total 缺失)时只显示已采集行数,不编造百分比', async () => {
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: null, page: null, itemsReceived: 30, rowCount: 30 })),