This commit is contained in:
2026-08-07 17:14:42 +08:00
parent c0590ffc73
commit 8474829b0e
7 changed files with 149 additions and 117 deletions
+27 -1
View File
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement } from './api'
import { downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount } from './api'
import type { SaveInboundMeasurementDraftRequest } from './types'
vi.mock('@/shared/api/http', () => ({
@@ -75,4 +75,30 @@ describe('inbound measurement API', () => {
{ params: { tenantId: '10001' } },
)
})
it('downloads the current measurement image using the scoped file route', async () => {
const image = new Blob(['image-data'], { type: 'image/jpeg' })
vi.mocked(http.get).mockResolvedValue(image)
await expect(downloadInboundMeasurementImage('100/01', '7001#1', '88001')).resolves.toBe(image)
expect(http.get).toHaveBeenCalledWith(
'/platform/v1/files/measurements/100%2F01/7001%231/88001',
{ responseType: 'blob' },
)
})
it('updates one scanned carton confirmed package count', async () => {
const saved = { measurementId: '9001', measurementVersion: 3, itemId: '1', boxCode: 'RK#10-1', confirmedPackageCount: 9 }
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: saved })
await expect(updateConfirmedPackageCount('10001', '7001', '1', {
measurementVersion: 2,
confirmedPackageCount: 9,
})).resolves.toEqual(saved)
expect(http.put).toHaveBeenCalledWith(
'/platform/v1/first-leg/inbounds/7001/measurement/items/1/confirmed-package-count',
{ measurementVersion: 2, confirmedPackageCount: 9 },
{ params: { tenantId: '10001' } },
)
})
})