feat(short-drama-agent-front): 接入分阶段镜头生产与摄影修订
This commit is contained in:
1 parent
1e9ef33d1d
commit
87427d9d43
29 files changed
+2787
-136
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>分阶段生产 · 隔离验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./staged-production.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,299 @@
|
||||
import { createApp, computed, defineComponent, h, provide, ref } from 'vue'
|
||||
import { NButton, NConfigProvider, NGlobalStyle, NMessageProvider, zhCN, dateZhCN } from 'naive-ui'
|
||||
import { useTheme } from '../../src/composables/useTheme'
|
||||
import ActionMessageProvider from '../../src/components/ui/ActionMessageProvider.vue'
|
||||
import StoryboardPage from '../../src/features/storyboard/StoryboardPage.vue'
|
||||
import { projectContextKey, useProjectData } from '../../src/features/projects/context'
|
||||
import {
|
||||
directionsResult,
|
||||
visualStatesResult,
|
||||
storyboardCheckpoint
|
||||
} from '../../src/features/storyboard/testing/fixtures'
|
||||
import { preparationFixture } from '../features/storyboard-preparation/fixtures'
|
||||
import type { WorkflowExecution } from '../../src/features/workflows/execution.types'
|
||||
import { billingCatalog, billingProfile } from '../fixtures/billing'
|
||||
import '../../src/styles/styles.css'
|
||||
import '../../src/styles/admin.css'
|
||||
|
||||
/** 隔离场景,任何请求都不会进入本地真实 API。 */
|
||||
const scenario = new URLSearchParams(location.search).get('scenario') ?? 'direction'
|
||||
/** 固定隔离身份以验证刷新恢复,和正式项目完全分开。 */
|
||||
const projectId = `staged-browser-${scenario}`
|
||||
/** 显式显示模拟写入次数,便于 Chrome 验证没有自动生产。 */
|
||||
const calls = ref<Array<{ path: string; method: string; body: unknown }>>([])
|
||||
/** 当前正式模拟摄影,保留并发版本与原文。 */
|
||||
let directions = directionsResult(projectId)
|
||||
for (const row of directions.beats.flatMap(beat => beat.shots))
|
||||
row.direction = {
|
||||
...row.direction!,
|
||||
id: 'original-' + row.shotId,
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
rawJson: '原摄影原文'
|
||||
}
|
||||
/** 尚无画面状态的镜头允许独立摄影修订。 */
|
||||
let visuals = visualStatesResult(projectId, 1, scenario === 'complete')
|
||||
/** 用于验证用户明确覆盖后的二次保护。 */
|
||||
let conflictNext = false
|
||||
/** 场景的正式质量确认。 */
|
||||
const approval = preparationFixture(projectId)
|
||||
/** 任务当前持久化投影,模拟停止后在途回执的保留。 */
|
||||
let task: WorkflowExecution = {
|
||||
id: 'mock-derived-task',
|
||||
projectId,
|
||||
workflowName: 'storyboard-direction',
|
||||
status: scenario === 'running' ? 'running' : 'completed',
|
||||
stage: scenario === 'running' ? 'storyboardDirection' : 'completed',
|
||||
current: 0,
|
||||
total: 2,
|
||||
currentResourceId: null,
|
||||
metadata: {
|
||||
derivedBatchVersion: 1,
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2'],
|
||||
claims: [{ state: 'submitted', episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] }]
|
||||
},
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: '2026-11-15T00:00:00Z',
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-15T00:00:00Z',
|
||||
updatedAt: '2026-11-15T00:00:00Z'
|
||||
}
|
||||
if (scenario === 'running') {
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem('staged-browser:task') ?? 'null')
|
||||
if (saved?.projectId === projectId) task = saved
|
||||
} catch {
|
||||
/* 隔离数据损坏不构造正式任务。 */
|
||||
}
|
||||
localStorage.setItem(`short-drama:workflow-execution:${projectId}:storyboard-direction`, task.id)
|
||||
}
|
||||
/**
|
||||
* 全量拦截当前页面请求,未知接口拒绝,不连接正式项目、模型或资产。
|
||||
* @param input 原接口地址
|
||||
* @param init 原请求方法与正文
|
||||
* @returns 与原正式路由同形状的隔离数据
|
||||
*/
|
||||
window.fetch = async (input, init) => {
|
||||
const path = String(input),
|
||||
method = init?.method ?? 'GET'
|
||||
const body = init?.body ? JSON.parse(String(init.body)) : undefined
|
||||
calls.value.push({ path, method, body })
|
||||
let data: unknown
|
||||
if (path.endsWith(`/projects/${projectId}`))
|
||||
data = {
|
||||
id: projectId,
|
||||
title: '隔离验收剧本',
|
||||
status: 'completed',
|
||||
episodes: [{ episode: 1, title: '来信', content: '隔离内容' }],
|
||||
characters: []
|
||||
}
|
||||
else if (path.endsWith('/stage-readiness'))
|
||||
data = {
|
||||
projectId,
|
||||
...Object.fromEntries(
|
||||
['script', 'breakdown', 'preparation', 'visualStyle', 'identity', 'subjectAssets', 'storyboard'].map(
|
||||
key => [key, { ready: true, reason: null }]
|
||||
)
|
||||
)
|
||||
}
|
||||
else if (path.includes('/checkpoints')) data = path.includes('view=summary') ? [] : [storyboardCheckpoint()]
|
||||
else if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
data = { ...approval.approval, valid: true, confirmation: approval.record }
|
||||
else if (path.endsWith('/storyboard-quality-confirmation/preflight'))
|
||||
data = {
|
||||
current: { ...approval.approval, valid: true, confirmation: approval.record },
|
||||
quality: approval.quality
|
||||
}
|
||||
else if (path.includes('/storyboard-directions?')) data = directions
|
||||
else if (path.includes('/storyboard-visual-states?')) data = visuals
|
||||
else if (path.endsWith('/storyboard/duration-audit')) data = { projectId, issues: [] }
|
||||
else if (path.endsWith('/duration-budget')) data = { projectId, episodes: [] }
|
||||
else if (path.endsWith('/production/entry-readiness'))
|
||||
data = {
|
||||
...approval.entry,
|
||||
derivedAssets: {
|
||||
...approval.entry.derivedAssets,
|
||||
shotCount: 2,
|
||||
directionCount: 2,
|
||||
visualStateCount: visuals.visualStateCount,
|
||||
staleDirectionCount: 0,
|
||||
staleVisualStateCount: 0
|
||||
}
|
||||
}
|
||||
else if (path.endsWith('/generation-models')) data = billingCatalog
|
||||
else if (path.endsWith('/creative-profile')) data = { ...billingProfile, projectId }
|
||||
else if (path.includes('/keyframe-review-draft')) data = null
|
||||
else if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
if (conflictNext && body.preview === false) {
|
||||
conflictNext = false
|
||||
return new Response(
|
||||
JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影已由另一审核人更新,请重新核对。' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
}
|
||||
if (!body.preview)
|
||||
directions.beats[0]!.shots[0]!.direction = {
|
||||
...directions.beats[0]!.shots[0]!.direction!,
|
||||
...body.shots[0].direction
|
||||
}
|
||||
data = {
|
||||
projectId,
|
||||
phase: 'direction',
|
||||
preview: body.preview,
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
changed: !body.preview,
|
||||
shots: [
|
||||
{
|
||||
shotId: body.shots[0].shotId,
|
||||
directionId: 'original-shot-db-1-1',
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
changed: !body.preview,
|
||||
alreadyApplied: false
|
||||
}
|
||||
]
|
||||
}
|
||||
} else if (
|
||||
path.endsWith('/storyboard-directions/generate') ||
|
||||
path.endsWith('/storyboard-visual-states/generate')
|
||||
) {
|
||||
const visual = path.includes('visual-states')
|
||||
if (visual) visuals = visualStatesResult(projectId, 1, true)
|
||||
else directions = directionsResult(projectId)
|
||||
task = {
|
||||
...task,
|
||||
id: 'mock-' + calls.value.length,
|
||||
workflowName: visual ? 'storyboard-visual-state' : 'storyboard-direction',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
metadata: { ...body, claims: [{ state: 'received' }] },
|
||||
result: {
|
||||
projectId,
|
||||
episodeCount: 1,
|
||||
completedEpisodes: 1,
|
||||
skippedEpisodes: 0,
|
||||
failedEpisodes: 0,
|
||||
episodes: [{ episodeNo: 1, status: 'completed' }]
|
||||
},
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
data = { executionId: task.id, projectId, status: 'running' }
|
||||
} else if (path.endsWith('/stop')) {
|
||||
task = {
|
||||
...task,
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true, retryAutomatically: false },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
setTimeout(() => {
|
||||
task = {
|
||||
...task,
|
||||
metadata: { ...task.metadata, claims: [{ state: 'received' }] },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
}, 1000)
|
||||
data = task
|
||||
} else if (path.includes('/workflow-executions/')) data = task
|
||||
else if (path.endsWith('/references')) data = { shotId: path.split('/').at(-2), references: [], missing: [] }
|
||||
else if (path.endsWith('/production/plan'))
|
||||
data = {
|
||||
projectId,
|
||||
configuration: { status: 'blocked', reason: '隔离项目尚未设置图片模型' },
|
||||
entryReadiness: { ready: false, reason: '仅所选镜头准备完成,项目未就绪' },
|
||||
stageReadiness: {
|
||||
referenceImages: { status: 'ready', reason: null },
|
||||
keyframes: { status: 'blocked', reason: '需要核对首帧预览' },
|
||||
videos: { status: 'blocked', reason: '尚无主视频' }
|
||||
},
|
||||
details: null
|
||||
}
|
||||
else if (path.endsWith('/production/status')) data = { projectId, completed: false }
|
||||
else return new Response(JSON.stringify({ message: '隔离页面拒绝未声明接口,不连接真实服务' }), { status: 403 })
|
||||
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } })
|
||||
}
|
||||
/** 整页复用原上下文及分镜组件,只增加隔离控制栏。 */
|
||||
const Workspace = defineComponent({
|
||||
setup() {
|
||||
const id = ref(projectId)
|
||||
const context = useProjectData(id)
|
||||
provide(projectContextKey, context)
|
||||
return () => h(StoryboardPage)
|
||||
}
|
||||
})
|
||||
/** 主题只用于当前隔离页渲染,不更改用户存储偏好。 */
|
||||
const Preview = defineComponent({
|
||||
setup() {
|
||||
const theme = useTheme()
|
||||
const writes = computed(
|
||||
() => calls.value.filter(call => call.method === 'POST' && /generate|confirm|stop/.test(call.path)).length
|
||||
)
|
||||
return () =>
|
||||
h(
|
||||
NConfigProvider,
|
||||
{ locale: zhCN, dateLocale: dateZhCN, theme: theme.theme.value, themeOverrides: theme.overrides.value },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
ActionMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () => [
|
||||
h(NGlobalStyle),
|
||||
h(
|
||||
'header',
|
||||
{
|
||||
style: 'height:70px;padding:12px;display:flex;gap:12px;flex-wrap:wrap;overflow:auto'
|
||||
},
|
||||
[
|
||||
...Object.entries({
|
||||
direction: '独立摄影',
|
||||
complete: '已有结果',
|
||||
running: '停止与刷新'
|
||||
}).map(([key, label]) =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
location.href = `?scenario=${key}`
|
||||
}
|
||||
},
|
||||
() => label
|
||||
)
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
conflictNext = true
|
||||
}
|
||||
},
|
||||
() => '模拟一次并发冲突'
|
||||
),
|
||||
h(
|
||||
'span',
|
||||
{ role: 'status' },
|
||||
`模拟写入 ${writes.value} 次 · 真实模型请求 0 次`
|
||||
)
|
||||
]
|
||||
),
|
||||
h('div', { style: 'height:calc(100dvh - 70px);min-height:0' }, [
|
||||
h(Workspace)
|
||||
])
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
createApp(Preview).mount('#app')
|
||||
@@ -1,3 +1,5 @@
|
||||
import { preparationApi } from '@/features/storyboard-preparation/api'
|
||||
import { preparationFixture } from '../storyboard-preparation/fixtures'
|
||||
import { h } from 'vue'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
@@ -36,6 +38,7 @@ function readiness(id: string, ready = true): ProjectStageReadiness {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(preparationApi, 'approval').mockImplementation(async id => preparationFixture(id).approval)
|
||||
vi.spyOn(workflowExecutionApi, 'latest').mockResolvedValue(null)
|
||||
vi.spyOn(projectsApi, 'stageReadiness').mockImplementation(async id => readiness(id))
|
||||
})
|
||||
@@ -115,6 +118,24 @@ async function openProject(initialPath: string) {
|
||||
}
|
||||
|
||||
describe('剧本完成前的下游访问限制', () => {
|
||||
it('正式分镜存在时可读查看,完整生产与素材入口仍保留原门禁', async () => {
|
||||
const id = 'formal-read-only'
|
||||
const state = readiness(id, false)
|
||||
state.script.ready = true
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(state)
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpointSummaries').mockResolvedValue([])
|
||||
const fixture = preparationFixture(id)
|
||||
vi.mocked(preparationApi.approval).mockResolvedValue({
|
||||
...fixture.approval,
|
||||
valid: true,
|
||||
confirmation: fixture.record
|
||||
})
|
||||
const { mounted } = await openProject(`/projects/${id}/storyboard`)
|
||||
expect(mounted).toHaveBeenCalledWith('storyboard')
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('已知项目资产入口不受制作阶段拦截,未知工作区仍默认锁定', async () => {
|
||||
const id = 'independent-project-assets'
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(readiness(id, false))
|
||||
|
||||
@@ -0,0 +1,656 @@
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NCheckbox, NInput, NTag } from 'naive-ui'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { useStoryboard } from '@/features/storyboard/useStoryboard'
|
||||
import { derivedBatchInput, derivedState, derivedTaskState } from '@/features/storyboard/staged-derived'
|
||||
import {
|
||||
designedShot,
|
||||
directionsResult,
|
||||
visualStatesResult,
|
||||
storyboardCheckpoint
|
||||
} from '@/features/storyboard/testing/fixtures'
|
||||
import { preparationFixture } from '../storyboard-preparation/fixtures'
|
||||
import ShotDerivedReview from '@/features/storyboard/components/ShotDerivedReview.vue'
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { billingCatalog, billingProfile } from '../../fixtures/billing'
|
||||
import StagedShotPreparation from '@/features/storyboard/components/StagedShotPreparation.vue'
|
||||
import ConfirmAction from '@/features/workflows/ConfirmAction.vue'
|
||||
import DirectionStageReview from '@/features/storyboard/components/DirectionStageReview.vue'
|
||||
import WorkflowExecutionPanel from '@/features/workflows/WorkflowExecutionPanel.vue'
|
||||
import type { WorkflowExecution } from '@/features/workflows/execution.types'
|
||||
import { workflowExecutionApi } from '@/features/workflows/execution-api'
|
||||
|
||||
/** 每个用例独立项目,避免共享活动锁污染其它范围。 */
|
||||
let serial = 0
|
||||
/** 已挂载实例统一释放轮询与取消信号。 */
|
||||
const wrappers: VueWrapper[] = []
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach(wrapper => wrapper.unmount())
|
||||
localStorage.clear()
|
||||
})
|
||||
/**
|
||||
* 不接触真实数据的公开 API 响应。
|
||||
* @param data 隔离业务数据
|
||||
* @returns 公开接口形状的独立响应
|
||||
*/
|
||||
function response(data: unknown) {
|
||||
return new Response(JSON.stringify({ data }))
|
||||
}
|
||||
/**
|
||||
* 构造后端持久化任务,领取信息与业务结果分别保留。
|
||||
* @param projectId 隔离项目身份
|
||||
* @param overrides 当前用例的任务状态
|
||||
* @returns 独立任务记录
|
||||
*/
|
||||
function execution(projectId: string, overrides: Partial<WorkflowExecution> = {}): WorkflowExecution {
|
||||
return {
|
||||
id: 'execution-1',
|
||||
projectId,
|
||||
workflowName: 'storyboard-direction',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
current: 1,
|
||||
total: 1,
|
||||
currentResourceId: null,
|
||||
metadata: { episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] },
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-15T00:00:00Z',
|
||||
updatedAt: '2026-11-15T00:00:00Z',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 挂载真实编排 Hook,所有生产 POST 由内存模拟明确隔离。
|
||||
* @param projectId 隔离项目身份
|
||||
* @returns 编排状态与明确的模拟控制
|
||||
*/
|
||||
async function harness(projectId = `staged-${++serial}`) {
|
||||
const context = testProjectContext(projectId)
|
||||
context.data.value!.checkpoints = [storyboardCheckpoint()]
|
||||
const fixture = preparationFixture(projectId)
|
||||
let directions = directionsResult(projectId)
|
||||
directions.beats[1]!.shots[0]!.direction = null
|
||||
directions.directionCount = 1
|
||||
let visuals = visualStatesResult(projectId)
|
||||
let current = execution(projectId)
|
||||
let failTransport = false
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
return response({ ...fixture.approval, valid: true, confirmation: fixture.record })
|
||||
if (path.includes('/storyboard-directions?')) return response(directions)
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visuals)
|
||||
if (path.endsWith('/production/entry-readiness'))
|
||||
return response({
|
||||
...fixture.entry,
|
||||
derivedAssets: {
|
||||
...fixture.entry.derivedAssets,
|
||||
shotCount: 2,
|
||||
directionCount: directions.directionCount,
|
||||
staleDirectionCount: directions.staleCount,
|
||||
staleVisualStateCount: visuals.staleCount
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/stop')) {
|
||||
current = {
|
||||
...current,
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true, retryAutomatically: false },
|
||||
updatedAt: '2026-11-15T00:02:00Z'
|
||||
}
|
||||
return response(current)
|
||||
}
|
||||
if (path.includes('/workflow-executions/latest')) return response(current)
|
||||
if (path.includes('/workflow-executions/')) return response(current)
|
||||
if (path.endsWith('/storyboard-directions/generate')) {
|
||||
if (failTransport) throw new Error('断线')
|
||||
directions = directionsResult(projectId)
|
||||
current = execution(projectId)
|
||||
return response({ executionId: current.id, projectId, status: 'running' })
|
||||
}
|
||||
if (path.endsWith('/storyboard-visual-states/generate')) {
|
||||
visuals = visualStatesResult(projectId, 1, true)
|
||||
current = execution(projectId, { id: 'execution-vs', workflowName: 'storyboard-visual-state' })
|
||||
return response({ executionId: current.id, projectId, status: 'running' })
|
||||
}
|
||||
throw new Error(`没有模拟 ${init?.method ?? 'GET'} ${path}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
let state!: ReturnType<typeof useStoryboard>
|
||||
const component = defineComponent({
|
||||
setup() {
|
||||
state = useStoryboard()
|
||||
return () => h('div')
|
||||
}
|
||||
})
|
||||
const options = { global: { provide: { [projectContextKey as symbol]: context } } }
|
||||
const wrapper = mount(component, options)
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
return {
|
||||
state,
|
||||
context,
|
||||
fetcher,
|
||||
wrapper,
|
||||
remount: async () => {
|
||||
const next = mount(component, options)
|
||||
wrappers.push(next)
|
||||
await flushPromises()
|
||||
return state
|
||||
},
|
||||
setTransportFailure: () => {
|
||||
failTransport = true
|
||||
},
|
||||
setCurrent: (record: WorkflowExecution) => {
|
||||
current = record
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 提取实际收费派生请求,免费读取不计入。
|
||||
* @param fetcher 隔离请求记录
|
||||
* @returns 模拟派生生成请求
|
||||
*/
|
||||
function posts(fetcher: ReturnType<typeof vi.fn<typeof fetch>>) {
|
||||
return fetcher.mock.calls.filter(
|
||||
([url, init]) => init?.method === 'POST' && /storyboard-(directions|visual-states)\/generate/.test(String(url))
|
||||
)
|
||||
}
|
||||
|
||||
describe('按正式镜头定向派生', () => {
|
||||
it.each([{ ids: [] }, { ids: ['one', 'one'] }, { ids: ['outside'] }])('拒绝空、重复和跨集范围 %j', ({ ids }) => {
|
||||
expect(() => derivedBatchInput('selected', ids, [designedShot('one')], 1, 1, false)).toThrow(/请选择|所选镜头/)
|
||||
})
|
||||
it('旧批量省略 shotIds,所选范围保留 force=false 与正式集号', () => {
|
||||
expect(derivedBatchInput('selected', ['one'], [designedShot('one')], 1, 1, false)).toEqual({
|
||||
episodeNo: 1,
|
||||
shotIds: ['one'],
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
expect(derivedBatchInput('project', [], [], 1, 1, false)).toEqual({ concurrency: 1, force: false })
|
||||
expect(derivedBatchInput('episode', [], [], 1, 1, false)).toEqual({
|
||||
episodeNo: 1,
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
})
|
||||
it('正式存在、缺失、过期与无法定位的过期来源分别显示', () => {
|
||||
const shot = designedShot('one')
|
||||
expect(derivedState(shot, 'direction', 0)).toBe('current')
|
||||
expect(derivedState({ ...shot, direction: null }, 'direction', 0)).toBe('missing')
|
||||
expect(derivedState(shot, 'direction', 1)).toBe('unknown')
|
||||
const entry = preparationFixture().entry
|
||||
entry.derivedAssetShotGaps = [{ episode: 1, shotId: 'one', direction: 'stale', visualState: 'current' }]
|
||||
expect(derivedState(shot, 'direction', 1, entry)).toBe('stale')
|
||||
expect(derivedState(shot, 'visualState', 1, entry)).toBe('current')
|
||||
})
|
||||
it('混合范围复用已有结果,摄影完成后仅显式提交画面状态,刷新不重复 POST', async () => {
|
||||
const { state, fetcher } = await harness()
|
||||
expect(state.allowed.value['direction-all']).toBe(false)
|
||||
state.toggleShots(['shot-db-1-1', 'shot-db-1-2'])
|
||||
expect(state.allowed.value['visual-all']).toBe(false)
|
||||
await state.run('visual-all')
|
||||
expect(posts(fetcher)).toHaveLength(0)
|
||||
await state.run('direction-all')
|
||||
await flushPromises()
|
||||
expect(posts(fetcher)).toHaveLength(1)
|
||||
expect(JSON.parse(String(posts(fetcher)[0]![1]?.body))).toEqual({
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2'],
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
expect(state.allowed.value['visual-all']).toBe(true)
|
||||
await state.query.refresh()
|
||||
expect(posts(fetcher)).toHaveLength(1)
|
||||
await state.run('visual-all')
|
||||
expect(JSON.parse(String(posts(fetcher)[1]![1]?.body))).toMatchObject({
|
||||
maxRepairAttempts: 0,
|
||||
force: false,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2']
|
||||
})
|
||||
await state.run('visual-all')
|
||||
expect(posts(fetcher)).toHaveLength(2)
|
||||
})
|
||||
it('有效镜头默认禁用重复生成;覆盖是明确切换,切集清空选择及覆盖', async () => {
|
||||
const { state, fetcher } = await harness()
|
||||
state.toggleShots(['shot-db-1-1'])
|
||||
expect(state.allowed.value['direction-all']).toBe(false)
|
||||
state.force.value = true
|
||||
expect(state.allowed.value['direction-all']).toBe(true)
|
||||
await state.run('direction-all')
|
||||
expect(JSON.parse(String(posts(fetcher)[0]![1]?.body)).force).toBe(true)
|
||||
state.selectedEpisode.value = 2
|
||||
await flushPromises()
|
||||
expect(state.checkedShotIds.value).toEqual([])
|
||||
expect(state.force.value).toBe(false)
|
||||
})
|
||||
it('提交回执断线后持久保护,重新挂载只免费核对原范围,不重新 POST', async () => {
|
||||
const setup = await harness()
|
||||
setup.state.toggleShots(['shot-db-1-2'])
|
||||
setup.setTransportFailure()
|
||||
await setup.state.run('direction-all')
|
||||
expect(setup.state.submissionUnknown.value).toBe(true)
|
||||
setup.wrapper.unmount()
|
||||
const restored = await setup.remount()
|
||||
restored.toggleShots(['shot-db-1-2'])
|
||||
await restored.run('direction-all')
|
||||
expect(posts(setup.fetcher)).toHaveLength(1)
|
||||
setup.setCurrent(
|
||||
execution(restored.id.value, {
|
||||
id: 'accepted-original',
|
||||
metadata: { episodeNo: 1, shotIds: ['shot-db-1-2'] }
|
||||
})
|
||||
)
|
||||
await restored.inspectSubmission()
|
||||
expect(restored.submissionUnknown.value).toBe(false)
|
||||
expect(restored.executions[1]!.observer.executionId.value).toBe('accepted-original')
|
||||
expect(posts(setup.fetcher)).toHaveLength(1)
|
||||
})
|
||||
it('停止后保留终态,免费刷新接收在途回执,不重新发生成', async () => {
|
||||
const setup = await harness()
|
||||
const current = execution(setup.state.id.value, {
|
||||
status: 'running',
|
||||
metadata: {
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1'],
|
||||
claims: [{ state: 'submitted', shotIds: ['shot-db-1-1'] }]
|
||||
}
|
||||
})
|
||||
setup.setCurrent(current)
|
||||
const observer = setup.state.executions[1]!.observer
|
||||
await observer.track(current.id, setup.state.id.value)
|
||||
expect(observer.canStop.value).toBe(true)
|
||||
await observer.stop()
|
||||
expect(observer.query.data.value?.stage).toBe('stopped')
|
||||
expect(observer.active.value).toBe(false)
|
||||
setup.setCurrent({
|
||||
...observer.query.data.value!,
|
||||
metadata: { claims: [{ state: 'received' }] },
|
||||
updatedAt: '2026-11-15T00:03:00Z'
|
||||
})
|
||||
await observer.query.refresh()
|
||||
expect(observer.query.data.value?.metadata?.claims).toEqual([{ state: 'received' }])
|
||||
expect(observer.query.data.value?.status).toBe('failed')
|
||||
expect(posts(setup.fetcher)).toHaveLength(0)
|
||||
expect(setup.fetcher.mock.calls.filter(([url]) => String(url).endsWith('/stop'))).toHaveLength(1)
|
||||
})
|
||||
it('已停止但原请求仍在途时,force也不能绕过所选范围费用核对', async () => {
|
||||
const setup = await harness()
|
||||
const record = execution(setup.state.id.value, {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true },
|
||||
metadata: {
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1'],
|
||||
claims: [{ episodeNo: 1, shotIds: ['shot-db-1-1'], state: 'submitted' }]
|
||||
}
|
||||
})
|
||||
setup.setCurrent(record)
|
||||
await setup.state.executions[1]!.observer.track(record.id, setup.state.id.value)
|
||||
setup.state.toggleShots(['shot-db-1-1'])
|
||||
setup.state.force.value = true
|
||||
expect(setup.state.allowed.value['direction-all']).toBe(false)
|
||||
await setup.state.run('direction-all')
|
||||
expect(posts(setup.fetcher)).toHaveLength(0)
|
||||
setup.state.toggleShots(['shot-db-1-1', 'shot-db-1-2'])
|
||||
setup.state.toggleShots(['shot-db-1-1'])
|
||||
expect(setup.state.allowed.value['direction-all']).toBe(true)
|
||||
})
|
||||
it('停止按项目原执行 POST,未知请求与范围外镜头分开', async () => {
|
||||
const record = execution('p', {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
error: 'STORYBOARD_DERIVED_REQUEST_UNRESOLVED'
|
||||
})
|
||||
expect(derivedTaskState(record, 'shot-db-1-1', 1)).toBe('unresolved')
|
||||
expect(derivedTaskState(record, 'outside', 1)).toBeNull()
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockResolvedValue(response(record)))
|
||||
await workflowExecutionApi.stop('original/1', 'p')
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
'/api/workflow-executions/original%2F1/stop',
|
||||
expect.objectContaining({ method: 'POST', body: '{"projectId":"p"}' })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('独立摄影沿原采用入口', () => {
|
||||
/**
|
||||
* 挂载原字段编辑与独立阶段,模拟端只返回正式契约。
|
||||
* @param conflict 是否制造正式采用并发冲突
|
||||
* @returns 真实编辑器与隔离请求记录
|
||||
*/
|
||||
async function editor(conflict = false) {
|
||||
const projectId = `direction-review-${++serial}`
|
||||
const fixture = preparationFixture(projectId)
|
||||
const directions = directionsResult(projectId)
|
||||
directions.beats[0]!.shots[0]!.direction = {
|
||||
...directions.beats[0]!.shots[0]!.direction!,
|
||||
id: 'direction-original',
|
||||
updatedAt: '2026-11-15T01:00:00.000Z',
|
||||
rawJson: null
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
return response({ ...fixture.approval, valid: true, confirmation: fixture.record })
|
||||
if (path.includes('/storyboard-directions?')) return response(directions)
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId))
|
||||
if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
const body = JSON.parse(String(init?.body))
|
||||
if (conflict && !body.preview)
|
||||
return new Response(
|
||||
JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影版本已变化,请重新读取。' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
return response({
|
||||
projectId,
|
||||
phase: 'direction',
|
||||
preview: body.preview,
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
changed: false,
|
||||
shots: [
|
||||
{
|
||||
shotId: 'shot-db-1-1',
|
||||
directionId: 'direction-original',
|
||||
updatedAt: '2026-11-15T01:00:00.000Z',
|
||||
changed: false,
|
||||
alreadyApplied: !body.preview
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
throw new Error('没有模拟 ' + path)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(DirectionStageReview, {
|
||||
props: { projectId, episodeNo: 1, shot: { ...designedShot(), visualState: null }, disabled: false }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
return { wrapper, fetcher }
|
||||
}
|
||||
it('免费预检冻结完整原版本,changed=false仍可采用,同草案支持幂等回执', async () => {
|
||||
const { wrapper, fetcher } = await editor()
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs[0]!.vm.$emit('update:value', '修订构图,保持已绑定主体')
|
||||
inputs[2]!.vm.$emit('update:value', '实际审核人')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('预检通过')
|
||||
expect(wrapper.vm.canAdopt).toBe(false)
|
||||
wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
expect(wrapper.vm.canAdopt).toBe(true)
|
||||
await wrapper.vm.adopt()
|
||||
const calls = fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm'))
|
||||
expect(calls).toHaveLength(2)
|
||||
const preview = JSON.parse(String(calls[0]![1]?.body))
|
||||
const adopt = JSON.parse(String(calls[1]![1]?.body))
|
||||
expect(preview).toMatchObject({
|
||||
phase: 'direction',
|
||||
preview: true,
|
||||
reviewer: '实际审核人',
|
||||
expectedShotFingerprint: 'b'.repeat(64),
|
||||
shots: [
|
||||
{
|
||||
expectedDirectionId: 'direction-original',
|
||||
expectedDirectionRawJson: null,
|
||||
expectedDirectionUpdatedAt: '2026-11-15T01:00:00.000Z',
|
||||
direction: { shotSize: 'medium', cameraAngle: 'eye-level', composition: '修订构图,保持已绑定主体' }
|
||||
}
|
||||
]
|
||||
})
|
||||
expect(adopt).toEqual({ ...preview, preview: false, expectedSourceFingerprint: 'c'.repeat(64) })
|
||||
expect(preview.shots[0]).not.toHaveProperty('visualState')
|
||||
expect(wrapper.emitted('adopted')).toHaveLength(1)
|
||||
})
|
||||
it('修改署名或内容撤销预检;并发409保留输入且不自动覆盖', async () => {
|
||||
const { wrapper, fetcher } = await editor(true)
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs[2]!.vm.$emit('update:value', '审核人')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await wrapper.vm.adopt()
|
||||
expect(wrapper.vm.canAdopt).toBe(false)
|
||||
expect(wrapper.emitted('adopted')).toBeUndefined()
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm'))).toHaveLength(2)
|
||||
expect(inputs[2]!.props('value')).toBe('审核人')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '重新读取正式来源')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
inputs[0]!.vm.$emit('update:value', '又一次修改')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('预检通过')
|
||||
})
|
||||
})
|
||||
|
||||
describe('已有下游的原组合摄影修订', () => {
|
||||
it('保留画面状态、原预览指纹和正式来源,不绕入独立摄影 phase', async () => {
|
||||
const projectId = `combined-${++serial}`
|
||||
const fixture = preparationFixture(projectId)
|
||||
const shot = designedShot()
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.includes('/keyframe-review-draft')) return response(null)
|
||||
if (path.endsWith('/preflight'))
|
||||
return response({
|
||||
current: { ...fixture.approval, valid: true, confirmation: fixture.record },
|
||||
quality: fixture.quality
|
||||
})
|
||||
if (path.includes('/keyframe-spec'))
|
||||
return response({ shotId: shot.shotId, formalSourceFingerprint: 'e'.repeat(64), references: [] })
|
||||
if (path.includes('/generation-spec')) return response({ shotId: shot.shotId, subjects: [] })
|
||||
if (path.includes('/storyboard-directions?')) return response(directionsResult(projectId))
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId, 1, true))
|
||||
if (path.endsWith('/generation-models')) return response(billingCatalog)
|
||||
if (path.endsWith('/creative-profile')) return response({ ...billingProfile, projectId })
|
||||
if (path.includes('/keyframe/preview'))
|
||||
return response({
|
||||
...imagePreviewFixture(),
|
||||
shotId: shot.shotId,
|
||||
draftFingerprint: 'd'.repeat(64),
|
||||
productionReady: false,
|
||||
productionGate: { ready: false, reason: '项目尚未完成' },
|
||||
sceneSources: []
|
||||
})
|
||||
if (path.endsWith('/storyboard-derived-reviews/confirm'))
|
||||
return response({ shots: [{ shotId: shot.shotId }] })
|
||||
throw new Error(`未模拟 ${init?.method ?? 'GET'} ${path}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(ShotDerivedReview, {
|
||||
attachTo: document.body,
|
||||
props: { projectId, episodeNo: 1, shot, shots: [shot], disabled: false }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.findComponent(DirectionStageReview).exists()).toBe(false)
|
||||
const preview = [...document.querySelectorAll<HTMLButtonElement>('.app-drawer button')].find(
|
||||
button => button.textContent?.trim() === '免费预览摄影草案'
|
||||
)!
|
||||
expect(preview.disabled).toBe(false)
|
||||
preview.click()
|
||||
await flushPromises()
|
||||
const reviewer = wrapper.findAllComponents(NInput).find(input => input.attributes('aria-label') === '审核人')!
|
||||
reviewer.vm.$emit('update:value', '组合审核人')
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
const adopt = [...document.querySelectorAll<HTMLButtonElement>('.app-drawer button')].find(
|
||||
button => button.textContent?.trim() === '正式采用本镜'
|
||||
)!
|
||||
expect(adopt.disabled).toBe(false)
|
||||
adopt.click()
|
||||
await flushPromises()
|
||||
const call = fetcher.mock.calls.find(([url]) => String(url).endsWith('/storyboard-derived-reviews/confirm'))!
|
||||
const body = JSON.parse(String(call[1]?.body))
|
||||
expect(body).not.toHaveProperty('phase')
|
||||
expect(body.shots[0]).toMatchObject({
|
||||
expectedDraftFingerprint: 'd'.repeat(64),
|
||||
expectedCurrentFormalSourceFingerprint: 'e'.repeat(64),
|
||||
draft: { visualState: { shotNo: shot.shotNo }, expectedShotFingerprint: 'b'.repeat(64) }
|
||||
})
|
||||
expect(wrapper.emitted('changed')).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('原失败、停止及免费恢复展示', () => {
|
||||
it('停止不显示普通质量失败或成功,收到结果不暗示通过', () => {
|
||||
const wrapper = mount(WorkflowExecutionPanel, {
|
||||
props: {
|
||||
execution: execution('stopped-ui', {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true },
|
||||
metadata: { claims: [{ state: 'submitted' }, { state: 'received' }] }
|
||||
}),
|
||||
loading: false,
|
||||
error: ''
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
expect(wrapper.getComponent(NTag).text()).toBe('已停止')
|
||||
expect(wrapper.getComponent(NTag).props('type')).toBe('default')
|
||||
expect(wrapper.text()).toContain('请求结果未知 1 步')
|
||||
expect(wrapper.text()).not.toContain('制作任务执行失败')
|
||||
})
|
||||
it('免费恢复关联原失败历史,只有免费 GET,不出现重新生成成功', async () => {
|
||||
const original = execution('recovery-ui', {
|
||||
id: 'failed-original',
|
||||
workflowName: 'storyboard-visual-state',
|
||||
status: 'failed',
|
||||
error: '原结果校验未通过'
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(response(original))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(WorkflowExecutionPanel, {
|
||||
props: {
|
||||
execution: execution('recovery-ui', {
|
||||
workflowName: 'storyboard-visual-state',
|
||||
metadata: { recoveryOf: original.id },
|
||||
result: { recovered: true, actualModelRequests: 0 }
|
||||
}),
|
||||
loading: false,
|
||||
error: ''
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('新增模型请求 0 次')
|
||||
expect(wrapper.text()).toContain('原失败执行仍保留为失败')
|
||||
expect(wrapper.text()).toContain('原结果校验未通过')
|
||||
expect(wrapper.text()).not.toContain('重新生成成功')
|
||||
expect(fetcher.mock.calls.every(([, options]) => options?.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('免费准备与精确范围确认', () => {
|
||||
it('未点击不请求,参考、计划和资产错误分开,不把失败当尚未生成', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async url => {
|
||||
if (String(url).endsWith('/references'))
|
||||
return new Response(JSON.stringify({ message: '参考数据读取失败' }), { status: 500 })
|
||||
if (String(url).endsWith('/production/plan'))
|
||||
return new Response(JSON.stringify({ message: '计划读取失败' }), { status: 500 })
|
||||
return response({ projectId: 'preparation-errors', completed: false })
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(StagedShotPreparation, {
|
||||
props: { projectId: 'preparation-errors', active: true, shots: [designedShot('one')] }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('参考数据读取失败')
|
||||
expect(wrapper.text()).toContain('计划读取失败')
|
||||
expect(wrapper.text()).toContain('尚未完成')
|
||||
expect(wrapper.text()).not.toContain('参考素材缺失')
|
||||
expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([
|
||||
'/api/storyboard-shots/one/references',
|
||||
'/api/projects/preparation-errors/production/plan',
|
||||
'/api/projects/preparation-errors/production/status'
|
||||
])
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
|
||||
expect(JSON.parse(String(fetcher.mock.calls[1]![1]?.body))).toEqual({})
|
||||
})
|
||||
it('关闭抽屉取消完整计划,迟到响应不回填也不再读取资产状态', async () => {
|
||||
let resolvePlan!: (value: Response) => void
|
||||
let planSignal: AbortSignal | null = null
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
if (String(url).endsWith('/references')) return response({ shotId: 'one', references: [], missing: [] })
|
||||
planSignal = init?.signal as AbortSignal
|
||||
return new Promise(resolve => {
|
||||
resolvePlan = resolve
|
||||
})
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(StagedShotPreparation, {
|
||||
props: { projectId: 'cancel-plan', active: true, shots: [designedShot('one')] }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
await wrapper.setProps({ active: false })
|
||||
await flushPromises()
|
||||
expect((planSignal as AbortSignal | null)?.aborted).toBe(true)
|
||||
resolvePlan(response({ projectId: 'cancel-plan', entryReadiness: { ready: true }, stageReadiness: {} }))
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('项目生产入口:已就绪')
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
it('同镜头数量但身份改变时撤销旧费用确认', async () => {
|
||||
const wrapper = mount(ConfirmAction, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
label: '补齐所选 1 镜',
|
||||
description: '收费文本模型与覆盖影响说明',
|
||||
confirmationKey: 'shot-one',
|
||||
acknowledgement: true
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
const checkbox = document.querySelector<HTMLElement>('.app-dialog [role="checkbox"]')!
|
||||
checkbox.click()
|
||||
await flushPromises()
|
||||
const confirm = [...document.querySelectorAll<HTMLButtonElement>('.app-dialog button')].find(
|
||||
button => button.textContent?.trim() === '确认补齐所选 1 镜'
|
||||
)!
|
||||
expect(confirm.disabled).toBe(false)
|
||||
await wrapper.setProps({ confirmationKey: 'shot-two' })
|
||||
await flushPromises()
|
||||
expect(confirm.disabled).toBe(true)
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -117,6 +117,19 @@ function stubFetch(fetcher: Mock<typeof fetch>) {
|
||||
const current = preparationFixture(fixture.id)
|
||||
return jsonResponse({ ...current.approval, valid: true, confirmation: current.record })
|
||||
}
|
||||
if (path.endsWith('/production/entry-readiness'))
|
||||
return jsonResponse({
|
||||
...preparationFixture(fixture.id).entry,
|
||||
derivedAssets: {
|
||||
shotCount: 4,
|
||||
directionCount: 2,
|
||||
directionCoverage: 0.5,
|
||||
visualStateCount: 0,
|
||||
visualStateCoverage: 0,
|
||||
staleDirectionCount: 0,
|
||||
staleVisualStateCount: 0
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/generation-models')) return jsonResponse(imageCatalog)
|
||||
if (path.endsWith('/creative-profile')) return jsonResponse(generationProfile(fixture.id))
|
||||
/** 主体与首帧表单使用原配置解析接口,不创建图片候选。 */
|
||||
@@ -284,6 +297,8 @@ async function mountStoryboard() {
|
||||
})
|
||||
await flushPromises()
|
||||
await expandSections()
|
||||
selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'project')
|
||||
await flushPromises()
|
||||
return provided
|
||||
}
|
||||
|
||||
@@ -1830,8 +1845,8 @@ describe('工作台页面交互', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
await confirmGeneration('补齐全项目摄影设计')
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(true)
|
||||
await drawerPanel().get('.app-drawer-footer button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('[data-workspace-tools]').attributes('aria-expanded')).toBe('false')
|
||||
@@ -1854,15 +1869,15 @@ describe('工作台页面交互', () => {
|
||||
await flushPromises()
|
||||
expect(getStoryboardSession(fixture.id).receipt).toMatchObject({
|
||||
kind: 'batch',
|
||||
title: '项目导演设计'
|
||||
title: '摄影设计任务'
|
||||
})
|
||||
expect(getOperation(fixture.id).pending).toBe(false)
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts).toHaveLength(1)
|
||||
expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 2, force: false })
|
||||
expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 1, force: false })
|
||||
})
|
||||
|
||||
it('分镜只提供正式项目生成,逐集失败回执保留零次修复参数', async () => {
|
||||
it('分镜保留显式批量范围,逐集失败回执保留零次修复参数', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (init?.method === 'POST')
|
||||
return new Response(
|
||||
@@ -1899,15 +1914,18 @@ describe('工作台页面交互', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).not.toContain('生成本集导演设计')
|
||||
expect(wrapper!.text()).not.toContain('生成本集即时状态')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(false)
|
||||
expect(button('补齐项目即时状态').disabled).toBe(false)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(false)
|
||||
selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'episode')
|
||||
await flushPromises()
|
||||
expect(button('补齐第 1 集画面状态').disabled).toBe(false)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method !== 'POST')).toBe(true)
|
||||
await drawerPanel().get('#storyboard-repairs').setValue('0')
|
||||
await confirmGeneration('补齐项目即时状态')
|
||||
await confirmGeneration('补齐第 1 集画面状态')
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({
|
||||
concurrency: 2,
|
||||
concurrency: 1,
|
||||
force: false,
|
||||
episodeNo: 1,
|
||||
maxRepairAttempts: 0
|
||||
})
|
||||
expect(drawerPanel().text()).toContain('本次有未完成项')
|
||||
@@ -1998,15 +2016,18 @@ describe('工作台页面交互', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
await confirmGeneration('补齐全项目摄影设计')
|
||||
expect(drawerPanel().get('[aria-label="生成回执"] [role="alert"]').text()).toContain('本次有未完成项')
|
||||
expect(drawerPanel().text()).toContain('模型校验失败')
|
||||
await drawerPanel().get('[role="checkbox"]').trigger('click')
|
||||
await confirmGeneration('重生成全部导演设计')
|
||||
await drawerPanel()
|
||||
.findAll('[role="checkbox"]')
|
||||
.find(item => item.text().includes('覆盖本次范围已有结果'))!
|
||||
.trigger('click')
|
||||
await confirmGeneration('重生成全项目摄影设计')
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts.map(([, init]) => JSON.parse(init!.body as string))).toEqual([
|
||||
{ concurrency: 2, force: false },
|
||||
{ concurrency: 2, force: true }
|
||||
{ concurrency: 1, force: false },
|
||||
{ concurrency: 1, force: true }
|
||||
])
|
||||
})
|
||||
|
||||
@@ -2052,7 +2073,7 @@ describe('工作台页面交互', () => {
|
||||
/** 切换剧集只增加当前集查询,项目时长预算只在挂载时读取一次。 */
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => !String(url).endsWith('/storyboard-quality-confirmation'))
|
||||
).toHaveLength(6)
|
||||
).toHaveLength(7)
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard-quality-confirmation'))
|
||||
).toHaveLength(1)
|
||||
@@ -2076,11 +2097,11 @@ describe('工作台页面交互', () => {
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('数据库暂不可用')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(true)
|
||||
fail = false
|
||||
button('重试查询').click()
|
||||
await flushPromises()
|
||||
expect(button('补齐项目导演设计').disabled).toBe(false)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(false)
|
||||
/** 重试恢复正式镜头数据,内部编号仍用于业务选择。 */
|
||||
expect(wrapper!.getComponent(ShotDesign).props('shot').shotId).toBe('shot-db-1-1')
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user