This commit is contained in:
2026-08-04 21:01:39 +08:00
parent 88bd939170
commit 5cb1ca307d
77 changed files with 9914 additions and 131 deletions
+86
View File
@@ -0,0 +1,86 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { getPlatformInbound, listPlatformInbounds } from './api'
vi.mock('@/shared/api/http', () => ({
http: { get: vi.fn() },
unwrapApiResponse: <T>(response: { data: T }) => response.data,
}))
describe('platform inbound query API', () => {
beforeEach(() => vi.mocked(http.get).mockReset())
it('omits the backend tenant filter for an all-customer list query', async () => {
vi.mocked(http.get).mockResolvedValue({
code: '200', message: 'success', data: { records: [], page: 1, size: 20, total: 0, pages: 0 },
})
await listPlatformInbounds(undefined, { page: 1, size: 20 })
expect(http.get).toHaveBeenCalledWith('/platform/inbounds', { params: { page: 1, size: 20 } })
})
it('uses the implemented non-v1 list path and normalizes page values and IDs', async () => {
vi.mocked(http.get).mockResolvedValue({
code: '200', message: 'success', data: {
records: [{ id: 19001, orderId: 18001, customerId: 10001, totalPackageCount: '6', holdFlag: 'false' }],
page: '1', size: '20', total: '1', pages: '1',
},
})
await expect(listPlatformInbounds('10001', {
page: 1, size: 20, tab: 'WAIT_MEASURE', inboundCode: 'RK', holdFlag: false,
})).resolves.toMatchObject({
records: [{ id: '19001', orderId: '18001', customerId: '10001', totalPackageCount: 6, holdFlag: false }],
total: 1, pages: 1,
})
expect(http.get).toHaveBeenCalledWith('/platform/inbounds', {
params: { tenantId: '10001', page: 1, size: 20, tab: 'WAIT_MEASURE', inboundCode: 'RK', holdFlag: false },
})
})
it('loads a tenant-scoped aggregate detail and keeps nested IDs as strings', async () => {
vi.mocked(http.get).mockResolvedValue({
code: '200', message: 'success', data: {
summary: { id: 19001, orderId: 18001 }, publicRemark: null,
palletLocations: [{ palletId: 21001, locationId: 22001 }], files: [{ fileId: 23001, uploadedBy: 2 }],
internalNotes: [{ id: 24001, createdBy: 2 }], statusHistory: [{ operatorId: 2 }],
},
})
await expect(getPlatformInbound('10001', '19001')).resolves.toMatchObject({
summary: { id: '19001', orderId: '18001' },
palletLocations: [{ palletId: '21001', locationId: '22001' }],
files: [{ fileId: '23001', uploadedBy: '2' }],
internalNotes: [{ id: '24001', createdBy: '2' }],
statusHistory: [{ operatorId: '2' }],
})
expect(http.get).toHaveBeenCalledWith('/platform/inbounds/19001', { params: { tenantId: '10001' } })
})
it('passes the implemented order, process, measurement and fee review filters without renaming them', async () => {
vi.mocked(http.get).mockResolvedValue({
code: '200', message: 'success', data: { records: [], page: 1, size: 20, total: 0, pages: 0 },
})
await listPlatformInbounds('10001', {
page: 1,
size: 20,
processStatus: 'MEASURE_PENDING',
orderStatus: 'APPROVED',
measureReviewStatus: 'PENDING',
feeStatus: 'UNPRICED',
feeReviewStatus: 'PENDING',
warehouseId: '9007199254740993',
deliveryWarehouseId: '9007199254740995',
})
expect(http.get).toHaveBeenCalledWith('/platform/inbounds', {
params: {
tenantId: '10001', page: 1, size: 20, processStatus: 'MEASURE_PENDING',
orderStatus: 'APPROVED', measureReviewStatus: 'PENDING', feeStatus: 'UNPRICED', feeReviewStatus: 'PENDING',
warehouseId: '9007199254740993', deliveryWarehouseId: '9007199254740995',
},
})
})
})