This commit is contained in:
2026-08-12 12:35:32 +08:00
parent 11e085e30f
commit 4fb8b85c13
22 changed files with 161 additions and 47 deletions
@@ -5,6 +5,7 @@ import { DOMWrapper, enableAutoUnmount, flushPromises, mount, type VueWrapper }
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { useAccessPreviewStore } from '@/core/access/accessPreview'
import { useAuthStore } from '@/core/auth/auth'
import { ApiResponseError } from '@/shared/api/http'
import {
confirmWeightResult,
correctWeightResult,
@@ -482,7 +483,7 @@ describe('WeightOcrPanel confirmation behavior', () => {
})
it('keeps the edited draft available when confirmation fails', async () => {
vi.mocked(confirmWeightResult).mockRejectedValueOnce(new Error('version conflict'))
vi.mocked(confirmWeightResult).mockRejectedValueOnce(new ApiResponseError('数据版本已变化,请刷新后重试', 'A0409', 409))
const wrapper = mountPanel()
await flushPromises()
await openWeightDialog(wrapper)
@@ -493,7 +494,7 @@ describe('WeightOcrPanel confirmation behavior', () => {
await flushPromises()
expect((input.element as HTMLInputElement).value).toBe('286.125')
expect(wrapper.text()).toContain('version conflict')
expect(wrapper.text()).toContain('数据版本已变化,请刷新后重试')
expect(confirmWeightResult).toHaveBeenCalledTimes(1)
})
})