fix:优化再拼一次bug,优化打手端移动端拼单列表显示
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
compareWorkerHallOrderRows,
|
||||
evaluateWorkerKeywordVerdict,
|
||||
matchesWorkerWorkOrderKeyword,
|
||||
patchWorkerHallPersonalShares,
|
||||
patchWorkerWorkOrderInfiniteEnvelope,
|
||||
patchWorkerWorkOrderListEnvelope,
|
||||
resolveWorkerMyOrderRealtimeVerdict,
|
||||
@@ -428,6 +429,56 @@ test('大厅广播覆盖行时必须保留本打手的 myShare/myShares,并更
|
||||
assert.equal(insertedRow?.myShares ?? null, null)
|
||||
})
|
||||
|
||||
test('旧版大厅广播显式带 null/[] 时也不能冲掉本打手份额', () => {
|
||||
const cachedRow = buildRow({
|
||||
status: 'open',
|
||||
myShare: { shareId: 88, quantity: 2, status: 'joined' },
|
||||
myShares: [{ shareId: 88, quantity: 2, status: 'joined' }],
|
||||
sharingProgress: { joinedQuantity: 2, pendingSubmissionCount: 1 },
|
||||
})
|
||||
const envelope = { pages: [buildEnvelope([cachedRow])], pageParams: [1] }
|
||||
const patched = patchWorkerWorkOrderInfiniteEnvelope(
|
||||
envelope,
|
||||
{
|
||||
operation: 'upsert',
|
||||
data: buildRow({
|
||||
status: 'open',
|
||||
myShare: null,
|
||||
myShares: [],
|
||||
sharingProgress: { joinedQuantity: 3 },
|
||||
}),
|
||||
},
|
||||
true,
|
||||
['myShare', 'myShares'],
|
||||
) as { pages: unknown[] }
|
||||
const row = itemsOf(patched.pages[0])[0] as {
|
||||
myShare?: { shareId: number }
|
||||
myShares?: unknown[]
|
||||
sharingProgress?: { joinedQuantity: number }
|
||||
}
|
||||
assert.equal(row.myShare?.shareId, 88, '旧事件不能把「再拼一次」冲掉')
|
||||
assert.equal(row.myShares?.length, 1)
|
||||
assert.equal(row.sharingProgress?.joinedQuantity, 3, '公开进度仍取广播最新值')
|
||||
})
|
||||
|
||||
test('「我的订单」快照回填大厅行个人份额:撤销份额后清空,找不到工单不改缓存', () => {
|
||||
const joined = buildRow({
|
||||
workOrderId: 5,
|
||||
status: 'open',
|
||||
myShare: { shareId: 66, quantity: 1, status: 'joined' },
|
||||
myShares: [{ shareId: 66, quantity: 1, status: 'joined' }],
|
||||
})
|
||||
const envelope = { pages: [buildEnvelope([joined])], pageParams: [1] }
|
||||
|
||||
const cleared = patchWorkerHallPersonalShares(envelope, 5, null, []) as { pages: unknown[] }
|
||||
const row = itemsOf(cleared.pages[0])[0] as { myShare?: unknown; myShares?: unknown[] }
|
||||
assert.equal(row.myShare ?? null, null, '后台撤掉份额后大厅按钮要能恢复成「拼单」')
|
||||
assert.deepEqual(row.myShares, [])
|
||||
|
||||
// 工单不在大厅缓存里时原样返回,不能凭空造行。
|
||||
assert.equal(patchWorkerHallPersonalShares(envelope, 999, null, []), envelope)
|
||||
})
|
||||
|
||||
/**
|
||||
* 线上坑:进大厅后过一会儿「排名靠后的订单跑到前面去」。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user