feat(short-drama-agent-front): 补齐后端生产与质量功能
This commit is contained in:
1 parent
967c4ebea1
commit
470b52e26d
52 files changed
+3754
-1075
No files matched your search
@@ -5,6 +5,7 @@ import { NCheckbox, NInputNumber, NRadioGroup } from 'naive-ui'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { productionApi } from '@/features/production/api'
|
||||
import { qualityApi } from '@/features/production/quality-api'
|
||||
import { generationConfigApi } from '@/features/generation-config/api'
|
||||
import {
|
||||
allowedTextLines,
|
||||
qualityKey,
|
||||
@@ -108,12 +109,16 @@ function server() {
|
||||
missingReference: 0,
|
||||
results: [{ shotId: 'shot-1', success: true, status: 'passed' as const }]
|
||||
}
|
||||
const executionState = { status: 'completed' as 'running' | 'completed' | 'failed' }
|
||||
let batchMetadata: QualityInput | null = null
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, options) => {
|
||||
const path = String(url)
|
||||
let data: unknown
|
||||
if (options?.method === 'POST') {
|
||||
if (path.endsWith('/generate-quality')) data = batch
|
||||
else if (path.includes('/videos/') && path.endsWith('/repair'))
|
||||
if (path.endsWith('/generate-quality')) {
|
||||
batchMetadata = JSON.parse(String(options.body)) as QualityInput
|
||||
data = { executionId: `exec-${projectId}`, projectId, status: 'running', total: 1 }
|
||||
} else if (path.includes('/videos/') && path.endsWith('/repair'))
|
||||
data = {
|
||||
shotId: 'shot-1',
|
||||
sourceVideoId: 'video-1',
|
||||
@@ -142,6 +147,19 @@ function server() {
|
||||
}
|
||||
else data = keyframeResult
|
||||
} else if (path.endsWith(`/projects/${projectId}`)) data = project
|
||||
else if (path.includes('/workflow-executions/'))
|
||||
data = {
|
||||
id: `exec-${projectId}`,
|
||||
projectId,
|
||||
workflowName: 'keyframe-quality',
|
||||
status: executionState.status,
|
||||
stage: 'keyframe_quality',
|
||||
current: 1,
|
||||
total: 1,
|
||||
metadata: batchMetadata,
|
||||
result: batch,
|
||||
error: null
|
||||
}
|
||||
else if (path.endsWith('/checkpoints')) data = []
|
||||
else if (path.includes('/readiness')) data = readiness
|
||||
else if (path.endsWith('/keyframes')) data = [keyframe]
|
||||
@@ -170,6 +188,7 @@ function server() {
|
||||
keyframeResult,
|
||||
repair,
|
||||
batch,
|
||||
executionState,
|
||||
fetcher,
|
||||
posts: () => fetcher.mock.calls.filter(([, options]) => options?.method === 'POST')
|
||||
}
|
||||
@@ -301,13 +320,54 @@ describe('视觉质量契约与付费边界', () => {
|
||||
expect(wrapper.emitted('locate')).toEqual([['shot-1']])
|
||||
})
|
||||
|
||||
it('过期优先级与后端一致,当前集无过期项时不误补其他镜头', async () => {
|
||||
it('后台开始不显示最终通过,关闭切目标后完成仍归原镜头且刷新能恢复', async () => {
|
||||
const original: QualityTarget = { kind: 'batch', episodeNo: 1, shotId: 'shot-1', title: '原镜头' }
|
||||
const data = setup(original)
|
||||
data.executionState.status = 'running'
|
||||
await data.service.run('batch', input({ shotId: 'shot-1', limit: 1 }))
|
||||
expect(data.service.session.value.receipt).toBeNull()
|
||||
expect(data.service.blocked.value).toBe(true)
|
||||
const postCount = data.posts().length
|
||||
await data.service.run('batch', input({ shotId: 'shot-1' }))
|
||||
expect(data.posts()).toHaveLength(postCount)
|
||||
data.visible.value = false
|
||||
data.props.target = { kind: 'batch', episodeNo: 2, title: '其他集' }
|
||||
await flushPromises()
|
||||
data.executionState.status = 'completed'
|
||||
await data.service.execution.query.refresh()
|
||||
await flushPromises()
|
||||
expect(data.service.session.value.receipt).toBeNull()
|
||||
expect(qualitySession(qualityKey(data.projectId, original)).receipt).toMatchObject({
|
||||
kind: 'batch',
|
||||
result: { passed: 1 }
|
||||
})
|
||||
wrapper!.unmount()
|
||||
let restored!: ReturnType<typeof useQuality>
|
||||
wrapper = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
restored = useQuality(
|
||||
data.props,
|
||||
() => false,
|
||||
() => {}
|
||||
)
|
||||
return () => null
|
||||
}
|
||||
})
|
||||
)
|
||||
await flushPromises()
|
||||
expect(restored.execution.executionId.value).toBe(`exec-${data.projectId}`)
|
||||
expect(restored.execution.query.data.value?.status).toBe('completed')
|
||||
expect(data.posts()).toHaveLength(postCount)
|
||||
})
|
||||
|
||||
it('按真实后端 ready 列表处理本集缺失与过期项', async () => {
|
||||
const data = setup({ kind: 'batch', episodeNo: 1, title: '第一集' })
|
||||
data.readiness.stalePrimaryKeyframe = 1
|
||||
expect(qualityTargets(data.readiness, input())).toHaveLength(0)
|
||||
expect(qualityTargets(data.readiness, input())).toHaveLength(1)
|
||||
await data.service.run('batch', input())
|
||||
expect(data.posts()).toHaveLength(0)
|
||||
expect(data.service.session.value.error).toContain('切换剧集')
|
||||
expect(data.posts()).toHaveLength(1)
|
||||
expect(data.service.session.value.error).toBe('')
|
||||
expect(qualityTargets(data.readiness, input({ force: true }))).toHaveLength(1)
|
||||
})
|
||||
|
||||
@@ -401,6 +461,37 @@ describe('质量面板渐进展示', () => {
|
||||
|
||||
it('批量默认当前集一镜,调整次数撤销费用确认', async () => {
|
||||
const data = server()
|
||||
// 明确的项目配置与启用模型;不能依靠缺失配置进入付费确认。
|
||||
vi.spyOn(generationConfigApi, 'catalog').mockResolvedValue({
|
||||
defaults: { imageProvider: 'qwen-image', videoProvider: 'wan' },
|
||||
images: [
|
||||
{
|
||||
type: 'image',
|
||||
provider: 'qwen-image',
|
||||
providerLabel: 'Qwen',
|
||||
model: 'qwen-model',
|
||||
modelLabel: 'Qwen Model',
|
||||
supported: true,
|
||||
enabled: true,
|
||||
isDefault: true,
|
||||
capabilities: {},
|
||||
generationOptions: [],
|
||||
defaults: {},
|
||||
projectConstraints: []
|
||||
}
|
||||
],
|
||||
videos: []
|
||||
})
|
||||
vi.spyOn(generationConfigApi, 'profile').mockResolvedValue({
|
||||
projectId: data.projectId,
|
||||
aspectRatio: '9:16',
|
||||
imageProvider: 'qwen-image',
|
||||
imageModel: 'qwen-model',
|
||||
imageOptions: {},
|
||||
videoProvider: 'wan',
|
||||
videoModel: 'wan-model',
|
||||
videoOptions: {}
|
||||
})
|
||||
wrapper = mount(QualityDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
|
||||
Reference in new issue
Block a user