优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ApiResponseError, http } from '@/shared/api/http'
|
||||
import {
|
||||
prepareTrip, listTrips, getTrip, createTrip, updateTripPlan, assignTrip, bindTripDispatch, unbindTripDispatch, cancelTrip,
|
||||
prepareTrip, listTrips, getTrip, createTrip, updateTripPlan, assignTrip, getTripResourceOccupancy, bindTripDispatch, unbindTripDispatch, cancelTrip,
|
||||
getTripLoading, confirmTripLoading, getTripCompletion, completeTrip, releaseTripResource, listTripHistory, reviewTripDispatch, reviewTripLoading, getTripCapacityPlan, confirmTripCapacityPlan,
|
||||
} from './trips'
|
||||
|
||||
@@ -26,6 +26,15 @@ const envelope = <T>(data: T) => ({ code: '200', message: '成功', data })
|
||||
describe('fleet trip API contract', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
|
||||
it('batches occupancy queries without rounding long resource identifiers', async () => {
|
||||
const occupancy = [{ resourceId: longId, occupiedTripNo: 'TR-OTHER', available: false }]
|
||||
vi.mocked(http.get).mockResolvedValueOnce(envelope(occupancy))
|
||||
expect(await getTripResourceOccupancy('TR/TEST', 'DRIVER', [longId, '9007199254740997'])).toEqual(occupancy)
|
||||
expect(http.get).toHaveBeenCalledExactlyOnceWith(`${base}/TR%2FTEST/resource-occupancy`, { params: { kind: 'DRIVER', resourceIds: `${longId},9007199254740997` } })
|
||||
expect(await getTripResourceOccupancy('TR/TEST', 'VEHICLE', [])).toEqual([])
|
||||
expect(http.get).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('uses one paged request and keeps long identifiers as exact strings', async () => {
|
||||
vi.mocked(http.get).mockResolvedValueOnce(envelope({ records: [trip], page: '1', size: '20', total: '121', pages: '7' }))
|
||||
const query = { page: 1, size: 20, keyword: 'TEST', warehouseId: longId }
|
||||
|
||||
Reference in New Issue
Block a user