feat(short-drama-agent-front): 接入有限图片授权与候选修订
This commit is contained in:
1 parent
f6edc4eb70
commit
b15a6011ce
37 files changed
+3569
-76
No files matched your search
@@ -0,0 +1,246 @@
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { NCheckbox, NInput } from 'naive-ui'
|
||||
import ShotDerivedReview from '@/features/storyboard/components/ShotDerivedReview.vue'
|
||||
import { jointReviewFixture } from '../../fixtures/joint-review'
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { billingCatalog, billingProfile } from '../../fixtures/billing'
|
||||
import { keyframeFixture } from '@/features/production/testing/fixtures'
|
||||
import type { SaveKeyframeDraft, SavedKeyframeDraft } from '@/features/storyboard/derived-review.types'
|
||||
|
||||
/**
|
||||
* 通过真实摄影抽屉验证已有failed图片下的有界修订;所有接口隔离。
|
||||
* @param conflict 是否模拟其它任务占用后改源
|
||||
* @returns 实际抽屉、只读候选及原请求
|
||||
*/
|
||||
async function camera(conflict = false) {
|
||||
const projectId = conflict ? 'camera-conflict' : 'camera-existing-images',
|
||||
f = jointReviewFixture(projectId),
|
||||
shotId = f.shot.shotId
|
||||
let saved: SavedKeyframeDraft | null = null,
|
||||
adopted = false
|
||||
const rows = [
|
||||
keyframeFixture({ id: 'old-failed-image', shotId, isPrimary: false }),
|
||||
keyframeFixture({ id: 'original-primary', shotId, isPrimary: true })
|
||||
]
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url),
|
||||
body = init?.body ? JSON.parse(String(init.body)) : undefined
|
||||
if (path.endsWith('/storyboard-quality-confirmation/preflight'))
|
||||
return Response.json({
|
||||
data: {
|
||||
current: { ...f.approval.approval, valid: true, confirmation: f.approval.record },
|
||||
quality: f.approval.quality
|
||||
}
|
||||
})
|
||||
if (path.includes('/keyframe-review-draft')) {
|
||||
if (init?.method === 'PUT') {
|
||||
const input = body as SaveKeyframeDraft
|
||||
saved = {
|
||||
...f.saved,
|
||||
revision: (saved?.revision ?? 0) + 1,
|
||||
draft: input.draft,
|
||||
providerInput: input.providerInput ?? null,
|
||||
expectedCurrentFormalSourceFingerprint: input.expectedCurrentFormalSourceFingerprint ?? null
|
||||
}
|
||||
}
|
||||
return Response.json({ data: saved })
|
||||
}
|
||||
if (path.includes('/keyframe-spec'))
|
||||
return Response.json({
|
||||
data: {
|
||||
...f.keyframe,
|
||||
formalSourceFingerprint: adopted ? 'f'.repeat(64) : f.keyframe.formalSourceFingerprint
|
||||
}
|
||||
})
|
||||
if (path.includes('/generation-spec'))
|
||||
return Response.json({ data: { projectId, shotId, subjects: [], continuity: null } })
|
||||
if (path.includes('/storyboard-directions?')) return Response.json({ data: f.directions })
|
||||
if (path.includes('/storyboard-visual-states?')) return Response.json({ data: f.visuals })
|
||||
if (path.endsWith('/generation-models')) return Response.json({ data: billingCatalog })
|
||||
if (path.endsWith('/creative-profile'))
|
||||
return Response.json({
|
||||
data: { ...billingProfile, projectId, imageOptions: { size: '1024x1024', quality: 'auto', count: 1 } }
|
||||
})
|
||||
if (path.includes('/keyframe/preview'))
|
||||
return Response.json({
|
||||
data: {
|
||||
...imagePreviewFixture(),
|
||||
shotId,
|
||||
provider: 'openai-image',
|
||||
model: 'gpt-image-2.5-flare',
|
||||
...(body.draft
|
||||
? {
|
||||
draftFingerprint: 'd'.repeat(64),
|
||||
currentDerivedFingerprint: 'c'.repeat(64),
|
||||
adjacentDerivedVersions: [],
|
||||
productionReady: false,
|
||||
productionGate: { ready: false, reason: '原费用仍阻断' },
|
||||
sceneSources: []
|
||||
}
|
||||
: {})
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
if (conflict) {
|
||||
f.directions.beats[0]!.shots[0]!.direction!.composition = '另一位编辑已经更改正式构图'
|
||||
return Response.json(
|
||||
{ code: 'CAMERA_REVISION_ACTIVE', message: '原任务仍活动,请保留草稿' },
|
||||
{ status: 409 }
|
||||
)
|
||||
}
|
||||
adopted = true
|
||||
if (saved) saved.status = 'stale'
|
||||
f.directions.beats[0]!.shots[0]!.direction = {
|
||||
...body.shots[0].draft.direction,
|
||||
rawJson: JSON.stringify({
|
||||
cameraRevisionHistory: [
|
||||
{
|
||||
reviewer: body.reviewer,
|
||||
before: { composition: '人物居左', cameraPosition: '门口' },
|
||||
after: {
|
||||
composition: body.shots[0].draft.direction.composition,
|
||||
cameraPosition: body.shots[0].draft.direction.cameraPosition
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
return Response.json({
|
||||
data: {
|
||||
projectId,
|
||||
shots: [{ shotId, directionId: 'd', visualStateId: 'v', draftFingerprint: 'd'.repeat(64) }]
|
||||
}
|
||||
})
|
||||
}
|
||||
if (path.endsWith('/image-authorizations/preview'))
|
||||
return Response.json({
|
||||
data: {
|
||||
provider: 'openai-image',
|
||||
model: 'gpt-image-2.5-flare',
|
||||
context: { projectId, scope: 'keyframe', targetId: shotId, sourceFingerprint: 'f'.repeat(64) },
|
||||
planFingerprint: 'b'.repeat(64),
|
||||
authorization: { billingBlocked: true }
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/keyframes')) return Response.json({ data: rows })
|
||||
if (path.includes('/quality-review'))
|
||||
return Response.json({
|
||||
data: {
|
||||
shotId,
|
||||
keyframeId: path.includes('/old-failed-image/') ? 'old-failed-image' : 'original-primary',
|
||||
qualityDecision: path.includes('/old-failed-image/') ? 'failed' : 'passed',
|
||||
effectiveQualityStatus: adopted
|
||||
? 'stale'
|
||||
: path.includes('/old-failed-image/')
|
||||
? 'failed'
|
||||
: 'passed',
|
||||
validationTaskId: null,
|
||||
historicalGazePreview: [],
|
||||
manualReview: null,
|
||||
manualReviewAvailable: false
|
||||
}
|
||||
})
|
||||
if (path.includes('/validations')) return Response.json({ data: [] })
|
||||
throw new Error('未模拟 ' + path)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(ShotDerivedReview, {
|
||||
props: { projectId, episodeNo: 1, shot: f.shot, shots: f.shots, disabled: false },
|
||||
global: { stubs: { teleport: true } }
|
||||
})
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
return { wrapper, fetcher, rows }
|
||||
}
|
||||
/**
|
||||
* 显式点击摄影抽屉中的原动作,不绕开禁用或确认逻辑。
|
||||
* @param wrapper 真实抽屉
|
||||
* @param text 当前按钮文字
|
||||
*/
|
||||
async function click(wrapper: Awaited<ReturnType<typeof camera>>['wrapper'], text: string) {
|
||||
const row = wrapper.findAll('button').find(button => button.text() === text)!
|
||||
expect(row.attributes('disabled')).toBeUndefined()
|
||||
await row.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
describe('已有失败图片的摄影修订', () => {
|
||||
it('保存不采用;明确采用后旧failed转当前stale,原Primary/图片/审核和费用仍保留', async () => {
|
||||
const { wrapper, fetcher, rows } = await camera()
|
||||
try {
|
||||
const input = wrapper.findAllComponents(NInput).find(row => row.attributes('aria-label') === '摄影构图')!
|
||||
input.vm.$emit('update:value', '本次新构图,保持正式主体与原动作')
|
||||
await flushPromises()
|
||||
await click(wrapper, '保存草案')
|
||||
expect(
|
||||
fetcher.mock.calls.some(([url]) => String(url).endsWith('/storyboard-derived-reviews/confirm'))
|
||||
).toBe(false)
|
||||
await wrapper
|
||||
.findAll('.n-collapse-item__header-main')
|
||||
.find(row => row.text() === '已有图片与质量(只读)')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('质量未通过')
|
||||
expect(wrapper.findAll('.keyframe-card')).toHaveLength(2)
|
||||
await click(wrapper, '免费预览摄影草案')
|
||||
wrapper
|
||||
.findAllComponents(NInput)
|
||||
.find(row => row.attributes('aria-label') === '审核人')!
|
||||
.vm.$emit('update:value', '明确摄影审核人')
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await click(wrapper, '正式采用本镜')
|
||||
const confirm = fetcher.mock.calls.find(([url]) =>
|
||||
String(url).endsWith('/storyboard-derived-reviews/confirm')
|
||||
)!,
|
||||
body = JSON.parse(String(confirm[1]?.body))
|
||||
expect(body).not.toHaveProperty('phase')
|
||||
expect(body.shots[0]).not.toHaveProperty('jointRevision')
|
||||
expect(body.shots[0].draft.direction).toMatchObject({
|
||||
composition: '本次新构图,保持正式主体与原动作',
|
||||
shotSize: 'medium',
|
||||
cameraAngle: 'eye-level',
|
||||
cameraMovement: 'static',
|
||||
lensIntent: 'normal',
|
||||
depthOfField: 'shallow',
|
||||
visualIntent: '观察来信'
|
||||
})
|
||||
expect(wrapper.text()).toContain('历史审核未通过,当前来源已变化')
|
||||
expect(wrapper.text()).toContain('草案来源已变化')
|
||||
expect(wrapper.text()).toContain('主首帧')
|
||||
expect(wrapper.findAll('.keyframe-card')).toHaveLength(2)
|
||||
expect(rows[1]!.isPrimary).toBe(true)
|
||||
expect(
|
||||
fetcher.mock.calls.some(
|
||||
([url, init]) => init?.method === 'POST' && /\/keyframe$|\/validate|\/primary/.test(String(url))
|
||||
)
|
||||
).toBe(false)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/image-authorizations/preview'))).toBe(true)
|
||||
} finally {
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
it('活动/来源409重读正式源但保留人工构图,不自动再次采用', async () => {
|
||||
const { wrapper, fetcher } = await camera(true)
|
||||
try {
|
||||
const input = wrapper.findAllComponents(NInput).find(row => row.attributes('aria-label') === '摄影构图')!
|
||||
input.vm.$emit('update:value', '这份人工构图必须保留')
|
||||
await flushPromises()
|
||||
await click(wrapper, '免费预览摄影草案')
|
||||
wrapper
|
||||
.findAllComponents(NInput)
|
||||
.find(row => row.attributes('aria-label') === '审核人')!
|
||||
.vm.$emit('update:value', '人工审核人')
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await click(wrapper, '正式采用本镜')
|
||||
expect(input.props('value')).toBe('这份人工构图必须保留')
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard-derived-reviews/confirm'))
|
||||
).toHaveLength(1)
|
||||
expect(wrapper.findAll('button').find(row => row.text() === '正式采用本镜')).toBeUndefined()
|
||||
} finally {
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,349 @@
|
||||
import { defineComponent, h, ref } from 'vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useMotionRevision } from '@/features/storyboard/useMotionRevision'
|
||||
import { motionEvidenceCurrent, type MotionPlan, type MotionRevision } from '@/features/storyboard/motion-revision'
|
||||
import type { WorkflowExecution } from '@/features/workflows/execution.types'
|
||||
import { keyframeFixture } from '@/features/production/testing/fixtures'
|
||||
|
||||
/** 独立项目避免共享工作流或操作锁互相影响。 */ let serial = 0
|
||||
/** 释放所有观察器。 */ const wrappers: VueWrapper[] = []
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach(wrapper => wrapper.unmount())
|
||||
localStorage.clear()
|
||||
})
|
||||
/**
|
||||
* 全量隔离原Task、失败根、人工子版本及起点任务,不调用真实模型。
|
||||
* @param conflict 是否拒绝第一次保存
|
||||
* @returns 真实编排、公开投影及Mock请求
|
||||
*/
|
||||
async function harness(conflict = false) {
|
||||
const projectId = 'failed-motion-' + ++serial,
|
||||
shotId = 'failed-motion-shot',
|
||||
primary = keyframeFixture({ shotId })
|
||||
const plan: MotionPlan = {
|
||||
beats: [
|
||||
{
|
||||
startSecond: 0,
|
||||
endSecond: 4,
|
||||
action: '人物开始向前缓慢行走',
|
||||
cameraMotion: '保持静止',
|
||||
physicalContinuity: '双脚支撑保持正常连续',
|
||||
subjectRefs: ['@CH0001'],
|
||||
closingState: '人物停在原地保持站立',
|
||||
performedActionIds: ['actual-action']
|
||||
}
|
||||
],
|
||||
globalMotionConstraints: ['保持正式动作不重复'],
|
||||
interactions: []
|
||||
}
|
||||
const history: {
|
||||
shotId: string
|
||||
originalRevisionId: string | null
|
||||
activeRevisionId: string | null
|
||||
revisions: MotionRevision[]
|
||||
} = { shotId, originalRevisionId: null, activeRevisionId: null, revisions: [] }
|
||||
const candidate = {
|
||||
taskId: 'failed-task',
|
||||
executionId: 'failed-workflow',
|
||||
shotId,
|
||||
plan: { projectId },
|
||||
current: true,
|
||||
status: 'failed',
|
||||
qualityFailure: { phase: 'motion_plan', issues: ['原起点动作冲突'] },
|
||||
observations: { motion_plan: plan },
|
||||
steps: [
|
||||
{
|
||||
name: 'motion_plan',
|
||||
status: 'completed',
|
||||
providerRequestId: 'original-provider',
|
||||
usage: { inputTokens: 100 }
|
||||
}
|
||||
]
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url),
|
||||
body = init?.body ? JSON.parse(String(init.body)) : undefined
|
||||
if (path.endsWith('/motion-plan/preview'))
|
||||
return Response.json({
|
||||
data: {
|
||||
shotId,
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
durationSeconds: 4,
|
||||
motionPlanAvailable: false,
|
||||
beats: [],
|
||||
globalMotionConstraints: [],
|
||||
issues: [],
|
||||
actionDensityIssues: [],
|
||||
actionReviewSuggestions: [],
|
||||
savedActionDensityIssues: null,
|
||||
willCallModel: false,
|
||||
willModifyAssets: false
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/keyframes')) return Response.json({ data: [primary] })
|
||||
if (path.endsWith('/video-prompt/executions/failed-task')) return Response.json({ data: candidate })
|
||||
if (path.endsWith('/revisions/preview'))
|
||||
return Response.json({
|
||||
data: {
|
||||
shotId,
|
||||
valid: true,
|
||||
motionPlanFingerprint: 'f'.repeat(64),
|
||||
schemaIssues: [],
|
||||
timelineIssues: [],
|
||||
actionDensityIssues: [],
|
||||
formalIssues: [],
|
||||
requiresStartStateValidation: true,
|
||||
canActivate: false,
|
||||
willCallModel: false,
|
||||
willModifyAssets: false,
|
||||
startStateStatus: 'required_unknown',
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
previewFingerprint: 'd'.repeat(64),
|
||||
source: {
|
||||
projectId,
|
||||
activeRevisionId: history.activeRevisionId,
|
||||
primaryKeyframeId: primary.id,
|
||||
facts: {}
|
||||
},
|
||||
startStatePlan: {
|
||||
version: 1,
|
||||
primaryKeyframeId: primary.id,
|
||||
expectedRevisionId: history.activeRevisionId,
|
||||
motionPlanFingerprint: 'f'.repeat(64),
|
||||
fingerprint: 'a'.repeat(64),
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
status: 'ready',
|
||||
executionAvailable: true,
|
||||
proposedMaximumProviderRequests: 1,
|
||||
additionalProviderRequests: 1,
|
||||
feeEstimate: { currency: 'CNY', amount: null, reason: '未知' }
|
||||
}
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/revisions') && init?.method === 'POST') {
|
||||
if (conflict)
|
||||
return Response.json({ code: 'MOTION_PLAN_PREVIEW_STALE', message: '原来源已变化' }, { status: 409 })
|
||||
const root: MotionRevision = {
|
||||
revisionId: 'failed-root',
|
||||
shotId,
|
||||
source: 'failed_candidate',
|
||||
parentRevisionId: null,
|
||||
reason: JSON.stringify({ originalBusinessStatus: 'failed' }),
|
||||
candidateOrigin: {
|
||||
taskId: 'failed-task',
|
||||
workflowExecutionId: 'failed-workflow',
|
||||
authorizationId: 'original-grant',
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
evidenceFingerprint: 'e'.repeat(64),
|
||||
receiptFingerprint: 'b'.repeat(64),
|
||||
originalBusinessStatus: 'failed'
|
||||
},
|
||||
motionPlan: plan,
|
||||
durationSeconds: 4,
|
||||
fingerprint: 'e'.repeat(64),
|
||||
createdAt: '2026-11-18T00:00:00Z',
|
||||
isActive: false
|
||||
}
|
||||
const manual: MotionRevision = {
|
||||
...root,
|
||||
revisionId: 'manual-child',
|
||||
source: 'manual',
|
||||
parentRevisionId: root.revisionId,
|
||||
reason: body.reason,
|
||||
candidateOrigin: null,
|
||||
motionPlan: body.motionPlan,
|
||||
fingerprint: 'f'.repeat(64)
|
||||
}
|
||||
history.revisions = [root, manual]
|
||||
return Response.json({ data: manual }, { status: 201 })
|
||||
}
|
||||
if (path.endsWith('/revisions')) return Response.json({ data: history })
|
||||
if (path.endsWith('/start-state-validation/start'))
|
||||
return Response.json({
|
||||
data: { executionId: 'validation-workflow', status: 'completed', willCallModel: false, reused: true }
|
||||
})
|
||||
if (path.includes('/workflow-executions/validation-workflow'))
|
||||
return Response.json({
|
||||
data: {
|
||||
id: 'validation-workflow',
|
||||
projectId,
|
||||
workflowName: 'motion-plan-start-state-validation',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
current: 1,
|
||||
total: 1,
|
||||
currentResourceId: null,
|
||||
metadata: { shotId, revisionId: 'manual-child' },
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-18T00:00:00Z',
|
||||
updatedAt: '2026-11-18T00:00:00Z',
|
||||
result: {
|
||||
passed: true,
|
||||
stale: false,
|
||||
shotId,
|
||||
revisionId: 'manual-child',
|
||||
fingerprint: 'f'.repeat(64),
|
||||
primaryKeyframeId: primary.id,
|
||||
primaryKeyframeImageUrl: primary.imageUrl,
|
||||
expectedRevisionId: null,
|
||||
validation: { passed: true },
|
||||
plan: { sourceFingerprint: 'c'.repeat(64), fingerprint: 'a'.repeat(64) }
|
||||
}
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/active')) {
|
||||
history.activeRevisionId = 'manual-child'
|
||||
return Response.json({
|
||||
data: {
|
||||
shotId,
|
||||
activeRevisionId: 'manual-child',
|
||||
motionPlanFingerprint: 'f'.repeat(64),
|
||||
changed: true,
|
||||
videoPromptStale: true
|
||||
}
|
||||
})
|
||||
}
|
||||
throw new Error('未模拟 ' + path)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
let state!: ReturnType<typeof useMotionRevision>
|
||||
const wrapper = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
state = useMotionRevision({ projectId, shotId }, ref(true), () => {})
|
||||
return () => h('div')
|
||||
}
|
||||
})
|
||||
)
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
return { state, history, candidate, fetcher, primary, projectId, shotId }
|
||||
}
|
||||
describe('失败动作候选只承接为人工子版本', () => {
|
||||
it('原Task/Workflow失败保留,预检/保存/起点/采用分别主动执行', async () => {
|
||||
const { state, fetcher, history, candidate } = await harness()
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
expect(state.requiresCandidate.value).toBe(true)
|
||||
state.failedTaskId.value = 'failed-task'
|
||||
await state.readCandidate()
|
||||
expect(state.draft.value.beats).toHaveLength(0)
|
||||
state.useCandidate()
|
||||
state.draft.value.beats[0]!.action = '人工修订为保持当前站姿后缓慢行走'
|
||||
state.reason.value = '只修订原失败动作,不改变身份与场景'
|
||||
await state.precheck()
|
||||
expect(state.preview.value?.startStateStatus).toBe('required_unknown')
|
||||
expect(state.canSave.value).toBe(false)
|
||||
state.failedAcknowledged.value = true
|
||||
await state.save()
|
||||
await flushPromises()
|
||||
const save = fetcher.mock.calls.find(
|
||||
([url, init]) => String(url).endsWith('/revisions') && init?.method === 'POST'
|
||||
)!
|
||||
expect(JSON.parse(String(save[1]?.body))).toMatchObject({
|
||||
parentRevisionId: null,
|
||||
failedCandidate: {
|
||||
taskId: 'failed-task',
|
||||
expectedSourceFingerprint: 'c'.repeat(64),
|
||||
expectedPreviewFingerprint: 'd'.repeat(64),
|
||||
acknowledgeFailedCandidate: true
|
||||
}
|
||||
})
|
||||
expect(history.originalRevisionId).toBeNull()
|
||||
expect(history.activeRevisionId).toBeNull()
|
||||
expect(history.revisions.map(row => row.source)).toEqual(['failed_candidate', 'manual'])
|
||||
expect(history.revisions[1]!.parentRevisionId).toBe('failed-root')
|
||||
expect(state.candidateOrigin.value?.taskId).toBe('failed-task')
|
||||
const preservedDraft = JSON.stringify(state.draft.value)
|
||||
state.failedCandidate.value = null
|
||||
await state.readOriginCandidate()
|
||||
expect(JSON.stringify(state.draft.value)).toBe(preservedDraft)
|
||||
expect(state.failedCandidate.value).toMatchObject({ executionId: 'failed-workflow' })
|
||||
expect(candidate.status).toBe('failed')
|
||||
expect(
|
||||
fetcher.mock.calls.some(([url]) => /start-state-validation|\/active$|\/video-prompt$/.test(String(url)))
|
||||
).toBe(false)
|
||||
state.acknowledged.value = true
|
||||
await state.validate()
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/start-state-validation/start'))).toBe(false)
|
||||
await state.precheck()
|
||||
state.acknowledged.value = true
|
||||
await state.validate()
|
||||
await flushPromises()
|
||||
const start = fetcher.mock.calls.find(([url]) => String(url).endsWith('/start-state-validation/start'))!
|
||||
expect(JSON.parse(String(start[1]?.body))).toEqual({
|
||||
primaryKeyframeId: state.context.data.value!.primary!.id,
|
||||
expectedRevisionId: null,
|
||||
expectedPlanFingerprint: 'a'.repeat(64)
|
||||
})
|
||||
expect(history.activeRevisionId).toBeNull()
|
||||
expect(state.canActivate.value).toBe(true)
|
||||
await state.activate()
|
||||
expect(history.activeRevisionId).toBe('manual-child')
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(1)
|
||||
})
|
||||
it('来源409保留人工草稿,不产生半个版本或自动重试', async () => {
|
||||
const { state, fetcher, history } = await harness(true)
|
||||
state.failedTaskId.value = 'failed-task'
|
||||
await state.readCandidate()
|
||||
state.useCandidate()
|
||||
state.draft.value.beats[0]!.action = '保留这份人工输入等待重新核对来源'
|
||||
state.reason.value = '只保存'
|
||||
await state.precheck()
|
||||
state.failedAcknowledged.value = true
|
||||
await state.save()
|
||||
expect(state.draft.value.beats[0]!.action).toBe('保留这份人工输入等待重新核对来源')
|
||||
expect(state.preview.value).toBeNull()
|
||||
expect(history.revisions).toHaveLength(0)
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url, init]) => String(url).endsWith('/revisions') && init?.method === 'POST')
|
||||
).toHaveLength(1)
|
||||
})
|
||||
it('即便伪造通过的起点结果,failed_candidate根也不可直接采用', async () => {
|
||||
const { state, fetcher, primary } = await harness()
|
||||
state.failedTaskId.value = 'failed-task'
|
||||
await state.readCandidate()
|
||||
state.useCandidate()
|
||||
state.reason.value = '保存测试'
|
||||
await state.precheck()
|
||||
state.failedAcknowledged.value = true
|
||||
await state.save()
|
||||
const manual = state.revision.value!
|
||||
const execution: WorkflowExecution = {
|
||||
stage: null,
|
||||
current: 0,
|
||||
total: 0,
|
||||
currentResourceId: null,
|
||||
metadata: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-18T00:00:00Z',
|
||||
updatedAt: '2026-11-18T00:00:00Z',
|
||||
id: 'e',
|
||||
projectId: 'p',
|
||||
workflowName: 'motion-plan-start-state-validation',
|
||||
status: 'completed',
|
||||
result: {
|
||||
passed: true,
|
||||
stale: false,
|
||||
validation: { passed: true },
|
||||
shotId: manual.shotId,
|
||||
revisionId: manual.revisionId,
|
||||
fingerprint: manual.fingerprint,
|
||||
primaryKeyframeId: primary.id,
|
||||
primaryKeyframeImageUrl: primary.imageUrl,
|
||||
expectedRevisionId: null
|
||||
}
|
||||
}
|
||||
expect(motionEvidenceCurrent(execution, { ...manual, source: 'failed_candidate' }, primary, null)).toBe(false)
|
||||
state.select('failed-root')
|
||||
await state.precheck()
|
||||
expect(state.canValidate.value).toBe(false)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/active'))).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -89,7 +89,11 @@ describe('动作修订激活证据', () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await motionApi.previewRevision('s/1', revision.motionPlan)
|
||||
await motionApi.saveRevision('s/1', { motionPlan: revision.motionPlan, parentRevisionId: null, reason: null })
|
||||
await motionApi.validateRevision('s/1', 'r/1', { primaryKeyframeId: primary.id, expectedRevisionId: null })
|
||||
await motionApi.validateRevision('s/1', 'r/1', {
|
||||
primaryKeyframeId: primary.id,
|
||||
expectedRevisionId: null,
|
||||
expectedPlanFingerprint: 'a'.repeat(64)
|
||||
})
|
||||
await motionApi.activateRevision('s/1', 'r/1', { expectedRevisionId: null, validationExecutionId: 'e1' })
|
||||
const calls = fetcher.mock.calls
|
||||
expect(calls.map(([url]) => url)).toEqual([
|
||||
@@ -105,7 +109,8 @@ describe('动作修订激活证据', () => {
|
||||
})
|
||||
expect(JSON.parse(String(calls[2]?.[1]?.body))).toEqual({
|
||||
primaryKeyframeId: primary.id,
|
||||
expectedRevisionId: null
|
||||
expectedRevisionId: null,
|
||||
expectedPlanFingerprint: 'a'.repeat(64)
|
||||
})
|
||||
expect(JSON.parse(String(calls[3]?.[1]?.body))).toEqual({
|
||||
expectedRevisionId: null,
|
||||
|
||||
Reference in new issue
Block a user