feat(short-drama-agent-front): 接入首帧授权与连续性审核
This commit is contained in:
1 parent
dbf97e6f98
commit
518b630a46
35 files changed
+3070
-97
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { continuityApi, continuitySelectionValid, validObservation } from '@/features/production/continuity'
|
||||
import { layoutApi } from '@/features/production/layout-api'
|
||||
|
||||
/** 隔离正式 HTTP 契约,所有请求由 Mock 接收。 */
|
||||
const fetcher = vi.fn<typeof fetch>(async () => new Response(JSON.stringify({ data: {} })))
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
describe('固定几何诊断与正式保存契约', () => {
|
||||
it('只接受正式顺序连续的两到三镜,不跨间隔或重复', () => {
|
||||
expect(continuitySelectionValid(['a', 'b'], ['a', 'b', 'c', 'd'])).toBe(true)
|
||||
expect(continuitySelectionValid(['a', 'c'], ['a', 'b', 'c', 'd'])).toBe(false)
|
||||
expect(continuitySelectionValid(['b', 'a'], ['a', 'b', 'c'])).toBe(false)
|
||||
expect(continuitySelectionValid(['a', 'a'], ['a', 'b'])).toBe(false)
|
||||
})
|
||||
it('诊断、保存指纹及历史回读使用同项目的正式接口', async () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const observation = {
|
||||
expectedFingerprint: 'a'.repeat(64),
|
||||
landmarks: ['窗', '门'] as [string, string],
|
||||
frames: ['s1', 's2'].map(shotId => ({
|
||||
shotId,
|
||||
view: 'same_side' as const,
|
||||
landmarkOrder: 'as_layout' as const,
|
||||
evidence: '当前图可见',
|
||||
features: [{ key: '铰链', side: 'left' as const, evidence: '连接处可见' }]
|
||||
}))
|
||||
}
|
||||
const input = { shotIds: ['s1', 's2'], sceneFormId: 'form', observation }
|
||||
await continuityApi.diagnose('p', input)
|
||||
await continuityApi.save('p', { ...input, reviewer: '审核人' })
|
||||
await continuityApi.review('p', 'review')
|
||||
expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([
|
||||
'/api/projects/p/storyboard-keyframes/continuity/diagnosis',
|
||||
'/api/projects/p/storyboard-keyframes/continuity/reviews',
|
||||
'/api/projects/p/storyboard-keyframes/continuity/reviews/review'
|
||||
])
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1]!.body as string).observation.expectedFingerprint).toBe(
|
||||
'a'.repeat(64)
|
||||
)
|
||||
expect(validObservation(observation, ['s1', 's2'])).toBe(true)
|
||||
expect(validObservation({ ...observation, landmarks: ['窗', '窗'] }, ['s1', 's2'])).toBe(false)
|
||||
})
|
||||
it('布局预览不混入摄影草案,正式确认使用原返回参数和真实确认人', async () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const supplement = {
|
||||
layoutId: 'layout',
|
||||
expectedVersion: 'b'.repeat(64),
|
||||
sceneSubjectId: 'scene',
|
||||
instruction: '远窗侧固定铰链',
|
||||
evidence: '人工确认'
|
||||
}
|
||||
await layoutApi.preview('p', 's', supplement)
|
||||
expect(JSON.parse(fetcher.mock.calls.at(-1)![1]!.body as string)).toEqual({ layoutSupplement: supplement })
|
||||
const confirmation = {
|
||||
name: '布局',
|
||||
sceneSubjectIds: ['scene'],
|
||||
constraints: [],
|
||||
evidence: '人工确认',
|
||||
expectedVersion: 'b'.repeat(64)
|
||||
}
|
||||
await layoutApi.confirm('p', confirmation, 'goujun')
|
||||
expect(JSON.parse(fetcher.mock.calls.at(-1)![1]!.body as string)).toEqual({
|
||||
...confirmation,
|
||||
confirmedBy: 'goujun'
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user