fix(short-drama-agent-front): 修复测试警告与请求模拟
This commit is contained in:
1 parent
46f54548c7
commit
a9370cdf50
8 files changed
+67
-18
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { generationProfile, imageCatalog } from '../../fixtures/generation'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { mediaAssetUrl } from '@/lib/assets'
|
||||
@@ -197,6 +198,15 @@ describe('镜头生产数据契约', () => {
|
||||
})
|
||||
|
||||
it('所有首帧生成都先成为候选,并要求费用确认', async () => {
|
||||
/** 弹窗打开时只读取模型目录和项目配置,测试不依赖真实后端。 */
|
||||
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}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, shotId: 'shot-1', shotTitle: '开场', projectId: 'project-1', disabled: false }
|
||||
@@ -208,7 +218,7 @@ describe('镜头生产数据契约', () => {
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
[{ provider: undefined, generationOptions: {}, setPrimary: false }]
|
||||
[{ provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }]
|
||||
])
|
||||
|
||||
await wrapper.setProps({ open: false })
|
||||
@@ -221,8 +231,10 @@ describe('镜头生产数据契约', () => {
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')?.at(-1)).toEqual([
|
||||
{ provider: undefined, generationOptions: {}, setPrimary: false }
|
||||
{ provider: 'qwen-image', generationOptions: { size: '2048*2048' }, setPrimary: false }
|
||||
])
|
||||
expect(fetcher).toHaveBeenCalledTimes(4)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
|
||||
|
||||
Reference in new issue
Block a user