feat: complete phase three admin loading workflow

This commit is contained in:
2026-08-10 12:05:20 +08:00
parent bbe93ca235
commit 2915e6d599
7 changed files with 191 additions and 80 deletions
@@ -1,12 +1,13 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import {
completeDelivery,
completeLoading,
confirmingPreload,
getPicking,
getPreload,
smartSplit,
uploadEvidenceFile,
voidEvidence,
} from './api'
vi.mock('@/shared/api/http', () => ({
@@ -45,15 +46,6 @@ describe('unified order workflow API contract', () => {
expect(vi.mocked(http.post).mock.calls.some(([url]) => String(url).includes('/actions/'))).toBe(false)
})
it('uses the inbound version for delivery completion', async () => {
vi.mocked(http.post).mockResolvedValue({ data: { mainStatus: 'DELIVERED', evidences: null } })
await completeDelivery('2', '8', { expectedVersion: 9, remark: '已确认派送' })
expect(http.post).toHaveBeenCalledWith(
'/platform/v1/inbounds/8/delivery/complete', { expectedVersion: 9, remark: '已确认派送' },
expect.objectContaining({ params: { tenantId: '2' }, headers: { 'Idempotency-Key': expect.any(String) } }),
)
})
it('does not swallow non-success responses', async () => {
vi.mocked(http.get).mockRejectedValue(new Error('无权限'))
await expect(getPreload('2', '8')).rejects.toThrow('无权限')
@@ -67,4 +59,20 @@ describe('unified order workflow API contract', () => {
expect.objectContaining({ params: { tenantId: '2' } }),
)
})
it('uploads a real evidence file and voids evidence through audited endpoints', async () => {
vi.mocked(http.post)
.mockResolvedValueOnce({ data: { fileId: '88', fileName: 'empty.jpg' } })
.mockResolvedValueOnce({ data: { mainStatus: 'LOADING', evidences: { inboundId: '8', evidences: [] } } })
await uploadEvidenceFile('2', '8', 'PHOTO_STEP_1', new File(['photo'], 'empty.jpg', { type: 'image/jpeg' }))
await voidEvidence('2', '8', '33', { expectedVersion: 2, reason: '照片错误' })
expect(http.post).toHaveBeenNthCalledWith(1,
'/platform/v1/files/loading-evidence/2/8', expect.any(FormData),
{ headers: { 'Content-Type': 'multipart/form-data' } },
)
expect(http.post).toHaveBeenNthCalledWith(2,
'/platform/v1/inbounds/8/loading/evidence/33/void', { expectedVersion: 2, reason: '照片错误' },
expect.objectContaining({ params: { tenantId: '2' }, headers: { 'Idempotency-Key': expect.any(String) } }),
)
})
})