feat(short-drama-agent-front): 支持母版复用并优化生成交互
This commit is contained in:
1 parent
49fb9c7a27
commit
ee5e49957a
28 files changed
+634
-326
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { identityImageFixture } from '@/features/subject-identity/testing/fixtures'
|
||||
import { subjectIdentityApi } from '@/features/subject-identity/api'
|
||||
|
||||
/** 每个契约用例完成后清理网络替身。 */
|
||||
@@ -6,6 +7,22 @@ afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
/** 验证正式身份路由和付费请求没有自动重试。 */
|
||||
describe('身份正式接口契约', () => {
|
||||
it('普通生图保留任务编号和嵌套图片,选角仍使用独立图片回执', async () => {
|
||||
const image = identityImageFixture({ status: 'generating', imageUrl: null, isAnchor: false })
|
||||
const started = { executionId: 'execution-1', image }
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: started }), { status: 202 }))
|
||||
.mockResolvedValueOnce(new Response(JSON.stringify({ data: image }), { status: 202 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const result = await subjectIdentityApi.generateImage('subject-1', { viewType: 'primary' })
|
||||
expect(result.executionId).toBe('execution-1')
|
||||
expect(result.image.identityId).toBe(image.identityId)
|
||||
expect(result.image.status).toBe('generating')
|
||||
expect(await subjectIdentityApi.generateCastingCandidate('subject-1', {})).toEqual(image)
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('预览与实际生成传递相同参数,并支持取消预览', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
|
||||
@@ -113,7 +113,7 @@ describe('身份图与母版契约', () => {
|
||||
expect(wrapper.emitted('regenerate')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('候选未确认时不填补母版空状态,无图片时不提供管理入口', async () => {
|
||||
it('单张候选直接显示且保持未确认,无图片时不提供管理入口', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -124,14 +124,13 @@ describe('身份图与母版契约', () => {
|
||||
images: [identityImageFixture({ id: 'candidate', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
expect(wrapper.text()).toContain('尚未确认身份母版')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('母版候选 · 未确认')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(true)
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
expect(document.querySelector('[aria-label="身份图片 candidate"]')).not.toBeNull()
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
await wrapper.setProps({ images: [] })
|
||||
expect(wrapper.text()).toContain('尚无身份母版')
|
||||
expect(wrapper.text()).toContain('尚无身份图片')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
})
|
||||
@@ -225,7 +224,7 @@ describe('身份图与母版契约', () => {
|
||||
]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[aria-label="身份图片 failed-front"]')!.textContent).not.toContain(
|
||||
'图片模型超时'
|
||||
@@ -363,7 +362,7 @@ describe('身份图与母版契约', () => {
|
||||
viewType: 'three-quarter',
|
||||
referenceImageId: 'identity-image-1',
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' },
|
||||
generationOptions: { size: '2048*2048', promptExtendMode: 'direct' },
|
||||
prompt: '自定义身份提示词'
|
||||
}
|
||||
]
|
||||
@@ -391,7 +390,7 @@ describe('身份图与母版契约', () => {
|
||||
await wrapper.setProps({ images: [] })
|
||||
expect(button('确认生成身份图').disabled).toBe(true)
|
||||
await wrapper.setProps({ subjectId: 's2', subjectName: '陆川' })
|
||||
expect(selectControl(wrapper!, 'id', 'identity-reference').props('value')).toBe('')
|
||||
expect(document.querySelector('#identity-reference')).toBeNull()
|
||||
expect(document.querySelector('#identity-image-cost')!.getAttribute('aria-checked')).toBe('false')
|
||||
})
|
||||
|
||||
@@ -426,7 +425,7 @@ describe('身份图与母版契约', () => {
|
||||
images: [identityImageFixture({ viewType: 'front', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
await flushPromises()
|
||||
const card = wrapper.findAllComponents(IdentityImageCard)[0]!
|
||||
expect(card.findAllComponents(NButton).some(item => item.text() === '确认选角并锁定')).toBe(false)
|
||||
@@ -464,7 +463,7 @@ describe('身份图与母版契约', () => {
|
||||
images: ['first', 'second'].map(id => identityImageFixture({ id, isAnchor: false }))
|
||||
}
|
||||
})
|
||||
button('管理候选(2)').click()
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
const cards = wrapper.findAllComponents(IdentityImageCard)
|
||||
const first = cards.find(item => item.props('image').id === 'first')!
|
||||
|
||||
Reference in new issue
Block a user