feat(short-drama-agent-front): 接入素材预览审核并完善创作流程

This commit is contained in:
GJ committed 2026-11-02 10:16:10 +08:00
1 parent f8b0fbb8ca
commit dc8bb17a23
66 files changed
+2864 -632

No files matched your search

+27 -17
View File
@@ -1,3 +1,4 @@
import { imagePreviewFixture } from '../../fixtures/image-preview'
import { preparationFixture } from '../storyboard-preparation/fixtures'
import { generationProfile, imageCatalog } from '../../fixtures/generation'
import { routerLinkStubs } from '../../fixtures/router'
@@ -228,6 +229,7 @@ function context(): ReturnType<typeof useProjectData> {
projectId: fixture.id,
script: { ready: true, reason: null },
breakdown: { ready: true, reason: null },
preparation: { ready: true, reason: null },
visualStyle: { ready: true, reason: null },
identity: { ready: true, reason: null },
subjectAssets: { ready: true, reason: null },
@@ -452,8 +454,8 @@ describe('视觉风格与主体身份工作区', () => {
expect(openSettings).toHaveBeenCalledExactlyOnceWith('generation')
}
)
it('当前主体已确认但其它角色未完成时,隐藏形态入口;保存后按新阶段状态开放', async () => {
/** 当前主体已锁定,其它角色仍未确认,用真实项目准入规则约束页面入口。 */
it('其它角色未完成不阻断当前主体形态准备,刷新后来源失效仍锁定入口', async () => {
/** 已锁定主体可先准备自身素材;整体身份不齐不代替正式来源门禁。 */
const saved = identityFixture({ isLocked: true })
vi.spyOn(subjectIdentityApi, 'get').mockResolvedValue(saved)
vi.spyOn(subjectIdentityApi, 'save').mockImplementation(async (_id, input) => ({ ...saved, ...input }))
@@ -478,21 +480,21 @@ describe('视觉风格与主体身份工作区', () => {
const provided = await mountAssets('identity')
provided.data.value!.stageReadiness.identity = { ready: false, reason: '还有角色身份需要确认' }
await flushPromises()
expect(wrapper!.get('.identity-next-action').text()).toContain('还有角色身份需要确认')
expect(wrapper!.get('.identity-next-action').find('button').exists()).toBe(false)
expect(wrapper!.get('.identity-subject-forms').text()).not.toContain('查看此主体形态图片')
expect(wrapper!.find('a[href*="/subject-images"]').exists()).toBe(false)
expect(wrapper!.get('.identity-next-action').text()).toContain('可以继续生成此主体的形态图片')
expect(button('查看形态图片').disabled).toBe(false)
expect(wrapper!.get('.identity-subject-forms').text()).toContain('查看此主体形态图片')
expect(wrapper!.find('a[href*="/subject-images"]').exists()).toBe(true)
vi.mocked(provided.refreshStageReadiness).mockImplementation(async () => {
provided.data.value!.stageReadiness.identity = { ready: true, reason: null }
provided.data.value!.stageReadiness.preparation = { ready: false, reason: '正式分镜来源已变化' }
})
await wrapper!.get('#identity-description').setValue('保存后仍保留已确认母版')
button('保存主体身份').click()
await flushPromises()
expect(provided.refreshStageReadiness).toHaveBeenCalledOnce()
expect(button('查看形态图片').disabled).toBe(false)
expect(wrapper!.get('.identity-detail a[href*="/subject-images"]').attributes('href')).toContain(
'subjectRef=@CH0001'
)
expect(wrapper!.get('.identity-next-action').text()).toContain('正式分镜来源已变化')
expect(wrapper!.get('.identity-next-action').find('button').exists()).toBe(false)
expect(wrapper!.find('.identity-detail a[href*="/subject-images"]').exists()).toBe(false)
})
it('生成进度只在图库显示,失败详情按需查看,切换后不串主体状态', async () => {
@@ -690,7 +692,7 @@ describe('视觉风格与主体身份工作区', () => {
button('重试读取').click()
await flushPromises()
expect(wrapper!.find('#style-prompt').exists()).toBe(true)
expect(wrapper!.get('.visual-style-rules').text()).toContain('中国人物选角基线')
expect(wrapper!.get('.visual-style-rules').text()).toContain('未明确时保持地域与族裔中性')
expect(wrapper!.find('.n-collapse').exists()).toBe(false)
expect(wrapper!.findAll('.style-category-fields textarea')).toHaveLength(3)
})
@@ -973,7 +975,7 @@ describe('视觉风格与主体身份工作区', () => {
await mountAssets('style')
expect(wrapper!.text()).toContain('尚未创建')
await expandSections()
expect(wrapper!.text()).toContain('默认采用中国人物选角基线')
expect(wrapper!.text()).toContain('未明确时保持地域与族裔中性')
expect(wrapper!.text()).toContain('人物风格与选角背景')
await wrapper!.get('#style-constraints').setValue('真人写实')
await wrapper!.get('#style-lock').trigger('click')
@@ -1149,7 +1151,7 @@ describe('视觉风格与主体身份工作区', () => {
})
it.each([true, false])(
'身份图片校验按真实 passed=%s 反馈,等待时显示目标按钮加载,结果不驻留页面',
'身份图片校验按真实 passed=%s 反馈,等待时显示目标按钮加载,结果按图片展示',
async passed => {
/** 延迟校验回执以覆盖请求期间的真实按钮状态。 */
let finish!: (response: Response) => void
@@ -1177,6 +1179,8 @@ describe('视觉风格与主体身份工作区', () => {
subjectId: 'subject-db-1',
imageId: 'identity-image-1',
passed,
sourceRequirementsPassed: true,
sourceVisualRequirements: [],
summary: '本次视觉检查结果',
issues: []
})
@@ -1185,10 +1189,10 @@ describe('视觉风格与主体身份工作区', () => {
expect(getOperation(fixture.id)).toMatchObject({
pending: false,
noticeType: passed ? 'success' : 'warning',
notice: `林知夏 的身份图片校验${passed ? '通过' : '未通过'}:本次视觉检查结果`
notice: `林知夏 的身份图片校验${passed ? '通过' : '未通过或待复核'}:本次视觉检查结果`
})
expect(gallery.props('pendingOperation')).toBeNull()
expect(wrapper!.text()).not.toContain('本次视觉检查结果')
expect(wrapper!.text()).toContain('本次视觉检查结果')
}
)
@@ -1531,6 +1535,7 @@ describe('工作台页面交互', () => {
it('形态单图确认后发送正式 ID 并刷新候选图,不会调用 production/start', async () => {
const form = formFixture()
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) => {
if (String(_url).endsWith('/preview')) return jsonResponse(imagePreviewFixture())
if (init?.method === 'POST') {
const candidate = imageFixture({
id: 'new-candidate',
@@ -1547,14 +1552,19 @@ describe('工作台页面交互', () => {
await mountSubjectImages()
button('再生成一张').click()
await flushPromises()
button('预览实际生成输入').click()
await flushPromises()
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
await flushPromises()
button('确认生成图片').click()
await flushPromises()
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
const post = fetcher.mock.calls.find(
([url, init]) => init?.method === 'POST' && String(url).endsWith('/images')
)!
expect(post[0]).toBe('/api/subject-forms/form-db-1/images')
expect(JSON.parse(post[1]!.body as string)).toEqual({
setPrimary: false,
expectedPreviewFingerprint: 'a'.repeat(64),
provider: 'qwen-image',
generationOptions: { size: '2048*2048' }
})
@@ -1619,7 +1629,7 @@ describe('工作台页面交互', () => {
await flushPromises()
expect(document.body.textContent).toContain('数据库异常')
expect(wrapper!.find('.form-image-card img').exists()).toBe(true)
await new DOMWrapper(button('刷新图片').closest('.app-dialog')!).get('.n-card-header__close').trigger('click')
await new DOMWrapper(button('刷新图片').closest('.app-drawer')!).get('.n-drawer-header__close').trigger('click')
await flushPromises()
expect(button('补齐项目主参考图').disabled).toBe(true)
})