This commit is contained in:
2026-08-12 14:08:33 +08:00
parent 4fb8b85c13
commit 975e0057e3
20 changed files with 378 additions and 29 deletions
+17 -1
View File
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount } from './api'
import { createManualCartonScan, downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount } from './api'
import type { SaveInboundMeasurementDraftRequest } from './types'
vi.mock('@/shared/api/http', () => ({
@@ -101,4 +101,20 @@ describe('inbound measurement API', () => {
{ params: { tenantId: '10001' } },
)
})
it('posts manual carton scan data and image to the scoped multipart route', async () => {
const result = { measurementId: '9001', measurementVersion: 3, itemId: '2', boxCode: 'RK#10-2', confirmedPackageCount: 1 }
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: result })
const image = new File(['image'], 'carton.jpg', { type: 'image/jpeg' })
await expect(createManualCartonScan('10001', '7001', {
boxCode: 'RK#10-2', length: 40, width: 30, height: 20, weight: 5,
machineNo: 'MANUAL-ADMIN', measuredAt: '2026-08-12T14:00:00', scannedShipmentId: null,
}, image)).resolves.toEqual(result)
const [path, body, config] = vi.mocked(http.post).mock.calls[0]!
expect(path).toBe('/platform/v1/first-leg/inbounds/7001/measurement/carton-scans')
expect(body).toBeInstanceOf(FormData)
expect((body as FormData).get('image')).toBe(image)
expect(config).toEqual({ params: { tenantId: '10001' }, headers: { 'Content-Type': 'multipart/form-data' } })
})
})