fix: align audit and dispatch workflows and release failed requests

This commit is contained in:
2026-10-22 23:10:09 +08:00
parent 9cdcb9c077
commit 4a3456756f
124 changed files with 1296 additions and 2120 deletions
@@ -12,6 +12,17 @@ vi.mock('../api/dispatches', () => ({ getDispatchEvidence: vi.fn(), getDispatchE
const metadata = (fileId = '301', contentType = 'image/png'): DispatchEvidenceFile => ({ fileId, fileName: contentType === 'application/pdf' ? '本车证照.pdf' : '本车证据.png', contentType, sizeBytes: 3 })
const options = { props: { modelValue: ['301'], dispatchNo: 'PC/1', kind: 'VEHICLE' as const }, global: { stubs: { ElButton: { props: ['disabled'], template: '<button :disabled="disabled"><slot /></button>' }, AppDialog: { name: 'AppDialog', props: ['modelValue', 'title'], template: '<section v-if="modelValue" role="dialog"><slot /><button @click="$emit(\'update:modelValue\', false)">关闭预览</button></section>' } } } }
const button = (wrapper: ReturnType<typeof mount>, label: string) => wrapper.findAll('button').find(value => value.text() === label)!
it.each(['VEHICLE', 'DRIVER_PHOTO', 'DRIVER'] as const)('does not count a PDF or failed upload as a %s photo', async kind => {
const wrapper = mount(DispatchEvidenceFiles, { ...options, props: { ...options.props, kind, photoCard: true, modelValue: [] } }); await flushPromises()
await selectFile(wrapper, new File(['pdf'], 'document.pdf', { type: 'application/pdf' }))
expect(api.uploadDispatchEvidence).not.toHaveBeenCalled()
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
vi.mocked(api.uploadDispatchEvidence).mockRejectedValueOnce(new Error('上传失败'))
await selectFile(wrapper, new File(['png'], 'photo.png', { type: 'image/png' }))
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
expect(wrapper.emitted('busy')?.at(-1)).toEqual([false])
wrapper.unmount()
})
it('previews an unsaved master license through its driver and keeps uploaded license files on the dispatch route', async () => {
vi.mocked(downloadDriverLicense).mockResolvedValue(new Blob(['png'], { type: 'image/png' }))
const wrapper = mount(DispatchEvidenceFiles, { ...options, props: { ...options.props, kind: 'DRIVER', photoCard: true, modelValue: ['301'], referenceIds: ['33'], masterLicense: { driverId: '2', fileId: '33' } } }); await flushPromises()