test(firstleg): align trucking attachment regressions
This commit is contained in:
@@ -185,6 +185,29 @@ export async function run(context) {
|
||||
&& !Object.hasOwn(appointment, 'receivableAmount')
|
||||
&& !Object.hasOwn(appointment, 'customerId') && !Object.hasOwn(appointment, 'customerName'), '', OPTIONS)
|
||||
const path = `${TRUCKS}/${appointmentId}`
|
||||
const attachmentForm = new FormData(); attachmentForm.append('attachmentType', 'DISPATCH_ORDER')
|
||||
attachmentForm.append('file', new Blob([`${context.marker}-DISPATCH_ORDER`], { type: 'application/pdf' }),
|
||||
`dispatch-order-${identity.suffix}.pdf`)
|
||||
const uploadAttachmentResponse = await context.requestMultipart('POST', `${path}/attachments/upload`,
|
||||
attachmentForm, context.token)
|
||||
const uploadedAttachment = context.apiSuccess(MODULE, '上传并关联DISPATCH_ORDER拖车附件', uploadAttachmentResponse, '', OPTIONS)
|
||||
const uploadedAttachmentId = id(uploadedAttachment?.id); const uploadedFileId = id(uploadedAttachment?.fileId)
|
||||
context.assert(MODULE, '拖车附件类型仅使用运营附件而非订舱提单', uploadAttachmentResponse,
|
||||
Boolean(uploadedAttachmentId && uploadedFileId) && uploadedAttachment?.attachmentType === 'DISPATCH_ORDER',
|
||||
`attachmentId=${uploadedAttachmentId || 'missing'}, fileId=${uploadedFileId || 'missing'}`, OPTIONS)
|
||||
const deleteUploadedResponse = await request(context, 'DELETE', `${path}/attachments/${uploadedAttachmentId}`)
|
||||
context.apiSuccess(MODULE, '删除首次上传的拖车附件引用', deleteUploadedResponse, '', OPTIONS)
|
||||
const referenceResponse = await request(context, 'POST', `${path}/attachments`,
|
||||
{ fileId: uploadedFileId, attachmentType: 'DISPATCH_ORDER' })
|
||||
const referencedAttachment = context.apiSuccess(MODULE, '重新引用平台归属拖车附件', referenceResponse, '', OPTIONS)
|
||||
const referencedAttachmentId = id(referencedAttachment?.id)
|
||||
const attachmentListResponse = await request(context, 'GET', `${path}/attachments`)
|
||||
const attachmentList = context.apiSuccess(MODULE, '查询拖车运营附件列表', attachmentListResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '附件列表包含重新引用的DISPATCH_ORDER', attachmentListResponse,
|
||||
Array.isArray(attachmentList) && attachmentList.some((item) => id(item?.id) === referencedAttachmentId
|
||||
&& item?.attachmentType === 'DISPATCH_ORDER'), `attachmentId=${referencedAttachmentId || 'missing'}`, OPTIONS)
|
||||
const deleteReferencedResponse = await request(context, 'DELETE', `${path}/attachments/${referencedAttachmentId}`)
|
||||
context.apiSuccess(MODULE, '删除重新引用的拖车附件', deleteReferencedResponse, '', OPTIONS)
|
||||
const usdResponse = await request(context, 'PUT', path,
|
||||
{ ...base, currency: 'USD', payableAmount: 12.34, expectedVersion: Number(appointment.version) })
|
||||
const usdAppointment = context.apiSuccess(MODULE, '编辑为USD应付费用', usdResponse, '', OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user