This commit is contained in:
2026-08-17 16:45:46 +08:00
parent 4a9438315c
commit d95c90bd1a
48 changed files with 1217 additions and 374 deletions
@@ -8,7 +8,7 @@ vi.mock('@/shared/api/http', async (original) => ({
http: { get: vi.fn(), post: vi.fn(), put: vi.fn(), patch: vi.fn() },
}))
const payload: SaveSupplierRequest = { name: '测试供应商', category: 'BOOKING', scope: 'DOMESTIC', region: '宁波', legalRepresentative: '张三', contactName: '李四', phone: '13800000000', email: null, address: null, businessLicenseNo: null, licenseFileId: '9007199254740995', status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: null }
const payload: SaveSupplierRequest = { name: '测试供应商', category: 'BOOKING', region: '宁波', legalRepresentative: '张三', contactName: '李四', phone: '13800000000', email: null, address: null, businessLicenseNo: null, licenseFileId: '9007199254740995', status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: null }
const resource = { id: 9007199254740993, tenantId: 0, ...payload, createdBy: 9007199254740994, createdAt: '2026-08-13T10:00:00', updatedBy: null, updatedAt: '2026-08-13T10:00:00', deleted: false, version: 1 }
describe('platform supplier API', () => {
@@ -18,8 +18,9 @@ describe('platform supplier API', () => {
vi.mocked(http.get)
.mockResolvedValueOnce({ code: '200', data: { records: [resource], page: 1, size: 20, total: 1, pages: 1 } })
.mockResolvedValueOnce({ code: '200', data: { booking: 1, customs: 2, trucking: 3, certificate: 4 } })
const page = await listSuppliers({ page: 1, size: 20, category: 'BOOKING', scope: 'DOMESTIC', keyword: '测试' })
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/suppliers', { params: expect.objectContaining({ category: 'BOOKING', scope: 'DOMESTIC', keyword: '测试' }) })
const page = await listSuppliers({ page: 1, size: 20, category: 'BOOKING', keyword: '测试' })
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/suppliers', { params: expect.objectContaining({ category: 'BOOKING', keyword: '测试' }) })
expect(vi.mocked(http.get).mock.calls[0]?.[1]?.params).not.toHaveProperty('scope')
expect(page.records[0]).toMatchObject({ id: expect.any(String), tenantId: '0', licenseFileId: expect.any(String), createdBy: expect.any(String) })
expect(await getSupplierStats()).toEqual({ booking: 1, customs: 2, trucking: 3, certificate: 4 })
expect(http.get).toHaveBeenNthCalledWith(2, '/platform/v1/suppliers/stats')
@@ -18,7 +18,7 @@ export async function listSuppliers(query: SupplierQuery): Promise<SupplierPage>
const response = await http.get<ApiEnvelope<SupplierPage>, ApiEnvelope<SupplierPage>>(basePath, {
params: {
page: query.page ?? 1, size: query.size ?? 20, category: query.category,
scope: query.scope || undefined, region: query.region?.trim() || undefined,
region: query.region?.trim() || undefined,
status: query.status || undefined, keyword: query.keyword?.trim() || undefined,
},
})