优化
This commit is contained in:
@@ -2,7 +2,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import {
|
||||
adjustInboundFeeDetail, createInboundFeeDetail, deleteInboundFeeDetail, listInboundFeeDetails,
|
||||
reviewInboundFeeDetail, updateInboundFeeDetail, voidInboundFeeDetail, type SaveInboundFeeDetailRequest,
|
||||
listInboundFeeItemOptions, listInboundFeeSupplierOptions, reviewInboundFeeDetail,
|
||||
updateInboundFeeDetail, voidInboundFeeDetail, type SaveInboundFeeDetailRequest,
|
||||
} from './inboundFeeDetails'
|
||||
|
||||
vi.mock('@/shared/api/http', async () => {
|
||||
@@ -18,7 +19,7 @@ describe('inbound fee-detail API', () => {
|
||||
})
|
||||
|
||||
it('maps the complete write contract and optimistic version', async () => {
|
||||
const payload: SaveInboundFeeDetailRequest = { feeItemId: '31', direction: 'PAYABLE', businessDate: '2026-08-12', unitPrice: 12.5, currency: 'CNY', amount: 125, settlementIncluded: true, partnerId: '41', partnerName: '测试供应商', remark: '验收' }
|
||||
const payload: SaveInboundFeeDetailRequest = { feeItemId: '31', direction: 'PAYABLE', businessDate: '2026-08-12', unitPrice: 12.5, currency: 'CNY', amount: 125, supplierId: '41', remark: '验收' }
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: [] })
|
||||
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: payload })
|
||||
@@ -32,4 +33,31 @@ describe('inbound fee-detail API', () => {
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/inbounds/88/fee-details/11/void', { expectedSourceVersion: 3 }, { params: { accountId: '100' } })
|
||||
expect(http.delete).toHaveBeenCalledWith('/platform/v1/inbounds/88/fee-details/11', { params: { accountId: '100' } })
|
||||
})
|
||||
|
||||
it('fails closed when a fee item has no recognized supplier category', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', data: { records: [
|
||||
{ id: 31, feeTypeName: '拖车费', feeCode: 'TRUCKING', supplierCategory: 'TRUCKING', warehousePayable: true },
|
||||
{ id: 32, feeTypeName: '未知费用', feeCode: 'UNMAPPED', supplierCategory: 'UNKNOWN', warehousePayable: true },
|
||||
{ id: 33, feeTypeName: '缺少类别', feeCode: 'MISSING', warehousePayable: true },
|
||||
] } })
|
||||
await expect(listInboundFeeItemOptions()).resolves.toMatchObject([
|
||||
{ id: 31, feeCode: 'TRUCKING', supplierCategory: 'TRUCKING' },
|
||||
{ id: 32, feeCode: 'UNMAPPED', supplierCategory: null },
|
||||
{ id: 33, feeCode: 'MISSING', supplierCategory: null },
|
||||
])
|
||||
})
|
||||
|
||||
it('requests and retains only ACTIVE suppliers in the required category', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', data: { records: [
|
||||
{ id: 41, tenantId: 0, name: '承运商A', category: 'TRUCKING', status: 'ACTIVE', version: 1, deleted: false },
|
||||
{ id: 42, tenantId: 0, name: '停用承运商', category: 'TRUCKING', status: 'INACTIVE', version: 1, deleted: false },
|
||||
{ id: 43, tenantId: 0, name: '报关行', category: 'CUSTOMS', status: 'ACTIVE', version: 1, deleted: false },
|
||||
], page: 1, size: 200, total: 3, pages: 1 } })
|
||||
await expect(listInboundFeeSupplierOptions('TRUCKING')).resolves.toEqual([
|
||||
{ id: '41', supplierName: '承运商A', category: 'TRUCKING' },
|
||||
])
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/suppliers', { params: {
|
||||
page: 1, size: 200, category: 'TRUCKING', region: undefined, status: 'ACTIVE', keyword: undefined,
|
||||
} })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user