接入动作时间轴、密度审计、人工视线目标和后台首帧编辑;独立读取已保存提示词,并在首帧晋升前重新核对持久化质量状态。 统一 NMessage 结果反馈、局部 loading 和业务说明间距,保留真实长任务进度与部分失败语义。 验证:pnpm check(49 个文件、393 项测试)、pnpm build;当前环境无法完成 localhost 浏览器验收及真实后端联调。
108 lines
3.9 KiB
TypeScript
108 lines
3.9 KiB
TypeScript
import { afterEach, expect, it, vi } from 'vitest'
|
|
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
|
import MotionPlanPanel from '@/features/storyboard/components/MotionPlanPanel.vue'
|
|
import MotionAuditPanel from '@/features/storyboard/components/MotionAuditPanel.vue'
|
|
import { motionApi } from '@/features/storyboard/motion-api'
|
|
import type { MotionPlanPreview } from '@/features/storyboard/motion.types'
|
|
|
|
let wrapper: VueWrapper | undefined
|
|
afterEach(() => {
|
|
wrapper?.unmount()
|
|
wrapper = undefined
|
|
vi.restoreAllMocks()
|
|
})
|
|
|
|
/**
|
|
* 构造已有动作事实,缺失历史审计不得被误报为历史通过。
|
|
* @param shotId 正式镜头标识
|
|
* @returns 只读动作详情
|
|
*/
|
|
function plan(shotId: string): MotionPlanPreview {
|
|
return {
|
|
shotId,
|
|
episodeNo: 1,
|
|
beatNo: 1,
|
|
shotNo: 1,
|
|
durationSeconds: 5,
|
|
motionPlanAvailable: true,
|
|
beats: [
|
|
{
|
|
startSecond: 0,
|
|
endSecond: 5,
|
|
action: `${shotId} 缓慢摇头`,
|
|
cameraMotion: '保持机位',
|
|
physicalContinuity: '握持农具',
|
|
subjectRefs: [],
|
|
closingState: '手停在腰侧'
|
|
}
|
|
],
|
|
globalMotionConstraints: [],
|
|
issues: [],
|
|
actionDensityIssues: [
|
|
{ code: 'slow_repeated_action', severity: 'warning', message: '当前复核线索', beatIndex: 0 }
|
|
],
|
|
actionReviewSuggestions: [
|
|
{
|
|
code: 'slow_repeated_action',
|
|
beatIndex: 0,
|
|
suggestions: ['保留自然运动节奏'],
|
|
requiresManualReview: true
|
|
}
|
|
],
|
|
savedActionDensityIssues: null,
|
|
willCallModel: false,
|
|
willModifyAssets: false
|
|
}
|
|
}
|
|
|
|
it('切镜取消旧请求,迟到动作不覆盖新镜头,缺失历史不显示通过', async () => {
|
|
let finish!: (value: MotionPlanPreview) => void
|
|
const preview = vi
|
|
.spyOn(motionApi, 'preview')
|
|
.mockImplementationOnce(
|
|
() =>
|
|
new Promise(resolve => {
|
|
finish = resolve
|
|
})
|
|
)
|
|
.mockImplementation(async shotId => plan(shotId))
|
|
wrapper = mount(MotionPlanPanel, { props: { shotId: 'old' } })
|
|
await wrapper.setProps({ shotId: 'new' })
|
|
await flushPromises()
|
|
expect(preview.mock.calls[0]?.[1]?.aborted).toBe(true)
|
|
finish(plan('old'))
|
|
await flushPromises()
|
|
expect(wrapper.text()).toContain('new 缓慢摇头')
|
|
expect(wrapper.text()).not.toContain('old 缓慢摇头')
|
|
expect(wrapper.text()).toContain('未保存生成时审计记录')
|
|
expect(wrapper.text()).toContain('需人工复核')
|
|
expect(wrapper.text()).not.toContain('质量未通过')
|
|
})
|
|
|
|
it('项目审计按需读取,时间轴和密度独立计数并用正式 ID 定位', async () => {
|
|
const item = {
|
|
...plan('saved-shot'),
|
|
issues: [{ code: 'timeline_gap', severity: 'warning' as const, message: '未覆盖时间' }]
|
|
}
|
|
const audit = vi.spyOn(motionApi, 'audit').mockResolvedValue({
|
|
projectId: 'project',
|
|
shotCount: 1,
|
|
auditedCount: 1,
|
|
missingMotionPlanCount: 0,
|
|
warningCount: 1,
|
|
actionDensityWarningCount: 1,
|
|
items: [item],
|
|
willCallModel: false,
|
|
willModifyAssets: false
|
|
})
|
|
wrapper = mount(MotionAuditPanel, { props: { projectId: 'project' } })
|
|
expect(audit).not.toHaveBeenCalled()
|
|
await wrapper.get('button').trigger('click')
|
|
await flushPromises()
|
|
expect(wrapper.text()).toContain('时间轴预警 1')
|
|
expect(wrapper.text()).toContain('动作密度预警 1')
|
|
const locate = wrapper.findAll('button').find(button => button.text() === '查看镜头')!
|
|
await locate.trigger('click')
|
|
expect(wrapper.emitted('locate')?.[0]?.[0]).toMatchObject({ shotId: 'saved-shot', episodeNo: 1 })
|
|
})
|