feat(short-drama-agent-front): 完善镜头定位与项目配置

This commit is contained in:
GJ committed 2026-10-08 19:45:26 +08:00
1 parent 470b52e26d
commit 5b134207b8
66 files changed
+2042 -984

No files matched your search

+64 -8
View File
@@ -1,3 +1,4 @@
import { generationProfile } from '../../fixtures/generation'
import { defineComponent } from 'vue'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
@@ -22,6 +23,7 @@ afterEach(() => {
wrapper = undefined
document.body.innerHTML = ''
vi.unstubAllGlobals()
localStorage.clear()
for (const id of ['capability-test', 'new-project']) {
Object.assign(getOperation(id), { pending: false, error: '', notice: '', label: '' })
Object.assign(getProductionSession(id), { receipt: null, pipelineReceipt: null })
@@ -33,7 +35,12 @@ function stageFixture() {
return { total: 1, planned: 1, skipped: 0, upstreamResolvable: 0, manualBlocked: 0 }
}
/**
* 构造正式预检、202 任务句柄与后续数据库结果的模拟服务。
* @returns 测试上下文、响应数据和已提交请求
*/
function server() {
localStorage.clear()
const context = testProjectContext()
const form = formFixture('capability-test')
const readiness = {
@@ -75,6 +82,9 @@ function server() {
videoGenerationResult: { total: 1, created: 1, skipped: 0, inProgress: 0, blocked: 0, failed: 0 }
}
const plan = {
canStart: true,
canAutoRun: true,
providers: { image: 'qwen-image', video: 'seedance' },
projectId: 'capability-test',
completed: false,
stage: 'subject_images',
@@ -114,7 +124,26 @@ function server() {
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
const path = String(url)
let data: unknown = context.project.value
if (path.endsWith('/checkpoints')) data = context.checkpoints.value
if (path.endsWith('/creative-profile')) data = generationProfile('capability-test')
else if (path.includes('/workflow-executions/'))
data = {
id: 'capability-execution-1',
projectId: 'capability-test',
workflowName: 'production',
status: 'completed',
stage: 'finalize',
current: 1,
total: 1,
currentResourceId: null,
metadata: null,
result: receipt,
error: null,
startedAt: '2026-10-08T00:00:00Z',
completedAt: '2026-10-08T00:00:01Z',
createdAt: '2026-10-08T00:00:00Z',
updatedAt: '2026-10-08T00:00:01Z'
}
else if (path.endsWith('/checkpoints')) data = context.checkpoints.value
else if (path.endsWith('/subject-forms')) data = [form]
else if (path.endsWith('/production/plan')) data = plan
else if (path.endsWith('/production/status')) data = status
@@ -134,7 +163,7 @@ function server() {
}
else if (init?.method === 'POST')
data = path.endsWith('/production/start')
? receipt
? { executionId: 'capability-execution-1', status: 'pending' }
: { total: 1, targetCount: 1, generated: 1, skipped: 0, blocked: 0, failed: 0, failures: [] }
return new Response(JSON.stringify({ data }))
})
@@ -154,6 +183,10 @@ function server() {
}
}
/**
* 挂载实际生产组合函数并等待只读绑定。
* @returns 测试数据和实际生产服务
*/
async function advanced() {
const data = server()
let service!: ReturnType<typeof useAdvancedProduction>
@@ -171,7 +204,7 @@ async function advanced() {
}
describe('高级串联生产的安全边界', () => {
it('挂载不查询或生成,通过预检仍需显式启动,再次预检后提交空参数', async () => {
it('挂载不查询或生成,通过预检仍需显式启动,再次预检后提交安全范围与项目模型参数', async () => {
const { service, fetcher, posts } = await advanced()
expect(fetcher).not.toHaveBeenCalled()
await service.start()
@@ -180,9 +213,19 @@ describe('高级串联生产的安全边界', () => {
expect(service.check.value?.issues).toEqual([])
expect(posts()).toHaveLength(0)
await service.start()
await flushPromises()
expect(posts()).toHaveLength(1)
expect(posts()[0]?.[0]).toBe('/api/projects/capability-test/production/start')
expect(JSON.parse(String(posts()[0]?.[1]?.body))).toEqual({})
expect(JSON.parse(String(posts()[0]?.[1]?.body))).toEqual({
stopAfter: 'videoPrompts',
stableIdentityAnchorLimit: 1,
subjectImageLimit: 1,
keyframeLimit: 1,
videoPromptLimit: 1,
imageProvider: 'qwen-image',
videoProvider: 'seedance',
imageGenerationOptions: { size: '2048*2048' }
})
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/production/plan'))).toHaveLength(2)
expect(service.session.value.pipelineReceipt?.errors).toEqual(['一个提示词未生成'])
expect(service.check.value).toBeNull()
@@ -248,7 +291,7 @@ describe('高级串联生产的安全边界', () => {
await flushPromises()
expect(service.check.value).toBeNull()
})
it('已提交的长请求只写回原项目的回执,不污染新项目', async () => {
it('迟到启动响应只保存原项目句柄,返回原项目后读取真实回执', async () => {
const { service, context, fetcher, receipt } = await advanced()
await service.preflight()
const original = fetcher.getMockImplementation()!
@@ -264,18 +307,31 @@ describe('高级串联生产的安全边界', () => {
await flushPromises()
context.data.value!.project.id = 'new-project'
await flushPromises()
finish(new Response(JSON.stringify({ data: receipt })))
finish(
new Response(JSON.stringify({ data: { executionId: 'capability-execution-1', status: 'pending' } }), {
status: 202
})
)
await pending
expect(service.session.value.pipelineReceipt).toBeNull()
expect(getProductionSession('capability-test').pipelineReceipt?.projectId).toBe('capability-test')
expect(getProductionSession('capability-test').pipelineReceipt).toBeNull()
expect(localStorage.getItem('short-drama:workflow-execution:capability-test:production')).toBe(
'capability-execution-1'
)
expect(localStorage.getItem('short-drama:workflow-execution:new-project:production')).toBeNull()
context.data.value!.project.id = 'capability-test'
await flushPromises()
expect(getProductionSession('capability-test').pipelineReceipt?.projectId).toBe(receipt.projectId)
})
it('回执项目不匹配时不发布成功回执', async () => {
const { service, receipt } = await advanced()
await service.preflight()
receipt.projectId = 'wrong'
await service.start()
await flushPromises()
expect(service.execution.query.data.value?.status).toBe('completed')
expect(service.execution.query.data.value?.result?.projectId).toBe('wrong')
expect(service.session.value.pipelineReceipt).toBeNull()
expect(getOperation('capability-test').error).toContain('回执项目不匹配')
})
it('界面区分流程返回与视频完成,显示部分错误,启动需要费用确认', async () => {
const { context, receipt, posts } = server()
+45 -15
View File
@@ -1,10 +1,16 @@
import { generationProfile, imageCatalog } from '../../fixtures/generation'
import { flushPromises, mount } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
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, sessionKeyframePassed, 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'
@@ -64,7 +70,13 @@ describe('精简公开资产回归', () => {
async url =>
new Response(
JSON.stringify({
data: String(url).endsWith('/videos') ? [video] : []
data: String(url).endsWith('/generation-models')
? imageCatalog
: String(url).endsWith('/creative-profile')
? generationProfile(projectId)
: String(url).endsWith('/videos')
? [video]
: []
})
)
)
@@ -100,7 +112,13 @@ describe('精简公开资产回归', () => {
async url =>
new Response(
JSON.stringify({
data: String(url).endsWith('/keyframes') ? [variant] : []
data: String(url).endsWith('/generation-models')
? imageCatalog
: String(url).endsWith('/creative-profile')
? generationProfile('public-variant-contract')
: String(url).endsWith('/keyframes')
? [variant]
: []
})
)
)
@@ -110,7 +128,10 @@ describe('精简公开资产回归', () => {
})
try {
await flushPromises()
await wrapper.findAll('button').find(item => item.text().includes('管理候选'))!.trigger('click')
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)
@@ -129,7 +150,13 @@ describe('精简公开资产回归', () => {
async url =>
new Response(
JSON.stringify({
data: String(url).endsWith('/keyframes') ? [primary, candidate] : []
data: String(url).endsWith('/generation-models')
? imageCatalog
: String(url).endsWith('/creative-profile')
? generationProfile(projectId)
: String(url).endsWith('/keyframes')
? [primary, candidate]
: []
})
)
)
@@ -144,12 +171,15 @@ describe('精简公开资产回归', () => {
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 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
)
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: '' })
@@ -172,16 +202,16 @@ describe('精简公开资产回归', () => {
}
await flushPromises()
expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(false)
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).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
)
expect(
[...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))
).toBe(true)
} finally {
wrapper.unmount()
}