feat(short-drama-agent-front): 接入素材预览审核并完善创作流程
This commit is contained in:
1 parent
f8b0fbb8ca
commit
dc8bb17a23
66 files changed
+2864
-632
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NButton, NImage } from 'naive-ui'
|
||||
import { AppDialog } from '@/components/ui'
|
||||
import IdentityImageDialog from '@/features/subject-identity/components/IdentityImageDialog.vue'
|
||||
@@ -19,8 +20,21 @@ import { identityImageFixture } from '@/features/subject-identity/testing/fixtur
|
||||
import { formFixture } from '@/features/subject-images/testing/fixtures'
|
||||
import { selectControl } from '@/testing/naive'
|
||||
|
||||
/** 生成提交由测试替身接收,绝不调用真实模型。 */
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** 每次生成用例只返回无副作用的预览夹具。 */
|
||||
beforeEach(() =>
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const formId = String(url).match(/subject-forms\/([^/]+)/)?.[1] ?? 'form-db-1'
|
||||
return new Response(JSON.stringify({ data: imagePreviewFixture(formId) }))
|
||||
})
|
||||
)
|
||||
)
|
||||
afterEach(() => {
|
||||
submitGeneration.mockClear()
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
@@ -333,6 +347,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -352,13 +367,16 @@ describe('身份图与母版契约', () => {
|
||||
expect(button('确认生成身份图').disabled).toBe(true)
|
||||
input('#identity-image-prompt', ' 自定义身份提示词 ')
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#identity-image-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成身份图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
viewType: 'three-quarter',
|
||||
referenceImageId: 'identity-image-1',
|
||||
provider: 'qwen-image',
|
||||
@@ -373,6 +391,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -385,6 +404,8 @@ describe('身份图与母版契约', () => {
|
||||
})
|
||||
await flushPromises()
|
||||
input('#identity-reference', 'identity-image-1')
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#identity-image-cost')!.click()
|
||||
await flushPromises()
|
||||
await wrapper.setProps({ images: [] })
|
||||
@@ -398,6 +419,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -491,6 +513,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(CastingCandidateDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 'subject-1',
|
||||
subjectName: '林夏',
|
||||
@@ -529,12 +552,20 @@ describe('身份图与母版契约', () => {
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('不会复用当前身份母版')
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#casting-candidate-cost')!.click()
|
||||
await flushPromises()
|
||||
button('AI 生成角色候选图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
[{ provider: 'qwen-image', generationOptions: { size: '1536*2688' } }]
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '1536*2688' }
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user