优化
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { getPlatformUnifiedOrder, listPlatformUnifiedOrders } from './unifiedOrders'
|
||||
import {
|
||||
approvePlatformUnifiedOrder,
|
||||
assignPlatformUnifiedOrderCarrier,
|
||||
getPlatformUnifiedOrder,
|
||||
listPlatformUnifiedOrders,
|
||||
} from './unifiedOrders'
|
||||
|
||||
vi.mock('@/shared/api/http', () => ({
|
||||
http: { get: vi.fn() },
|
||||
http: { get: vi.fn(), post: vi.fn(), put: vi.fn() },
|
||||
unwrapApiResponse: <T>(response: { data: T }) => response.data,
|
||||
}))
|
||||
|
||||
describe('unified orders API contract', () => {
|
||||
beforeEach(() => vi.mocked(http.get).mockReset())
|
||||
beforeEach(() => {
|
||||
vi.mocked(http.get).mockReset()
|
||||
vi.mocked(http.post).mockReset()
|
||||
vi.mocked(http.put).mockReset()
|
||||
})
|
||||
|
||||
it('uses the C02 platform orders endpoint and contract filters', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ data: { records: [], page: '2', size: '20', total: '0', pages: '0' } })
|
||||
@@ -62,7 +71,14 @@ describe('unified orders API contract', () => {
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/orders/90001', { params: { tenantId: '208' } })
|
||||
})
|
||||
|
||||
it('does not expose a guessed generic action endpoint', async () => {
|
||||
expect(http).not.toHaveProperty('post')
|
||||
it('uses the explicit first-leg carrier and approval boundaries for pending review', async () => {
|
||||
vi.mocked(http.put).mockResolvedValue({ data: null })
|
||||
vi.mocked(http.post).mockResolvedValue({ data: null })
|
||||
|
||||
await assignPlatformUnifiedOrderCarrier('208', '90001', '30001')
|
||||
await approvePlatformUnifiedOrder('208', '90001')
|
||||
|
||||
expect(http.put).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001/carrier', { carrierId: '30001' }, { params: { tenantId: '208' } })
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/orders/first-leg/90001/approve', undefined, { params: { tenantId: '208' } })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user