优化
This commit is contained in:
@@ -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' } })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user