优化
This commit is contained in:
@@ -19,8 +19,16 @@ import { createPlatformExportTask } from '@/modules/downloads'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { useAuthStore } from '@/core/auth/auth'
|
||||
import QueryToolbar from '@/shared/components/QueryToolbar.vue'
|
||||
import { showExportTaskCreatedDialog } from '@/shared/components/exportTaskCreatedDialog'
|
||||
import CustomersView from './CustomersView.vue'
|
||||
|
||||
const { routerPush } = vi.hoisted(() => ({ routerPush: vi.fn() }))
|
||||
|
||||
vi.mock('vue-router', async (importOriginal) => ({
|
||||
...await importOriginal<typeof import('vue-router')>(),
|
||||
useRouter: () => ({ push: routerPush }),
|
||||
}))
|
||||
|
||||
vi.mock('@/modules/iam', () => ({
|
||||
approveEnterpriseReview: vi.fn(),
|
||||
changePlatformTenantStatus: vi.fn(),
|
||||
@@ -39,6 +47,7 @@ vi.mock('@/modules/iam', () => ({
|
||||
}))
|
||||
|
||||
vi.mock('@/modules/downloads', () => ({ createPlatformExportTask: vi.fn() }))
|
||||
vi.mock('@/shared/components/exportTaskCreatedDialog', () => ({ showExportTaskCreatedDialog: vi.fn() }))
|
||||
|
||||
class ResizeObserverStub implements ResizeObserver {
|
||||
observe() {}
|
||||
@@ -97,7 +106,10 @@ 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)
|
||||
vi.mocked(createPlatformExportTask).mockResolvedValue({
|
||||
id: 'export-1', taskName: '客户列表', taskNo: 'EXP2084', status: 'PENDING',
|
||||
} as never)
|
||||
vi.mocked(showExportTaskCreatedDialog).mockResolvedValue(false)
|
||||
})
|
||||
|
||||
it('loads the complete customer detail before editing masked list fields', async () => {
|
||||
@@ -272,9 +284,27 @@ describe('CustomersView', () => {
|
||||
exportType: 'CUSTOMER_LIST', format: 'XLSX', taskName: '客户列表',
|
||||
parameters: { keyword: 'Acme', status: 'ACTIVE' },
|
||||
})
|
||||
expect(showExportTaskCreatedDialog).toHaveBeenCalledWith({ taskName: '客户列表', taskNo: 'EXP2084' })
|
||||
expect(listPlatformTenants).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('opens the download center when the export-created dialog action is confirmed', async () => {
|
||||
vi.mocked(createPlatformExportTask).mockResolvedValue({
|
||||
id: 'export-1', taskName: '客户列表', taskNo: 'EXP2084', status: 'PENDING',
|
||||
} as never)
|
||||
vi.mocked(showExportTaskCreatedDialog).mockResolvedValue(true)
|
||||
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(showExportTaskCreatedDialog).toHaveBeenCalledWith({ taskName: '客户列表', taskNo: 'EXP2084' })
|
||||
expect(routerPush).toHaveBeenCalledWith({ name: 'download-center' })
|
||||
})
|
||||
|
||||
it('hides customer export when the stable export permission is absent', async () => {
|
||||
const auth = useAuthStore()
|
||||
auth.permissions = ['platform:customer:list', 'platform:customer:view']
|
||||
|
||||
Reference in New Issue
Block a user