feat(short-drama-agent-front): 补齐后端生产与质量功能
This commit is contained in:
1 parent
967c4ebea1
commit
470b52e26d
52 files changed
+3754
-1075
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { subjectIdentityApi } from '@/features/subject-identity/api'
|
||||
|
||||
/** 每个契约用例完成后清理网络替身。 */
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
/** 验证正式身份路由和付费请求没有自动重试。 */
|
||||
describe('身份正式接口契约', () => {
|
||||
it('预览与实际生成传递相同参数,并支持取消预览', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: {} }), { status: 200 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const input = {
|
||||
viewType: 'primary' as const,
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' },
|
||||
referenceImageId: 'image-1',
|
||||
prompt: '真实完整提示词'
|
||||
}
|
||||
await subjectIdentityApi.previewImage('subject-1', input, new AbortController().signal)
|
||||
await subjectIdentityApi.generateImage('subject-1', input)
|
||||
expect(fetcher.mock.calls[0]?.[0]).toContain('/subjects/subject-1/identity/images/preview')
|
||||
expect(fetcher.mock.calls[0]?.[1]?.body).toBe(JSON.stringify(input))
|
||||
expect(fetcher.mock.calls[1]?.[1]?.body).toBe(fetcher.mock.calls[0]?.[1]?.body)
|
||||
})
|
||||
it('校验指定正式图片,质量生成保留有限修复次数和模型参数', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: {} }), { status: 200 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await subjectIdentityApi.validateImage('subject-1', 'image-1')
|
||||
const input = { maxRepairAttempts: 1, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }
|
||||
await subjectIdentityApi.generateStableAnchorQuality('subject-1', input)
|
||||
expect(fetcher.mock.calls[0]?.[0]).toContain('/subjects/subject-1/identity/images/image-1/validate')
|
||||
expect(fetcher.mock.calls[1]?.[0]).toContain('/subjects/subject-1/identity/stable-anchor/generate-quality')
|
||||
expect(fetcher.mock.calls[1]?.[1]?.body).toBe(JSON.stringify(input))
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user