This commit is contained in:
2026-08-03 14:58:17 +08:00
parent bc44a7942d
commit ee997ae894
17 changed files with 1694 additions and 303 deletions
+32
View File
@@ -3,6 +3,9 @@ import { http } from '@/api/http'
import {
changePlatformPartnerStatus,
createPlatformPartner,
downloadPlatformPartnerImportTemplate,
getPlatformPartner,
importPlatformPartners,
listPlatformPartners,
updatePlatformPartner,
type SavePlatformPartnerRequest,
@@ -17,6 +20,7 @@ const payload: SavePlatformPartnerRequest = {
partnerCode: 'CUS-001',
partnerName: '测试往来单位',
partnerType: 'CUSTOMER',
types: ['CUSTOMER', 'SHIPPER'],
contactName: '测试联系人',
contactPhone: '13800000000',
contactEmail: null,
@@ -27,6 +31,7 @@ const payload: SavePlatformPartnerRequest = {
addressLine: '测试地址 1 号',
postalCode: null,
status: 'ACTIVE',
remark: '测试档案',
}
describe('platform partner API', () => {
@@ -56,4 +61,31 @@ describe('platform partner API', () => {
expect(http.put).toHaveBeenCalledWith('/platform/v1/partners/19001', payload, { params: { tenantId: 10001 } })
expect(http.patch).toHaveBeenCalledWith('/platform/v1/partners/19001/status', { status: 'INACTIVE' }, { params: { tenantId: 10001 } })
})
it('normalizes legacy detail types and uses import contracts', async () => {
vi.mocked(http.get)
.mockResolvedValueOnce({ code: '200', message: 'success', data: {
id: '19001', tenantId: 10001, partnerCode: 'CUS-001', partnerName: '测试单位',
partnerType: 'BOTH', contactName: '张三', contactPhone: '13800000000', contactEmail: null,
countryCode: 'CN', province: null, city: '深圳市', district: null, addressLine: '测试地址',
postalCode: null, status: 'ACTIVE',
} })
.mockResolvedValueOnce(new Blob(['template']))
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: {
fileName: 'partners.xlsx', totalRows: 1, importedRows: 1, success: true, errors: [],
} })
const detail = await getPlatformPartner(10001, '19001')
const template = await downloadPlatformPartnerImportTemplate()
const file = new File(['xlsx'], 'partners.xlsx')
const result = await importPlatformPartners(10001, file)
expect(detail.types).toEqual(['CUSTOMER', 'SUPPLIER'])
expect(detail.dataScopeId).toBe(10001)
expect(template).toBeInstanceOf(Blob)
expect(result.success).toBe(true)
expect(http.get).toHaveBeenNthCalledWith(1, '/platform/v1/partners/19001', { params: { tenantId: 10001 } })
expect(http.get).toHaveBeenNthCalledWith(2, '/platform/v1/partners/import-template', { responseType: 'blob' })
expect(http.post).toHaveBeenCalledWith('/platform/v1/partners/import', expect.any(FormData), { params: { tenantId: 10001 } })
})
})