This commit is contained in:
2026-10-21 17:49:04 +08:00
parent 22e60248d2
commit 4f5cec1b94
20 changed files with 192 additions and 56 deletions
@@ -62,6 +62,17 @@ it('shows existing photos without exposing upload for a read-only account', asyn
expect(api.uploadLoadingPhoto).not.toHaveBeenCalled(); wrapper.unmount()
})
it('allows choosing another image after the server definitively rejects the file', async () => {
vi.mocked(api.uploadLoadingPhoto).mockRejectedValueOnce(new ApiResponseError('图片内容无效', 'A0400'))
const wrapper = setup(); await flushPromises(); await upload(wrapper)
expect(wrapper.text()).toContain('图片内容无效')
expect(wrapper.find('[role="status"]').exists()).toBe(false)
expect(api.bindLoadingPhoto).not.toHaveBeenCalled()
await upload(wrapper)
expect(api.uploadLoadingPhoto).toHaveBeenCalledTimes(2)
expect(wrapper.emitted('saved')).toHaveLength(1); wrapper.unmount()
})
it('allows saving photos while loading and keeps the loading stage', async () => {
vi.mocked(api.getLoadingDocuments).mockResolvedValue(data({ stage: 'LOADING' }))
vi.mocked(api.bindLoadingPhoto).mockResolvedValue(data({ stage: 'LOADING', recordVersion: '1', photos: [photo] }))