fix(short-drama-agent-front): 修复图片重复提交与首帧恢复
This commit is contained in:
1 parent
b88ad8770f
commit
ecb0423153
8 files changed
+508
-85
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { validationPreviewResponse } from '../../fixtures/image-preview'
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import ImageGalleryDialog from '@/features/subject-images/components/ImageGalleryDialog.vue'
|
||||
import { getOperation } from '@/features/workflows/operations'
|
||||
@@ -97,6 +98,65 @@ describe('候选质量与主图门禁', () => {
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it.each([504, 409])('审核回执 %s 后锁定同一候选的付费操作,重开图库仍保持锁定', async status => {
|
||||
const image = imageFixture({ id: 'unknown-review-' + status, isPrimary: false, qualityPassed: true })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (String(url).endsWith('/validate/preview')) return validationPreviewResponse(String(url))
|
||||
if (init?.method === 'POST') return new Response(JSON.stringify({ message: '审核结果待核对' }), { status })
|
||||
return Response.json({ data: [image] })
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const props = { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
/** 正式父页在项目请求进行中会同步禁用图库写入。 */
|
||||
const parent = defineComponent({
|
||||
setup: () => () => h(ImageGalleryDialog, { ...props, disabled: getOperation(props.projectId).pending })
|
||||
})
|
||||
wrapper = mount(parent, { attachTo: document.body })
|
||||
await flushPromises()
|
||||
button('审核此图片').click()
|
||||
await flushPromises()
|
||||
button('确认费用并审核').click()
|
||||
await flushPromises()
|
||||
wrapper.unmount()
|
||||
wrapper = mount(parent, { attachTo: document.body })
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('费用待核对')
|
||||
expect(button('审核此图片').disabled).toBe(true)
|
||||
expect(button('审核与修复').disabled).toBe(true)
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
button('刷新图片').click()
|
||||
await flushPromises()
|
||||
expect(button('审核此图片').disabled).toBe(true)
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
|
||||
})
|
||||
|
||||
it.each(['刷新图片', '确认费用并审核'])('同一候选来源变化后,%s 重新预检并阻止付费请求', async action => {
|
||||
let current = true
|
||||
const image = imageFixture({ id: 'stale-after-open', isPrimary: false, qualityPassed: true })
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async url =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url), current)
|
||||
: Response.json({ data: [image] })
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(button('审核此图片').disabled).toBe(false)
|
||||
button('审核此图片').click()
|
||||
await flushPromises()
|
||||
current = false
|
||||
button(action).click()
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('本次机位采用的几何已过期')
|
||||
expect(button('审核此图片').disabled).toBe(true)
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('主图晋升 409 保留原主图,不乐观切换或自动重试', async () => {
|
||||
const original = imageFixture({ id: 'old' })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) =>
|
||||
|
||||
Reference in new issue
Block a user