This commit is contained in:
2026-08-19 09:42:12 +08:00
parent 80cfca5056
commit 0cd13f0b4d
18 changed files with 86 additions and 50 deletions
@@ -34,17 +34,19 @@ describe('inbound fee-detail API', () => {
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 () => {
it('keeps an empty supplier category as null and rejects an unknown non-empty 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 },
])
vi.mocked(http.get).mockResolvedValue({ code: '200', data: { records: [
{ id: 32, feeTypeName: '未知费用', feeCode: 'UNMAPPED', supplierCategory: 'UNKNOWN', warehousePayable: true },
] } })
await expect(listInboundFeeItemOptions()).rejects.toThrow('Unsupported supplierCategory: UNKNOWN')
})
it('requests and retains only ACTIVE suppliers in the required category', async () => {
@@ -60,4 +62,19 @@ describe('inbound fee-detail API', () => {
page: 1, size: 200, category: 'TRUCKING', region: undefined, status: 'ACTIVE', keyword: undefined,
} })
})
it('requests all categories and retains every ACTIVE supplier when the category is empty', 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(null)).resolves.toEqual([
{ id: '41', supplierName: '承运商A', category: 'TRUCKING' },
{ id: '43', supplierName: '报关行', category: 'CUSTOMS' },
])
expect(http.get).toHaveBeenCalledWith('/platform/v1/suppliers', { params: {
page: 1, size: 200, category: undefined, region: undefined, status: 'ACTIVE', keyword: undefined,
} })
})
})