test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -38,7 +38,7 @@ export async function verifyClientRelabelFulfillment(context, { proof, transferP
context.assert(MODULE, name, null, Boolean(passed), '', { scenario: 'client-relabel-fulfillment', deploymentBlocker: true })
if (!passed) throw new Error(name)
}
const key = action => `${context.marker}-CLIENT-RELABEL-${action}`
const key = action => `${context.marker}-CLIENT-RELABEL-${proof.relabelNo}-${action}`
const platform = `/api/platform/v1/last-leg/relabel-applications/${encodeURIComponent(proof.relabelNo)}`
const merchant = `/api/merchant/v1/last-leg/relabel-applications/${encodeURIComponent(proof.relabelNo)}`
const work = `/api/pda/v1/last-leg/relabel-tasks/${encodeURIComponent(proof.relabelNo)}`
@@ -120,6 +120,26 @@ export async function verifyClientRelabelFulfillment(context, { proof, transferP
require('换标原箱源减一目标增一且组托重放复用操作', validId(bound.operationId) && bound.status === 'COMPLETED' && boundReplay.replayed === true
&& String(bound.operationId) === String(boundReplay.operationId)
&& Number(fromAfter.totalPackages) === Number(from.totalPackages) - 1 && Number(toAfter.totalPackages) === Number(to.totalPackages) + 1)
if (transferProof) {
// 明确的受控TEST补测输入;不按箱数、原托尺寸或计费重量推算,也不作为真实硬件实测证据。
const input = { lengthCm: 120, widthCm: 100, heightCm: 80, grossWeightKg: 12.5 }
proof.palletMeasurementInput = { syntheticTestMaterials: true, input }
let measurements = await command('POST', `${PALLETS}/relabel-pallet-measurements`, { relabelNo: proof.relabelNo }, pdaToken)
const codes = new Set([from.palletCode, target.palletCode])
require('补测只接受本次源目标非空托盘及当前库存版本', Array.isArray(measurements) && measurements.length > 0
&& measurements.every(row => validId(row.palletId) && codes.has(row.palletCode) && Number(row.packages) > 0 && row.stockVersion))
for (const row of [...measurements]) {
if (['grossWeightKg', 'volumeCbm'].every(field => Number(row[field]) > 0)
&& (row.cartonAggregated || ['lengthCm', 'widthCm', 'heightCm'].every(field => Number(row[field]) > 0))) continue
require('箱级实测不完整时不能用整托输入绕过', row.cartonAggregated !== true)
measurements = await command('POST', `${PALLETS}/relabel-pallet-measure`, { relabelNo: proof.relabelNo,
palletCode: row.palletCode, stockVersion: row.stockVersion, idempotencyKey: key(`measure-${row.palletId}`), ...input }, pdaToken)
const measured = measurements.find(value => String(value.palletId) === String(row.palletId))
require('补测回执保持本托库存版本和明确TEST输入', measured?.stockVersion === row.stockVersion
&& Object.entries(input).every(([field, value]) => Number(measured[field]) === value) && Number(measured.volumeCbm) > 0)
}
proof.palletMeasurements = measurements
}
task = await command('GET', work, undefined, pdaToken)
const photo = await command('POST', `${work}/photos/files`, { name: `${context.marker}-synthetic-relabel.png`, type: 'image/png',
content: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64') }, pdaToken, true)