Merge release/test and preserve pickup execution and photo workflows
This commit is contained in:
@@ -34,6 +34,38 @@ it('does not render a late thumbnail from the previous dispatch or an invalid im
|
||||
expect(URL.createObjectURL).not.toHaveBeenCalled(); expect(wrapper.find('img').exists()).toBe(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
it('uses the dialog body for the image and keeps loading until the browser decodes it', async () => {
|
||||
const wrapper = mount(DispatchEvidenceFiles, options); await flushPromises()
|
||||
await button(wrapper, '预览').trigger('click'); await flushPromises()
|
||||
const dialog = wrapper.get('[role="dialog"]')
|
||||
expect(dialog.find('table').exists()).toBe(false)
|
||||
expect(dialog.get('.evidence-preview').attributes('aria-busy')).toBe('true')
|
||||
const image = dialog.get('img')
|
||||
Object.defineProperties(image.element, { naturalWidth: { value: 1200 }, naturalHeight: { value: 800 } })
|
||||
await image.trigger('load')
|
||||
expect(dialog.get('.evidence-preview').attributes('aria-busy')).toBe('false')
|
||||
expect(image.attributes('src')).toBe('blob:authenticated')
|
||||
expect(dialog.text()).not.toContain('图片无法预览')
|
||||
wrapper.unmount()
|
||||
})
|
||||
it.each(['single-pixel', 'decode-error'])('explains %s images inside the preview and retries the owned content', async failure => {
|
||||
const wrapper = mount(DispatchEvidenceFiles, options); await flushPromises()
|
||||
await button(wrapper, '预览').trigger('click'); await flushPromises()
|
||||
const image = wrapper.get('[role="dialog"] img')
|
||||
if (failure === 'single-pixel') {
|
||||
Object.defineProperties(image.element, { naturalWidth: { value: 1 }, naturalHeight: { value: 1 } })
|
||||
await image.trigger('load')
|
||||
} else await image.trigger('error')
|
||||
expect(wrapper.get('[role="dialog"]').text()).toContain(failure === 'single-pixel' ? '1 × 1 像素' : '图片无法解码或加载')
|
||||
expect(wrapper.get('.evidence-preview').attributes('aria-busy')).toBe('false')
|
||||
expect(wrapper.find('[role="dialog"] img').exists()).toBe(false)
|
||||
await button(wrapper, '重新预览').trigger('click'); await flushPromises()
|
||||
expect(api.getDispatchEvidenceContent).toHaveBeenCalledTimes(2)
|
||||
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:authenticated')
|
||||
expect(wrapper.get('[role="dialog"] img').attributes('src')).toBe('blob:authenticated')
|
||||
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
|
||||
wrapper.unmount()
|
||||
})
|
||||
it('keeps previously provided references read-only and only submits newly uploaded audit files', async () => {
|
||||
const wrapper = mount(DispatchEvidenceFiles, { ...options, props: { ...options.props, modelValue: [], referenceIds: ['301'], kind: 'DRIVER_PHOTO', label: '司机照片' } }); await flushPromises()
|
||||
expect(wrapper.findAll('tbody button').map(item => item.text())).toEqual(['预览'])
|
||||
|
||||
Reference in New Issue
Block a user