优化
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { beforeEach, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { assignTransport } from './transportTasks'
|
||||
vi.mock('@/shared/api/http', () => ({ http: { post: vi.fn() }, unwrapApiResponse: (value: { data: unknown }) => value.data }))
|
||||
vi.mock('@/modules/overseas-master-data', () => ({ normalizeTripDetail: (value: unknown) => value }))
|
||||
beforeEach(() => vi.resetAllMocks())
|
||||
const body = { recordVersion: 4, vehicleId: '1', driverId: '2', reason: '保存照片', reviewPhotos: { vehicleFileIds: ['21'], driverPhotoFileIds: ['22'], licenseFileIds: [] }, masterLicenseFileId: '33' }
|
||||
it('does not submit photo changes when the backend has not supplied the dispatch version', () => {
|
||||
expect(() => assignTransport('PC1', body)).toThrow('照片保存版本')
|
||||
expect(http.post).not.toHaveBeenCalled()
|
||||
})
|
||||
it('preserves zero dispatch version and opaque photo IDs in the assignment', async () => {
|
||||
vi.mocked(http.post).mockResolvedValue({ data: { dispatchNo: 'PC1', taskType: 'PICKUP', dispatchRecordVersion: '1', resources: { vehicle: { evidenceFileIds: ['21'] } }, execution: {}, pickups: [] } })
|
||||
const result = await assignTransport('PC1', { ...body, dispatchRecordVersion: 0 })
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/transport-tasks/PC1/assign', { ...body, dispatchRecordVersion: 0 })
|
||||
expect(result.resources?.vehicle?.evidenceFileIds).toEqual(['21'])
|
||||
})
|
||||
Reference in New Issue
Block a user