fix(jd): B188-02 直推载荷带 userId,客户端判定分层消每单误报 WARNING

This commit is contained in:
2026-11-22 01:36:08 +08:00
parent 3184d6696d
commit fe479262e6
4 changed files with 50 additions and 8 deletions
+22 -2
View File
@@ -136,12 +136,32 @@ test('建单请求体与推送载荷都带店内分类双键', () => {
join(process.cwd(), 'src', 'pages', 'jd', 'JdCollectTab.vue'),
'JdCollectTab.vue',
)
assert.ok(page.includes('maxProducts: 0, shopCategoryNames, shopCategoryIds }'),
'推送载荷 data 必须带店内分类双键(与后端 JdTaskPullSpiImplTest 键集断言同键)')
assert.ok(page.includes('maxProducts: 0,') && page.includes('shopCategoryNames,')
&& page.includes('shopCategoryIds,'),
'推送载荷 data 必须带店内分类双键(与后端 JdTaskPullSpiImplTest 键集断言同键;'
+ 'B188-01 起 data 改 Record 逐键构造,断言按键名钉不再钉整行字面量)')
assert.ok(page.includes('createJdCollectTask(shop, tabs, 0, [], shopNames, shopIds)'),
'startCollect 建单必须把选中的分类(names+ids)传给 createJdCollectTask')
})
/** B188-02(2026-11-22):推送载荷带任务归属 userId——客户端拿它与执行时刻登录身份
* 对撞,不一致显式判死;localStorage 读不到 uid('0'/NaN)就不带,「没带」是合法
* 常态、客户端静默回落(铁律 30 同形:不得把「没带」读成「带了非法值」)。
* 摘掉守卫或无条件恒带(含 '0')即红。 */
test('推送载荷带任务归属 userId,uid>0 才带', () => {
const page = readIfExists(
join(process.cwd(), 'src', 'pages', 'jd', 'JdCollectTab.vue'),
'JdCollectTab.vue',
)
const pushAt = page.indexOf('async function pushToClientQueue')
assert.ok(pushAt > 0, 'JdCollectTab.vue 缺 pushToClientQueue')
const body = page.slice(pushAt, page.indexOf('const isRunning'))
assert.ok(/data\.userId = ownerUid/.test(body),
'推送载荷 data 必须带 userId(客户端据此与登录身份对撞)')
assert.ok(/ownerUid > 0/.test(body),
'uid 读不到(localStorage 0/NaN)不得带 userId——没带是合法常态')
})
test('重试/继续从历史行同源带回店内分类双键', () => {
const page = readIfExists(
join(process.cwd(), 'src', 'pages', 'jd', 'JdCollectTab.vue'),