fix(admin): update submitted measurement calculation strategy

This commit is contained in:
2026-09-10 11:02:52 +08:00
parent fc0226d4cb
commit 6a038c89ca
6 changed files with 74 additions and 69 deletions
+14 -1
View File
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { createManualCartonScan, downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount } from './api'
import { createManualCartonScan, downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount, updateMeasurementCalculationStrategy } from './api'
import type { SaveInboundMeasurementDraftRequest } from './types'
vi.mock('@/shared/api/http', () => ({
@@ -76,6 +76,19 @@ describe('inbound measurement API', () => {
)
})
it('updates calculation strategy without resaving the frozen measurement batch', async () => {
const payload = { measurementId: '9001', version: 3, coefficientMode: 'ADD' as const, chargeRuleId: null }
const saved = { ...payload, version: 4, status: 'SUBMITTED' }
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: saved })
await expect(updateMeasurementCalculationStrategy('10001', '7001', payload)).resolves.toEqual(saved)
expect(http.put).toHaveBeenCalledWith(
'/platform/v1/first-leg/inbounds/7001/measurement/calculation-strategy',
payload,
{ 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)