23 lines
1.5 KiB
TypeScript
23 lines
1.5 KiB
TypeScript
import { expect, it, vi } from 'vitest'
|
|
import { http } from '@/shared/api/http'
|
|
import { listPlanningCargo, listPlanningContainers } from './planningApi'
|
|
vi.mock('@/shared/api/http', () => ({ http: { get: vi.fn() }, unwrapApiResponse: <T>(value: { data: T }) => value.data }))
|
|
|
|
it('uses the gateway planning route and preserves stable source IDs and null predictions', async () => {
|
|
vi.mocked(http.get).mockResolvedValue({ data: { records: [{ sourceKey: 'ORDER:9007199254740993', orderId: '9007199254740993', estimatedArrivalAt: null }], page: '2', size: '20', total: '21', pages: '2' } })
|
|
const controller = new AbortController()
|
|
const result = await listPlanningCargo({ page: 2, size: 20, keyword: 'IN-A' }, controller.signal)
|
|
expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/appointment-planning/cargo', { params: { page: 2, size: 20, keyword: 'IN-A' }, signal: controller.signal })
|
|
expect(result.records[0]!.orderId).toBe('9007199254740993')
|
|
expect(result.records[0]!.estimatedArrivalAt).toBeNull()
|
|
expect(result.total).toBe(21)
|
|
})
|
|
|
|
it('keeps basic container listing on its own endpoint rather than requiring impact persistence', async () => {
|
|
vi.mocked(http.get).mockClear()
|
|
vi.mocked(http.get).mockResolvedValue({ data: { records: [], total: '0' } })
|
|
const result = await listPlanningContainers({ page: 1, size: 20 })
|
|
expect(http.get).toHaveBeenCalledExactlyOnceWith('/platform/v1/last-leg/appointment-planning/containers', { params: { page: 1, size: 20 }, signal: undefined })
|
|
expect(result.total).toBe(0)
|
|
})
|