feat: add inbound hold evidence controls
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { downloadInboundCartonLabels, getPlatformInbound, getPlatformInboundHold, holdPlatformInbound, listPlatformInbounds, releasePlatformInbound } from './api'
|
||||
import { downloadInboundCartonLabels, downloadPlatformInboundHoldEvidence, getPlatformInbound, getPlatformInboundHold, holdPlatformInbound, listPlatformInbounds, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './api'
|
||||
|
||||
vi.mock('@/shared/api/http', () => ({
|
||||
ApiResponseError: class ApiResponseError extends Error {
|
||||
@@ -146,4 +146,27 @@ describe('platform inbound query API', () => {
|
||||
params: { tenantId: '10002' }, headers: { 'Idempotency-Key': 'release-key' },
|
||||
})
|
||||
})
|
||||
|
||||
it('uploads and downloads tenant-scoped hold evidence without narrowing long IDs', async () => {
|
||||
const file = new File(['evidence'], '扣货说明.pdf', { type: 'application/pdf' })
|
||||
vi.mocked(http.post).mockResolvedValueOnce({ data: {
|
||||
fileId: '9007199254740999', fileName: '扣货说明.pdf', contentType: 'application/pdf', sizeBytes: '8',
|
||||
} })
|
||||
await expect(uploadPlatformInboundHoldEvidence('10002', '19001', file)).resolves.toEqual({
|
||||
fileId: '9007199254740999', fileName: '扣货说明.pdf', contentType: 'application/pdf', sizeBytes: 8,
|
||||
})
|
||||
const [path, body, options] = vi.mocked(http.post).mock.calls[0]!
|
||||
expect(path).toBe('/platform/inbounds/19001/hold/evidence')
|
||||
expect(body).toBeInstanceOf(FormData)
|
||||
expect((body as FormData).get('file')).toBe(file)
|
||||
expect(options).toEqual({ params: { tenantId: '10002' }, headers: { 'Content-Type': 'multipart/form-data' } })
|
||||
|
||||
const blob = new Blob(['evidence'], { type: 'application/pdf' })
|
||||
vi.mocked(http.get).mockResolvedValueOnce(blob)
|
||||
await expect(downloadPlatformInboundHoldEvidence('10002', '19001', '9007199254740999')).resolves.toBe(blob)
|
||||
expect(http.get).toHaveBeenLastCalledWith(
|
||||
'/platform/inbounds/19001/hold/evidence/9007199254740999/download',
|
||||
{ params: { tenantId: '10002' }, responseType: 'blob' },
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user