feat(short-drama-agent-front): 支持母版复用并优化生成交互

This commit is contained in:
GJ committed 2026-10-12 15:22:03 +08:00
1 parent 49fb9c7a27
commit ee5e49957a
28 files changed
+634 -326

No files matched your search

@@ -428,7 +428,7 @@ describe('拆解页内容滚动', () => {
expect(fetcher).not.toHaveBeenCalled()
})
it('关闭设置时错误仍可见,详细校验与恢复在面板内,不挤占结果高度', async () => {
it('关闭设置时保留问题入口,详细校验与恢复在面板内,不挤占结果高度', async () => {
const record = checkpoint()
record.state.workflowExecution!.status = 'failed'
record.state.workflowExecution!.errorMessage = '工作流中断'
@@ -437,11 +437,10 @@ describe('拆解页内容滚动', () => {
issues: [{ episodeNo: 1, message: '缺少形态绑定' }]
}
mountPage([record])
const feedback = wrapper!.get('.workspace-feedback')
expect(feedback.text()).toContain('工作流中断')
expect(feedback.text()).toContain('分镜校验未通过,共 1 项问题')
expect(feedback.find('.breakdown-results-section').exists()).toBe(false)
await feedback.get('button').trigger('click')
expect(wrapper!.find('.workspace-feedback').exists()).toBe(false)
expect(wrapper!.text()).not.toContain('缺少形态绑定')
const action = wrapper!.findAll('button').find(item => item.text() === '查看拆解问题')!
await action.trigger('click')
await flushPromises()
expect(drawerPanel().text()).toContain('缺少形态绑定')
expect(drawerPanel().text()).toContain('重试失败抽取')
@@ -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')!
@@ -203,7 +203,7 @@ describe('过期首帧到具体素材定位', () => {
})
const card = wrapper!.findAll('.form-image-card').find(item => item.attributes('data-form-id') === first.id)!
expect(card.get('.asset-image').classes()).not.toContain('form-image-has-source')
expect(card.get('.asset-image-empty').text()).toContain('尚未生成主参考图')
expect(card.get('.asset-image-empty').text()).toContain('确认并锁定身份母版后自动复用')
expect(card.find('img').exists()).toBe(false)
})
+10 -17
View File
@@ -350,7 +350,7 @@ describe('视觉风格与主体身份工作区', () => {
)
})
it('生成进度保留全栏提示,失败详情按需在浮层显示,切换后不串主体状态', async () => {
it('生成进度只在图库显示,失败详情按需查看,切换后不串主体状态', async () => {
/** 两个主体分别处于生成中与失败状态,所有查询均使用隔离的测试响应。 */
const first = formFixture()
const second = { ...formFixture(), id: 'second-form', subjectId: 'second-subject', images: [] }
@@ -385,14 +385,10 @@ describe('视觉风格与主体身份工作区', () => {
)
)
await mountAssets('identity')
const feedback = wrapper!.get('.identity-generation-feedback')
const workspace = wrapper!.get('.identity-workspace')
expect(feedback.element.closest('.identity-workspace-region')).toBe(
wrapper!.get('.identity-workspace-region').element
)
expect(feedback.element.closest('.identity-detail')).toBeNull()
expect(feedback.element.compareDocumentPosition(workspace.element) & 4).toBe(4)
expect(feedback.text()).toContain('林知夏 的身份图片正在生成')
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
const feedback = wrapper!.get('.identity-gallery [role="status"]')
expect(feedback.text()).toContain('正在生成中')
expect(feedback.element.closest('.identity-detail')).not.toBeNull()
await wrapper!
.findAll('.identity-subject-item')
.find(item => item.text().includes('第二个主体'))!
@@ -400,9 +396,8 @@ describe('视觉风格与主体身份工作区', () => {
await flushPromises()
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
expect(wrapper!.find('.identity-image-failure').exists()).toBe(false)
button('管理候选(1)').click()
await flushPromises()
expect(document.querySelector('.identity-candidate-grid')?.textContent).not.toContain('模型暂时不可用')
expect(wrapper!.get('.identity-gallery').text()).not.toContain('模型暂时不可用')
expect(wrapper!.get('.identity-gallery').find('[role="status"]').exists()).toBe(false)
expect(document.querySelector('.identity-image-failure')).toBeNull()
button('生成失败,查看失败原因').click()
await flushPromises()
@@ -475,7 +470,7 @@ describe('视觉风格与主体身份工作区', () => {
button('刷新身份').click()
await flushPromises()
expect(wrapper!.get<HTMLInputElement>('#identity-description').element.value).toBe('')
expect(wrapper!.text()).toContain('尚无身份母版')
expect(wrapper!.text()).toContain('尚无身份图片')
})
it('已有身份刷新保留草稿与图库,图片操作归属图库并遵守未保存限制', async () => {
@@ -1079,8 +1074,7 @@ describe('视觉风格与主体身份工作区', () => {
})
stubFetch(fetcher)
await mountAssets('identity')
button('管理候选(1)').click()
await flushPromises()
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
button('设为身份母版').click()
await flushPromises()
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'PUT')).toBe(false)
@@ -1211,8 +1205,7 @@ describe('视觉风格与主体身份工作区', () => {
stubFetch(fetcher)
await mountAssets('identity')
expect(wrapper!.text()).toContain('等待确认演员')
button('管理候选并确认').click()
await flushPromises()
expect(wrapper!.find('.identity-anchor-grid').exists()).toBe(true)
button('确认选角并锁定').click()
await flushPromises()
button('确认演员选择').click()