feat: 按质量结果管理主首帧候选

This commit is contained in:
GouJ committed 2026-09-23 11:35:53 +08:00
1 parent a72d96506a
commit 4298438219
6 files changed
+243 -88

No files matched your search

+6 -5
View File
@@ -136,10 +136,10 @@ describe('镜头生产数据契约', () => {
})
})
it('首个首帧默认设主图,已有主图时默认只新增候选,并要求费用确认', async () => {
it('所有首帧生成都先成为候选,并要求费用确认', async () => {
wrapper = mount(KeyframeDialog, {
attachTo: document.body,
props: { open: true, shotId: 'shot-1', shotTitle: '开场', keyframes: [], disabled: false }
props: { open: true, shotId: 'shot-1', shotTitle: '开场', disabled: false }
})
await flushPromises()
expect(button('确认生成首帧').disabled).toBe(true)
@@ -147,12 +147,13 @@ describe('镜头生产数据契约', () => {
await flushPromises()
button('确认生成首帧').click()
await flushPromises()
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: true }]])
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: false }]])
await wrapper.setProps({ open: false })
await flushPromises()
await wrapper.setProps({ open: true, shotId: 'shot-2', keyframes: [keyframeFixture({ shotId: 'shot-2' })] })
await wrapper.setProps({ open: true, shotId: 'shot-2', replacePrimary: true })
await flushPromises()
expect(document.body.textContent).toContain('生成替代候选')
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
await flushPromises()
button('确认生成首帧').click()
@@ -203,7 +204,7 @@ describe('镜头生产数据契约', () => {
vi.stubGlobal('fetch', fetcher)
wrapper = mount(KeyframeDialog, {
attachTo: document.body,
props: { open: true, shotId: 'shot-1', shotTitle: '开场', keyframes: [], disabled: false }
props: { open: true, shotId: 'shot-1', shotTitle: '开场', disabled: false }
})
await flushPromises()
button('预览实际生成输入').click()
@@ -4,7 +4,7 @@ import QualityResult from '@/features/production/components/QualityResult.vue'
import { expandSections } from '@/testing/naive'
import ShotProductionAssets from '@/features/production/components/ShotProductionAssets.vue'
import { primaryKeyframe } from '@/features/production/model'
import { qualityKey, qualitySession, sessionVideoValidation } from '@/features/production/quality'
import { qualityKey, qualitySession, sessionKeyframePassed, sessionVideoValidation } from '@/features/production/quality'
import { keyframeFixture, videoFixture } from '@/features/production/testing/fixtures'
import { storyboardApi } from '@/features/storyboard/api'
import { hasRunningWorkflow } from '@/features/workflows/selectors'
@@ -110,13 +110,83 @@ describe('精简公开资产回归', () => {
})
try {
await flushPromises()
expect(wrapper.text()).toContain('模型输入变体')
await wrapper.findAll('button').find(item => item.text().includes('管理候选'))!.trigger('click')
await flushPromises()
expect(document.body.textContent).toContain('模型输入变体')
expect(wrapper.findAll('button').some(button => button.text() === '设为主首帧')).toBe(false)
} finally {
wrapper.unmount()
}
})
it('主页面只展示主首帧,候选通过质量检查后才允许晋升', async () => {
const projectId = 'keyframe-promotion-contract'
const primary = keyframeFixture()
const candidate = keyframeFixture({ id: 'keyframe-2', isPrimary: false })
vi.stubGlobal(
'fetch',
vi.fn<typeof fetch>().mockImplementation(
async url =>
new Response(
JSON.stringify({
data: String(url).endsWith('/keyframes') ? [primary, candidate] : []
})
)
)
)
const wrapper = mount(ShotProductionAssets, {
attachTo: document.body,
props: { projectId, shot, disabled: false }
})
try {
await flushPromises()
expect(wrapper.findAll('.keyframe-card')).toHaveLength(1)
expect(wrapper.find('.primary-keyframe-mark').attributes('aria-label')).toBe('当前主首帧')
expect(wrapper.findAll('button').some(item => item.text().includes('设为主首帧'))).toBe(false)
await wrapper.findAll('button').find(item => item.text().includes('管理候选'))!.trigger('click')
await flushPromises()
expect(document.body.textContent).toContain('首帧候选管理')
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
false
)
const session = qualitySession(
qualityKey(projectId, { kind: 'keyframe', shotId: shot.shotId, assetId: candidate.id, title: '' })
)
session.receipt = {
kind: 'keyframe',
result: {
shotId: shot.shotId,
keyframeId: candidate.id,
validationTaskId: 'validation-2',
imageUrl: candidate.imageUrl!,
isPrimary: false,
passed: false,
summary: '人物身份不一致',
subjects: [],
subjectCountConsistent: true,
unauthorizedText: { detected: false, texts: [] },
issues: []
}
}
await flushPromises()
expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(false)
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
false
)
session.receipt.result.passed = true
await flushPromises()
expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(true)
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
true
)
} finally {
wrapper.unmount()
}
})
it('提示词返回使用 shotId,保留正文、状态和更新时间', async () => {
const result = {
shotId: 'shot/db',