feat(jd-collect): 任务进度行已采计数取 max(itemsReceived, rowCount)——分片被拒时不再与行数行自相矛盾

34959 实录:8 行已落京东数据库、分片回传 500 ⇒ 服务端 itemsReceived=0、rowCount=8,卡片 extraLines 显示「已采集 8 个商品」而进度行显示「已采集 0 个商品」。rowCount 是落库真值,进度百分比与计数文案统一取两者大者;分母(cursor.total)口径不变——客户端筛选生效时会写真分母(app_client 123777d 同窗)。判据:jd-collect-progress.mount 新增两支(分片被拒显示 8/8 99%、无分母取 rowCount 真值)18/18 绿+jd-collect-tab 12/12+vue-tsc rc0
This commit is contained in:
2026-11-19 23:35:29 +08:00
parent c6f70a0b11
commit 9220bbdc82
2 changed files with 42 additions and 3 deletions
@@ -242,6 +242,35 @@ describe('获取店铺数据:一键采集 + 任务面板', () => {
expect(w.find('.file-progress-bar').attributes('style')).toContain('width: 0%')
})
it('分片被拒时进度行以落库 rowCount 为准(itemsReceived 低估不再与行数行自相矛盾)', async () => {
// 34959 实录(2026-11-19):8 行已落京东数据库、分片回传 500 ⇒ 服务端
// itemsReceived=0、rowCount=8,extraLines 显示「已采集 8 个商品」而进度行显示 0。
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: 8, itemsReceived: 0, rowCount: 8 })),
)
const w = await mountPage()
await startCollect(w)
await flushPromises()
const meta = w.find('.file-progress-meta')
expect(meta.text()).toContain('已采集 8/8 个商品(99%)')
expect(meta.text()).not.toContain('已采集 0 个')
// 已落库 8/8:条形按 99% 封顶(SUCCESS 才满格)
expect(w.find('.file-progress-bar').attributes('style')).toContain('width: 99%')
})
it('没有分母且分片被拒时已采行数也取 rowCount 真值', async () => {
api.fetchJdCollectTaskProgressBatch.mockResolvedValue(
batchOf(historyItem({ total: null, page: null, itemsReceived: 0, rowCount: 8 })),
)
const w = await mountPage()
await startCollect(w)
await flushPromises()
expect(w.find('.file-progress-meta').text()).toContain('已采集 8 个商品')
expect(w.find('.file-progress-meta').text()).not.toContain('已采集 0 个')
})
it('SUCCESS 终态:状态徽章落「获取完成」、进度满格,且从轮询中收手', async () => {
const w = await mountPage()
await startCollect(w)