feat(delivery): let customers read and download signed receipts

This commit is contained in:
2026-09-30 12:09:22 +08:00
parent fa9bfd5f97
commit 6abb8b7388
4 changed files with 127 additions and 12 deletions
@@ -72,6 +72,32 @@ test('loads a typed detail route by delivery number and never exposes an interna
assert.doesNotMatch(detailSource, /detail\?\.id|deliveryNo \|\| detail\?\.id|customerId|tenantId/)
})
test('receipt list and binary download use the fixed merchant scope without category or revision escape', async () => {
const api = await importTypeScriptModule(apiSource.replace(
"import { apiBlobRequest, apiRequest } from '@/api/http'",
`export const requests = []
const apiRequest = async (config) => { requests.push(config); return { deliveryNo: 'DL/1', files: [] } }
const apiBlobRequest = async (config) => { requests.push(config); return new Blob(['receipt-bytes']) }`,
))
assert.deepEqual(await api.getDeliveryReceipts('DL/1'), { deliveryNo: 'DL/1', files: [] })
assert.equal(await (await api.downloadDeliveryReceipt('DL/1', '123')).text(), 'receipt-bytes')
assert.deepEqual(api.requests, [
{ method: 'GET', url: '/merchant/v1/last-leg/delivery-orders/DL%2F1/documents/receipt' },
{ method: 'GET', url: '/merchant/v1/last-leg/delivery-orders/DL%2F1/documents/receipt/files/123/download' },
])
assert.match(detailSource, /empty-text="暂无签收资料"/)
assert.match(detailSource, /receiptsError[\s\S]*@click="loadReceipts">重试/)
assert.match(detailSource, /:loading="receiptsLoading"/)
assert.match(detailSource, /downloadDeliveryReceipt\(props\.deliveryNo, file\.fileId\)/)
assert.match(detailSource, /URL\.revokeObjectURL\(url\)/)
assert.match(detailSource, /DELIVERING: '派送中'/)
for (const status of ['WAIT_DELIVERY', 'DELIVERING', 'DELIVERED', 'REJECTED', 'RETURN_PENDING', 'RETURNED']) {
assert.match(listSource, new RegExp(`value: '${status}'`))
}
assert.doesNotMatch(listSource, /value: '(?:PENDING|IN_TRANSIT|SIGNED)'/)
assert.doesNotMatch(detailSource, /el-upload|revisionVersion|documents\/BOL/)
})
test('renders a compact customer-readable delivery detail surface', () => {
assert.match(detailSource, /<article class="delivery-detail-surface">/)
assert.match(detailSource, /<el-button link type="primary" @click="backToList"><ArrowLeft[^>]*\/>返回列表<\/el-button>/)