优化
This commit is contained in:
@@ -5,6 +5,7 @@ import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vites
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { useAuthStore } from '@/core/auth/auth'
|
||||
import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam'
|
||||
import { ApiResponseError } from '@/shared/api/http'
|
||||
import {
|
||||
actionFinanceSettlement,
|
||||
actionReconciliationStatement,
|
||||
@@ -143,6 +144,60 @@ describe('finance G3/G4 page operations', () => {
|
||||
}, ['9001'])
|
||||
})
|
||||
|
||||
it('keeps receipt errors in the modal and rejects non-image vouchers before upload', async () => {
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ar:list', 'platform:finance:receipt:create'])
|
||||
const wrapper = mount(FinanceFormalSettlementPage, { props: { kind: 'receivable' }, attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
|
||||
await flushPromises()
|
||||
const vm = wrapper.vm as unknown as {
|
||||
openReceipt(row: Record<string, unknown>): Promise<void>
|
||||
selectReceiptFile(file: { raw: File }): void
|
||||
submitReceipt(): Promise<void>
|
||||
receiptFile: File | null
|
||||
receiptOpen: boolean
|
||||
receiptValidationError: string | null
|
||||
receiptError: { message: string } | null
|
||||
}
|
||||
|
||||
vm.selectReceiptFile({ raw: new File(['not an image'], 'receipt.pdf', { type: 'application/pdf' }) })
|
||||
expect(vm.receiptFile).toBeNull()
|
||||
expect(vm.receiptValidationError).toBe('收款凭证仅支持图片文件')
|
||||
|
||||
await vm.openReceipt({ id: '701' })
|
||||
vm.selectReceiptFile({ raw: new File(['receipt'], 'receipt.png', { type: 'image/png' }) })
|
||||
vi.mocked(uploadFinanceVoucher).mockRejectedValueOnce(new ApiResponseError('FIN_400: 凭证校验失败', 'FIN_400', 400, undefined, 'request-1', 'trace-1'))
|
||||
await vm.submitReceipt()
|
||||
|
||||
expect(vm.receiptOpen).toBe(true)
|
||||
expect(vm.receiptError?.message).toContain('FIN_400')
|
||||
expect(wrapper.text()).toContain('FIN_400')
|
||||
expect(wrapper.find('[aria-label="结算单应收列表"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('emits payable detail navigation and displays customer names without internal IDs', async () => {
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ap:list'])
|
||||
const wrapper = mount(FinanceFormalSettlementPage, { props: { kind: 'payable' }, attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
|
||||
await flushPromises()
|
||||
const vm = wrapper.vm as unknown as { openDetail(row: Record<string, unknown>): void; customerName(customerId: string, snapshot?: string): string }
|
||||
|
||||
vi.mocked(getFinanceSettlement).mockClear()
|
||||
vm.openDetail({ id: '801' })
|
||||
|
||||
expect(wrapper.emitted('openDetail')).toEqual([['801']])
|
||||
expect(getFinanceSettlement).not.toHaveBeenCalled()
|
||||
expect(vm.customerName('2088', '上海客户有限公司')).toBe('上海客户有限公司')
|
||||
expect(vm.customerName('2088')).toBe('—')
|
||||
})
|
||||
|
||||
it('keeps settled settlements readable and exportable while hiding receipt actions', async () => {
|
||||
vi.mocked(getFinanceSettlement).mockResolvedValue({ ...receivable, status: 'PAID', paidAmount: 300, outstandingAmount: 0 })
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ar:list', 'platform:finance:receipt:create'])
|
||||
const wrapper = mount(FinanceFormalSettlementPage, { props: { kind: 'receivable', settlementId: '701' }, attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.text()).toContain('导出')
|
||||
expect(wrapper.text()).not.toContain('部分收款')
|
||||
})
|
||||
|
||||
it('submits settlement void and reopen actions with the current version and reason', async () => {
|
||||
const prompt = vi.spyOn(ElMessageBox, 'prompt').mockResolvedValue({ value: '账务冲销' } as never)
|
||||
const pinia = piniaWithPermissions(['platform:finance:settlement-ar:list', 'platform:finance:settlement:void'])
|
||||
|
||||
Reference in New Issue
Block a user