优化优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import ElementPlus from 'element-plus'
|
||||
import ElementPlus, { ElMessageBox } from 'element-plus'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
getOutboundDispatch,
|
||||
getPreload,
|
||||
smartSplit,
|
||||
voidEvidence,
|
||||
} from '../api'
|
||||
|
||||
vi.mock('../api', async (importOriginal) => {
|
||||
@@ -19,6 +20,7 @@ vi.mock('../api', async (importOriginal) => {
|
||||
getOutboundDispatch: vi.fn(),
|
||||
getPreload: vi.fn(),
|
||||
smartSplit: vi.fn(),
|
||||
voidEvidence: vi.fn(),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -50,6 +52,7 @@ describe('UnifiedOrderWorkflowPanel preload editor', () => {
|
||||
vi.mocked(getEvidence).mockReset().mockResolvedValue({ inboundId: '2086085512165634051', evidences: [] })
|
||||
vi.mocked(getPreload).mockReset().mockResolvedValue(preload('REF-OLD'))
|
||||
vi.mocked(smartSplit).mockReset()
|
||||
vi.mocked(voidEvidence).mockReset()
|
||||
})
|
||||
|
||||
it('renders the formal preload table and keeps the operation column first', async () => {
|
||||
@@ -116,4 +119,41 @@ describe('UnifiedOrderWorkflowPanel preload editor', () => {
|
||||
expect(wrapper.text()).not.toContain('完成装柜')
|
||||
expect(wrapper.findAll('button').some((button) => button.text() === '作废')).toBe(false)
|
||||
})
|
||||
|
||||
it('uses a validated dialog when voiding evidence', async () => {
|
||||
vi.mocked(getEvidence).mockResolvedValue({
|
||||
inboundId: '2086085512165634051',
|
||||
evidences: [
|
||||
{ id: '1', inboundId: '2086085512165634051', tenantId: '2086085512165634052', evidenceType: 'PHOTO_STEP_1', fileId: '11', fileName: 'wrong.jpg', sealNo: null, remark: null, version: 2, status: 'ACTIVE', createdAt: null, updatedAt: null },
|
||||
],
|
||||
})
|
||||
vi.mocked(voidEvidence).mockResolvedValue({} as never)
|
||||
const prompt = vi.spyOn(ElMessageBox, 'prompt').mockResolvedValue({ value: '照片上传错误' } as never)
|
||||
const wrapper = mountPanel(['platform:firstleg:inbound:loading:view', 'platform:firstleg:inbound:loading:edit'], 'LOADING')
|
||||
await flushPromises()
|
||||
|
||||
const voidButton = wrapper.findAll('button').find((button) => button.text() === '作废')
|
||||
expect(voidButton).toBeTruthy()
|
||||
await voidButton!.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(prompt).toHaveBeenCalledWith(
|
||||
'作废后照片仍会保留在审计记录中。',
|
||||
'作废证据照片',
|
||||
expect.objectContaining({
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: '请输入作废原因',
|
||||
type: 'warning',
|
||||
}),
|
||||
)
|
||||
const options = prompt.mock.calls[0]?.[2]
|
||||
expect(options?.inputValidator?.(' ')).toBe('作废原因不能为空')
|
||||
expect(voidEvidence).toHaveBeenCalledWith(
|
||||
'2086085512165634052',
|
||||
'2086085512165634051',
|
||||
'1',
|
||||
{ expectedVersion: 2, reason: '照片上传错误' },
|
||||
)
|
||||
prompt.mockRestore()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user