test(firstleg): scope loading evidence by cabinet
This commit is contained in:
@@ -52,6 +52,17 @@ test('default fixture publishes a second marker-owned inbound for the same-plan
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('HTTP chain refreshes after stale inventory and keeps one stable PDA identity', () => {
|
test('HTTP chain refreshes after stale inventory and keeps one stable PDA identity', () => {
|
||||||
|
assert.match(loading,
|
||||||
|
/async function uploadEvidence\(context, containerBookingId, evidenceType\)/)
|
||||||
|
assert.match(loading,
|
||||||
|
/files\/loading-evidence\/\$\{containerBookingId\}\?evidenceType=/)
|
||||||
|
assert.match(loading,
|
||||||
|
/files\/loading-evidence\/\$\{containerBookingId\}\/\$\{fileId\}/)
|
||||||
|
assert.equal((loading.match(/uploadEvidence\(context, containerBookingId,/g) || []).length, 5)
|
||||||
|
assert.doesNotMatch(loading,
|
||||||
|
/files\/loading-evidence\/\$\{tenantId\}\/\$\{inboundId\}/)
|
||||||
|
assert.doesNotMatch(loading,
|
||||||
|
/uploadEvidence\(context, tenantId, inboundId,/)
|
||||||
ordered(loading, [
|
ordered(loading, [
|
||||||
'创建三期 DRAFT 订舱(不生成真实柜)',
|
'创建三期 DRAFT 订舱(不生成真实柜)',
|
||||||
'三期 DRAFT 订舱返回稳定身份和初始版本',
|
'三期 DRAFT 订舱返回稳定身份和初始版本',
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ async function request(context, method, path, body, headers = {}) {
|
|||||||
} catch (error) { return { method, path, http: 0, body: null, raw: String(error), requestId: null, traceId: null } }
|
} catch (error) { return { method, path, http: 0, body: null, raw: String(error), requestId: null, traceId: null } }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadEvidence(context, tenantId, inboundId, evidenceType) {
|
async function uploadEvidence(context, containerBookingId, evidenceType) {
|
||||||
const path = `/api/platform/v1/files/loading-evidence/${tenantId}/${inboundId}?evidenceType=${encodeURIComponent(evidenceType)}`
|
const path = `/api/platform/v1/files/loading-evidence/${containerBookingId}?evidenceType=${encodeURIComponent(evidenceType)}`
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
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])
|
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])
|
||||||
const fileName = `${context.marker}-${evidenceType.toLowerCase()}.png`
|
const fileName = `${context.marker}-${evidenceType.toLowerCase()}.png`
|
||||||
@@ -896,7 +896,7 @@ export async function run(context) {
|
|||||||
const evidenceTypes = ['PHOTO_STEP_1', 'PHOTO_STEP_2', 'PHOTO_STEP_3', 'PHOTO_STEP_4', 'SEAL']
|
const evidenceTypes = ['PHOTO_STEP_1', 'PHOTO_STEP_2', 'PHOTO_STEP_3', 'PHOTO_STEP_4', 'SEAL']
|
||||||
const evidenceItems = []
|
const evidenceItems = []
|
||||||
for (const evidenceType of evidenceTypes) {
|
for (const evidenceType of evidenceTypes) {
|
||||||
const upload = await uploadEvidence(context, tenantId, inboundId, evidenceType)
|
const upload = await uploadEvidence(context, containerBookingId, evidenceType)
|
||||||
const uploaded = context.apiSuccess(MODULE, `上传本轮 ${evidenceType} 真实证据文件`, upload, '', OPTIONS)
|
const uploaded = context.apiSuccess(MODULE, `上传本轮 ${evidenceType} 真实证据文件`, upload, '', OPTIONS)
|
||||||
const fileId = id(uploaded?.fileId)
|
const fileId = id(uploaded?.fileId)
|
||||||
context.assert(MODULE, `${evidenceType} 文件归属类型和媒体元数据正确`, upload,
|
context.assert(MODULE, `${evidenceType} 文件归属类型和媒体元数据正确`, upload,
|
||||||
@@ -934,7 +934,8 @@ export async function run(context) {
|
|||||||
`HTTP=${conflict.http}, code=${codeOf(conflict)}, requestId=${conflict.requestId || 'missing'}, traceId=${conflict.traceId || 'missing'}`, OPTIONS)
|
`HTTP=${conflict.http}, code=${codeOf(conflict)}, requestId=${conflict.requestId || 'missing'}, traceId=${conflict.traceId || 'missing'}`, OPTIONS)
|
||||||
}
|
}
|
||||||
|
|
||||||
const download = await context.requestBinary('GET', `/api/platform/v1/files/loading-evidence/${tenantId}/${inboundId}/${fileId}`)
|
const download = await context.requestBinary('GET',
|
||||||
|
`/api/platform/v1/files/loading-evidence/${containerBookingId}/${fileId}`)
|
||||||
context.assert(MODULE, `下载本轮 ${evidenceType} 证据文件`, download,
|
context.assert(MODULE, `下载本轮 ${evidenceType} 证据文件`, download,
|
||||||
download.http === 200 && download.contentType.toLowerCase().includes('image/png') && download.bytes.length > 0,
|
download.http === 200 && download.contentType.toLowerCase().includes('image/png') && download.bytes.length > 0,
|
||||||
`bytes=${download.bytes.length}, contentType=${download.contentType || 'missing'}`, OPTIONS)
|
`bytes=${download.bytes.length}, contentType=${download.contentType || 'missing'}`, OPTIONS)
|
||||||
@@ -948,7 +949,7 @@ export async function run(context) {
|
|||||||
const firstPhoto = evidenceItems.find((item) => item.evidenceType === 'PHOTO_STEP_1')
|
const firstPhoto = evidenceItems.find((item) => item.evidenceType === 'PHOTO_STEP_1')
|
||||||
const sealEvidence = evidenceItems.find((item) => item.evidenceType === 'SEAL')
|
const sealEvidence = evidenceItems.find((item) => item.evidenceType === 'SEAL')
|
||||||
|
|
||||||
const appendedUpload = await uploadEvidence(context, tenantId, inboundId, 'PHOTO_STEP_1')
|
const appendedUpload = await uploadEvidence(context, containerBookingId, 'PHOTO_STEP_1')
|
||||||
const appendedFile = context.apiSuccess(MODULE, '追加同类型第二张装柜证据文件', appendedUpload, '', OPTIONS)
|
const appendedFile = context.apiSuccess(MODULE, '追加同类型第二张装柜证据文件', appendedUpload, '', OPTIONS)
|
||||||
const appendedFileId = id(appendedFile?.fileId)
|
const appendedFileId = id(appendedFile?.fileId)
|
||||||
const appended = appendedFileId
|
const appended = appendedFileId
|
||||||
@@ -1045,7 +1046,7 @@ export async function run(context) {
|
|||||||
context.addStep(MODULE, '作废唯一证据类型后不提前占用异步完成命令', null, true,
|
context.addStep(MODULE, '作废唯一证据类型后不提前占用异步完成命令', null, true,
|
||||||
'PHOTO_STEP_4 已真实作废并回读;补传恢复后才允许最终阶段提交唯一完成命令', OPTIONS)
|
'PHOTO_STEP_4 已真实作废并回读;补传恢复后才允许最终阶段提交唯一完成命令', OPTIONS)
|
||||||
|
|
||||||
const replacementUpload = await uploadEvidence(context, tenantId, inboundId, 'PHOTO_STEP_4')
|
const replacementUpload = await uploadEvidence(context, containerBookingId, 'PHOTO_STEP_4')
|
||||||
const replacementFile = context.apiSuccess(MODULE, '补传缺失 PHOTO_STEP_4 真实文件', replacementUpload, '', OPTIONS)
|
const replacementFile = context.apiSuccess(MODULE, '补传缺失 PHOTO_STEP_4 真实文件', replacementUpload, '', OPTIONS)
|
||||||
const replacementFileId = id(replacementFile?.fileId)
|
const replacementFileId = id(replacementFile?.fileId)
|
||||||
const replacementBind = replacementFileId
|
const replacementBind = replacementFileId
|
||||||
@@ -1078,7 +1079,7 @@ export async function run(context) {
|
|||||||
wrongInboundEvidence.http === 200 && codeOf(wrongInboundEvidence) === 'A0404',
|
wrongInboundEvidence.http === 200 && codeOf(wrongInboundEvidence) === 'A0404',
|
||||||
`HTTP=${wrongInboundEvidence.http}, code=${codeOf(wrongInboundEvidence)}`, OPTIONS)
|
`HTTP=${wrongInboundEvidence.http}, code=${codeOf(wrongInboundEvidence)}`, OPTIONS)
|
||||||
|
|
||||||
const postLoadedUpload = await uploadEvidence(context, tenantId, inboundId, 'PHOTO_STEP_2')
|
const postLoadedUpload = await uploadEvidence(context, containerBookingId, 'PHOTO_STEP_2')
|
||||||
const postLoadedFile = context.apiSuccess(MODULE, '预置 LOADED 后新增证据边界文件', postLoadedUpload, '', OPTIONS)
|
const postLoadedFile = context.apiSuccess(MODULE, '预置 LOADED 后新增证据边界文件', postLoadedUpload, '', OPTIONS)
|
||||||
const postLoadedFileId = id(postLoadedFile?.fileId)
|
const postLoadedFileId = id(postLoadedFile?.fileId)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user