This commit is contained in:
2026-08-03 18:15:41 +08:00
parent 370a3926d7
commit 1241d11c01
12 changed files with 637 additions and 44 deletions
+21 -1
View File
@@ -11,6 +11,7 @@ import {
uploadPlatformTenantQualification,
type PlatformTenantResource,
} from '@/api/platformIam'
import { createPlatformExportTask } from '@/api/platformExportTasks'
import { useAccessPreviewStore } from '@/stores/accessPreview'
import { useAuthStore } from '@/stores/auth'
import CustomersView from './CustomersView.vue'
@@ -29,6 +30,8 @@ vi.mock('@/api/platformIam', () => ({
uploadPlatformTenantQualification: vi.fn(),
}))
vi.mock('@/api/platformExportTasks', () => ({ createPlatformExportTask: vi.fn() }))
class ResizeObserverStub implements ResizeObserver {
observe() {}
unobserve() {}
@@ -65,7 +68,7 @@ describe('CustomersView', () => {
setActivePinia(pinia)
const auth = useAuthStore()
auth.token = 'token'
auth.permissions = ['platform:customer:list', 'platform:customer:view', 'platform:customer:edit']
auth.permissions = ['platform:customer:list', 'platform:customer:view', 'platform:customer:edit', 'platform:customer:export']
useAccessPreviewStore().initializeAfterLogin()
vi.mocked(listPlatformTenants).mockResolvedValue({
records: [{ ...fullTenant, contactPhone: '138****8000', contactEmail: 'o***@example.com' }],
@@ -77,6 +80,7 @@ describe('CustomersView', () => {
vi.mocked(uploadPlatformTenantQualification).mockResolvedValue({
qualificationId: 'qualification-1', reviewId: null, tenantStatus: 'PROFILE_REQUIRED', documentUrl: '/files/license.png',
})
vi.mocked(createPlatformExportTask).mockResolvedValue({ id: 'export-1', status: 'PENDING' } as never)
})
it('loads the complete customer detail before editing masked list fields', async () => {
@@ -161,4 +165,20 @@ describe('CustomersView', () => {
false,
)
})
it('submits the current filters to the backend export service without loading every customer page', async () => {
mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
await flushPromises()
const exportButton = [...document.querySelectorAll<HTMLButtonElement>('button')]
.find((button) => button.textContent?.trim() === '导出Excel')
exportButton?.click()
await flushPromises()
expect(createPlatformExportTask).toHaveBeenCalledWith({
exportType: 'CUSTOMER_LIST', format: 'XLSX', taskName: '客户列表',
parameters: { keyword: undefined, status: undefined },
})
expect(listPlatformTenants).toHaveBeenCalledTimes(1)
})
})