feat(short-drama-agent-front): 完善视觉资产审核流程
This commit is contained in:
1 parent
dc8bb17a23
commit
b88ad8770f
45 files changed
+2258
-352
No files matched your search
@@ -197,44 +197,64 @@ describe('镜头生产数据契约', () => {
|
||||
expect(fetcher.mock.calls[1]?.[1]?.method).toBe('GET')
|
||||
})
|
||||
|
||||
it('所有首帧生成都先成为候选,并要求费用确认', async () => {
|
||||
/** 弹窗打开时只读取模型目录和项目配置,测试不依赖真实后端。 */
|
||||
it('首帧只提交用户核对过的版本,替换也先保存候选', async () => {
|
||||
const fingerprint = 'a'.repeat(64)
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
if (path === '/api/generation-models') return new Response(JSON.stringify({ data: imageCatalog }))
|
||||
if (path === '/api/projects/project-1/creative-profile')
|
||||
return new Response(JSON.stringify({ data: generationProfile('project-1') }))
|
||||
throw new Error(`首帧弹窗出现未预期请求:${path}`)
|
||||
const shotId = path.match(/storyboard-shots\/([^/]+)/)?.[1]
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId,
|
||||
previewFingerprint: fingerprint,
|
||||
provider: 'qwen-image',
|
||||
model: 'qwen-image-3.0-pro',
|
||||
providerPrompt: '完整首帧画面描述',
|
||||
generationConfig: {},
|
||||
referenceImages: []
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, shotId: 'shot-1', shotTitle: '开场', projectId: 'project-1', disabled: false }
|
||||
props: {
|
||||
open: true,
|
||||
shotId: 'shot-1',
|
||||
shotTitle: '开场',
|
||||
projectId: 'project-1',
|
||||
disabled: false,
|
||||
submitGeneration
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(button('确认生成首帧').disabled).toBe(true)
|
||||
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
[{ provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }]
|
||||
])
|
||||
|
||||
await wrapper.setProps({ open: false })
|
||||
await flushPromises()
|
||||
await wrapper.setProps({ open: true, shotId: 'shot-2', replacePrimary: true })
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('生成替代候选')
|
||||
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')?.at(-1)).toEqual([
|
||||
{ provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }
|
||||
])
|
||||
expect(fetcher).toHaveBeenCalledTimes(4)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
for (const shotId of ['shot-1', 'shot-2']) {
|
||||
if (shotId === 'shot-2') {
|
||||
await wrapper.setProps({ open: false })
|
||||
await wrapper.setProps({ open: true, shotId, replacePrimary: true })
|
||||
await flushPromises()
|
||||
}
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
expect(button('确认生成首帧').disabled).toBe(true)
|
||||
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
}
|
||||
expect(submitGeneration).toHaveBeenCalledTimes(2)
|
||||
expect(submitGeneration).toHaveBeenLastCalledWith({
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' },
|
||||
setPrimary: false,
|
||||
expectedPreviewFingerprint: fingerprint
|
||||
})
|
||||
})
|
||||
|
||||
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
|
||||
@@ -277,6 +297,8 @@ describe('镜头生产数据契约', () => {
|
||||
model: 'image-model',
|
||||
generationConfig: {},
|
||||
references: [],
|
||||
previewFingerprint: 'a'.repeat(64),
|
||||
referenceImages: ['/storage/preview.png'],
|
||||
referencePlan: {
|
||||
provider: 'seedream',
|
||||
maxReferenceImages: 4,
|
||||
@@ -307,7 +329,14 @@ describe('镜头生产数据契约', () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, shotId: 'shot-1', shotTitle: '开场', projectId: 'project-1', disabled: false }
|
||||
props: {
|
||||
open: true,
|
||||
shotId: 'shot-1',
|
||||
shotTitle: '开场',
|
||||
projectId: 'project-1',
|
||||
disabled: false,
|
||||
submitGeneration: vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
@@ -318,8 +347,8 @@ describe('镜头生产数据契约', () => {
|
||||
provider: 'seedream',
|
||||
generationOptions: {}
|
||||
})
|
||||
expect(document.body.textContent).toContain('已选 1 / 2 张')
|
||||
expect(document.body.textContent).toContain('省略 1 张')
|
||||
expect(document.body.textContent).toContain('1 张参考图')
|
||||
expect(document.body.textContent).toContain('未进入模型的参考图')
|
||||
expect(document.body.textContent).toContain('最终首帧 Prompt')
|
||||
expect(wrapper.emitted('generate')).toBeUndefined()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user