fix(delivery): expose nullable actual signed quantity to clients

This commit is contained in:
2026-10-03 23:10:44 +08:00
parent a0736239e4
commit f0777ba2db
2 changed files with 13 additions and 0 deletions
@@ -49,6 +49,7 @@ export interface DeliveryRow {
driverName: string | null
palletCount: number
packageCount: number
signedPackages: number | null
totalWeightKg: number | null
totalVolumeCbm: number | null
plannedDeliveryAt: string
@@ -18,6 +18,18 @@ async function importTypeScriptModule(source) {
return import(`data:text/javascript;base64,${Buffer.from(compiled).toString('base64')}`)
}
for (const signedPackages of [null, 0, 3]) test(`preserves actual signed quantity ${signedPackages} in merchant list and detail`, async () => {
const api = await importTypeScriptModule(apiSource.replace(
"import { apiBlobRequest, apiRequest } from '@/api/http'",
`const apiBlobRequest = async () => new Blob([])
const order = { deliveryNo: 'DL-1', packageCount: 9, signedPackages: ${JSON.stringify(signedPackages)} }
const apiRequest = async (config) => config.url.endsWith('/DL-1')
? { order, skus: [], fees: [] } : { records: [order], page: 1, size: 20, total: 1, pages: 1 }`,
))
assert.equal((await api.listDeliveryOrders({ page: 1, size: 20 })).records[0].signedPackages, signedPackages)
assert.equal((await api.getDeliveryOrder('DL-1')).signedPackages, signedPackages)
})
test('uses only authenticated merchant delivery endpoints without customer scope or mock fallback', () => {
assert.match(apiSource, /method: 'GET'[\s\S]*url: '\/merchant\/v1\/last-leg\/delivery-orders'/)
assert.match(apiSource, /delivery-orders\/\$\{encodeURIComponent\(deliveryNo\)\}/)