add:新增同一个工单同一人可以多次拼单:拼单后按钮固定显示「再拼一次」
This commit is contained in:
@@ -280,3 +280,49 @@ test('没有 workerStatuses 的旧快照仍按单个 status 比对(保持既
|
||||
})
|
||||
assert.equal(match.operation, 'upsert')
|
||||
})
|
||||
|
||||
/**
|
||||
* 大厅按钮需求:拼过一次后按钮固定显示「再拼一次」,不再随次数变化。
|
||||
* 这依赖 myShare/myShares 一直留在行上;而大厅广播是「所有打手通用」的快照,
|
||||
* 不含个人份额,覆盖行时必须保留,否则按钮会被冲回「拼单 ¥x/份」。
|
||||
*/
|
||||
test('大厅广播覆盖行时必须保留本打手的 myShare/myShares,并更新拼单进度', () => {
|
||||
const cachedRow = buildRow({
|
||||
status: 'open',
|
||||
myShare: { shareId: 77, quantity: 1, status: 'joined' },
|
||||
myShares: [{ shareId: 77, quantity: 1, status: 'joined' }],
|
||||
sharingProgress: { joinedQuantity: 1, pendingSubmissionCount: 1 },
|
||||
})
|
||||
const envelope = { pages: [buildEnvelope([cachedRow])], pageParams: [1] }
|
||||
const snapshot = buildRow({
|
||||
status: 'open',
|
||||
sharingProgress: { joinedQuantity: 2, pendingSubmissionCount: 2 },
|
||||
})
|
||||
const patched = patchWorkerWorkOrderInfiniteEnvelope(
|
||||
envelope,
|
||||
{ operation: 'upsert', data: snapshot },
|
||||
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, 77, '不能把「再拼一次」的依据冲掉')
|
||||
assert.equal(row.myShares?.length, 1)
|
||||
assert.equal(row.sharingProgress?.joinedQuantity, 2, '公开进度仍要用广播里的最新值')
|
||||
|
||||
// 新插入的行本来就不属于我,不能凭空补上旧字段
|
||||
const inserted = patchWorkerWorkOrderInfiniteEnvelope(
|
||||
envelope,
|
||||
{ operation: 'upsert', data: buildRow({ workOrderId: 9999, status: 'open' }) },
|
||||
true,
|
||||
['myShare', 'myShares'],
|
||||
) as { pages: unknown[] }
|
||||
const insertedRow = itemsOf(inserted.pages[0]).find((item) => item.workOrderId === 9999) as
|
||||
| { myShare?: unknown; myShares?: unknown }
|
||||
| undefined
|
||||
assert.equal(insertedRow?.myShare ?? null, null)
|
||||
assert.equal(insertedRow?.myShares ?? null, null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user