This commit is contained in:
2026-08-06 14:55:17 +08:00
parent a813426588
commit 4ac0adac62
18 changed files with 379 additions and 352 deletions
@@ -37,13 +37,13 @@ const payload: SavePlatformPartnerRequest = {
describe('platform partner API', () => {
beforeEach(() => vi.clearAllMocks())
it('queries the platform partner page with tenant and filters', async () => {
it('queries the platform partner page with filters only', async () => {
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: { records: [], page: '1', size: '20', total: '1', pages: '1' } })
const result = await listPlatformPartners(10001, { page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' })
const result = await listPlatformPartners({ page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' })
expect(http.get).toHaveBeenCalledWith('/platform/v1/partners', {
params: { tenantId: 10001, page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' },
params: { page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' },
})
expect(result).toMatchObject({ page: 1, size: 20, total: 1, pages: 1 })
})
@@ -53,13 +53,13 @@ describe('platform partner API', () => {
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: null })
vi.mocked(http.patch).mockResolvedValue({ code: '200', message: 'success', data: null })
await createPlatformPartner(10001, payload)
await updatePlatformPartner(10001, '19001', payload)
await changePlatformPartnerStatus(10001, '19001', 'INACTIVE')
await createPlatformPartner(payload)
await updatePlatformPartner('19001', payload)
await changePlatformPartnerStatus('19001', 'INACTIVE')
expect(http.post).toHaveBeenCalledWith('/platform/v1/partners', payload, { params: { tenantId: 10001 } })
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 } })
expect(http.post).toHaveBeenCalledWith('/platform/v1/partners', payload, { params: { tenantId: 0 } })
expect(http.put).toHaveBeenCalledWith('/platform/v1/partners/19001', payload, { params: { tenantId: 0 } })
expect(http.patch).toHaveBeenCalledWith('/platform/v1/partners/19001/status', { status: 'INACTIVE' }, { params: { tenantId: 0 } })
})
it('normalizes legacy detail types and uses import contracts', async () => {
@@ -75,17 +75,17 @@ describe('platform partner API', () => {
fileName: 'partners.xlsx', totalRows: 1, importedRows: 1, success: true, errors: [],
} })
const detail = await getPlatformPartner(10001, '19001')
const detail = await getPlatformPartner('19001')
const template = await downloadPlatformPartnerImportTemplate()
const file = new File(['xlsx'], 'partners.xlsx')
const result = await importPlatformPartners(10001, file)
const result = await importPlatformPartners(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(1, '/platform/v1/partners/19001', { params: { tenantId: 0 } })
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 } })
expect(http.post).toHaveBeenCalledWith('/platform/v1/partners/import', expect.any(FormData), { params: { tenantId: 0 } })
})
})