45 lines
2.0 KiB
TypeScript
45 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { actionDraft, actionDraftIssue } from '@/features/breakdown/repair'
|
|
import type { ShotActionDraft } from '@/features/breakdown/repair.types'
|
|
|
|
/** 含手部和身体资源证据的真实字段夹具。 */
|
|
const saved: ShotActionDraft = {
|
|
requiredActions: [{ id: 'a', description: '扶住栏杆', kind: 'action', mustPerformInShot: true }],
|
|
durationPlanning: {
|
|
complexity: 'low',
|
|
phases: [
|
|
{
|
|
action: '站稳',
|
|
actionIds: ['a'],
|
|
estimatedSeconds: 2,
|
|
handOccupancy: [{ actionId: 'a', characterRef: '@人物', hands: 'left' }],
|
|
resourceOccupancy: [
|
|
{ actionId: 'a', ownerRef: '@人物', resource: 'left_hand', usage: 'hold', shareable: false }
|
|
]
|
|
}
|
|
],
|
|
transitionSeconds: 0,
|
|
recommendedDurationSeconds: 2,
|
|
reason: '保持稳定'
|
|
}
|
|
}
|
|
describe('镜头动作修订草稿', () => {
|
|
it('完整保留证据且编辑草稿不污染源镜头', () => {
|
|
const draft = actionDraft(saved)
|
|
draft.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage = 'support'
|
|
expect(saved.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage).toBe('hold')
|
|
expect(draft.durationPlanning.phases[0]!.handOccupancy).toEqual(saved.durationPlanning.phases[0]!.handOccupancy)
|
|
expect(actionDraftIssue(draft)).toBe('')
|
|
})
|
|
it('拒绝失效的动作引用、重复编号和无效阶段时长', () => {
|
|
const draft = actionDraft(saved)
|
|
draft.requiredActions[0]!.id = 'changed'
|
|
expect(actionDraftIssue(draft)).toContain('引用')
|
|
draft.requiredActions.push({ ...draft.requiredActions[0]! })
|
|
expect(actionDraftIssue(draft)).toContain('编号')
|
|
draft.requiredActions = [{ ...saved.requiredActions[0]! }]
|
|
draft.durationPlanning.phases[0]!.estimatedSeconds = 0
|
|
expect(actionDraftIssue(draft)).toContain('时长')
|
|
})
|
|
})
|