This commit is contained in:
2026-08-05 09:11:48 +08:00
parent db8774627e
commit 3ffa7ec55f
11 changed files with 141 additions and 41 deletions
@@ -12,6 +12,7 @@ import {
rejectEnterpriseReview,
updatePlatformTenant,
uploadPlatformTenantQualification,
uploadPlatformTenantRequiredQualificationPackage,
type EnterpriseReview,
type PlatformTenantResource,
} from '@/modules/iam'
@@ -45,6 +46,7 @@ vi.mock('@/modules/iam', () => ({
submitPlatformTenantReview: vi.fn(),
updatePlatformTenant: vi.fn(),
uploadPlatformTenantQualification: vi.fn(),
uploadPlatformTenantRequiredQualificationPackage: vi.fn(),
}))
vi.mock('@/modules/downloads', () => ({ createPlatformExportTask: vi.fn() }))
@@ -107,6 +109,13 @@ describe('CustomersView', () => {
vi.mocked(uploadPlatformTenantQualification).mockResolvedValue({
qualificationId: 'qualification-1', reviewId: null, tenantStatus: 'PROFILE_REQUIRED', documentUrl: '/files/license.png',
})
vi.mocked(uploadPlatformTenantRequiredQualificationPackage).mockResolvedValue({
businessLicenseQualificationId: 'qualification-business',
legalPersonIdQualificationId: 'qualification-legal',
tenantStatus: 'PROFILE_REQUIRED',
businessLicenseDocumentUrl: '/files/license.png',
legalPersonIdDocumentUrl: '/files/legal-person-new.png',
})
vi.mocked(createPlatformExportTask).mockResolvedValue({
id: 'export-1', taskName: '客户列表', taskNo: 'EXP2084', status: 'PENDING',
} as never)
@@ -198,7 +207,7 @@ describe('CustomersView', () => {
expect(getPlatformTenant).not.toHaveBeenCalled()
})
it('saves customer data and selected qualifications with one action', async () => {
it('saves both required files and the credit code through one package action', async () => {
vi.mocked(listTenantQualifications).mockResolvedValue([{
id: 'qualification-legal', tenantId: fullTenant.id, qualificationType: 'LEGAL_PERSON_ID',
certificateNo: null, documentUrl: '/files/legal-person.png', status: 'PENDING', reviewComment: null, validTo: null,
@@ -209,9 +218,14 @@ describe('CustomersView', () => {
await flushPromises()
const licenseFile = new File(['license'], 'license.png', { type: 'image/png' })
const licenseInput = document.querySelector<HTMLInputElement>('.qualification-file input[type="file"]')
const legalPersonFile = new File(['legal-person'], 'legal-person.png', { type: 'image/png' })
const qualificationInputs = document.querySelectorAll<HTMLInputElement>('.qualification-file input[type="file"]')
const licenseInput = qualificationInputs[0]
const legalPersonInput = qualificationInputs[1]
Object.defineProperty(licenseInput, 'files', { configurable: true, value: [licenseFile] })
licenseInput?.dispatchEvent(new Event('change', { bubbles: true }))
Object.defineProperty(legalPersonInput, 'files', { configurable: true, value: [legalPersonFile] })
legalPersonInput?.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
const buttons = [...document.querySelectorAll<HTMLButtonElement>('button')]
@@ -220,14 +234,15 @@ describe('CustomersView', () => {
await flushPromises()
expect(updatePlatformTenant).toHaveBeenCalledWith(fullTenant.id, expect.objectContaining({ tenantName: fullTenant.tenantName }))
expect(uploadPlatformTenantQualification).toHaveBeenCalledWith(
expect(uploadPlatformTenantRequiredQualificationPackage).toHaveBeenCalledWith(
fullTenant.id,
'BUSINESS_LICENSE',
licenseFile,
undefined,
legalPersonFile,
fullTenant.unifiedSocialCreditCode,
false,
true,
)
expect(uploadPlatformTenantQualification).not.toHaveBeenCalled()
})
it('submits the current filters to the backend export service without loading every customer page', async () => {