test(phase3): satisfy finalization fixture gates
This commit is contained in:
@@ -48,6 +48,35 @@ async function uploadDocument(context, path, expectedVersion, operationReason, l
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureCompletionEvidence(context, chain, label) {
|
||||
const tenantId = chain.source.tenantId
|
||||
const inboundId = chain.source.inboundId
|
||||
const png = Uint8Array.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,13,73,68,65,84,8,215,99,248,207,192,240,31,0,5,0,1,255,137,153,61,29,0,0,0,0,73,69,78,68,174,66,96,130])
|
||||
for (const evidenceType of ['PHOTO_STEP_1', 'PHOTO_STEP_2', 'PHOTO_STEP_3', 'PHOTO_STEP_4', 'SEAL']) {
|
||||
const uploadPath = `/api/platform/v1/files/loading-evidence/${tenantId}/${inboundId}?evidenceType=${encodeURIComponent(evidenceType)}`
|
||||
const form = new FormData()
|
||||
form.append('file', new Blob([png], { type: 'image/png' }), `${label}-${evidenceType}.png`)
|
||||
const rawUpload = await fetch(`${context.options.gateway}${uploadPath}`, {
|
||||
method: 'POST', headers: { Accept: 'application/json', Authorization: `Bearer ${context.token}` },
|
||||
body: form, signal: AbortSignal.timeout(60_000),
|
||||
})
|
||||
const uploadBody = await rawUpload.json()
|
||||
const upload = { method: 'POST', path: uploadPath, http: rawUpload.status, body: uploadBody,
|
||||
requestId: uploadBody?.requestId || rawUpload.headers.get('x-request-id'),
|
||||
traceId: uploadBody?.traceId || rawUpload.headers.get('x-trace-id') }
|
||||
const file = context.apiSuccess(MODULE, `${label} 上传 ${evidenceType} 装柜证据`, upload, '', OPTIONS)
|
||||
const fileId = id(file?.id || file?.fileId)
|
||||
if (!fileId) throw new Error(`${label} ${evidenceType} 未返回文件ID`)
|
||||
const bind = await post(context,
|
||||
`/api/platform/v1/inbounds/${inboundId}/loading/evidence?tenantId=${encodeURIComponent(tenantId)}`, {
|
||||
expectedVersion: 0, evidenceType, fileId,
|
||||
sealNo: evidenceType === 'SEAL' ? `SEAL-${suffix(context, label)}`.slice(0, 64) : null,
|
||||
remark: context.marker,
|
||||
}, `${label}-evidence-${evidenceType}`)
|
||||
context.apiSuccess(MODULE, `${label} 绑定 ${evidenceType} 装柜证据`, bind, '', OPTIONS)
|
||||
}
|
||||
}
|
||||
|
||||
async function prepareInbound(context, label) {
|
||||
const originalMarker = context.marker
|
||||
const fixtureMarker = `${originalMarker}-MAN-${label}`
|
||||
@@ -267,6 +296,7 @@ async function pickAll(context, chain, label) {
|
||||
}
|
||||
|
||||
async function complete(context, chain, label) {
|
||||
await ensureCompletionEvidence(context, chain, label)
|
||||
const response = await context.request('POST', `${PDA}/tasks/${chain.task.id}/complete`, {
|
||||
expectedTaskVersion: Number(chain.task.version), operationId: operationId(context, `${label}-complete`),
|
||||
remark: `${context.marker} 人工完成状态样本`,
|
||||
|
||||
Reference in New Issue
Block a user