Files

45 lines
2.2 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest'
/** 重载保护测试后清理本地标记,避免影响其它测试。 */
afterEach(() => localStorage.clear())
import { currentEpisodeSource, getStoryboardSession, mergeDesignedShots } from '@/features/storyboard/model'
import { directionsResult, episodeShots, visualStatesResult } from '@/features/storyboard/testing/fixtures'
describe('重生成后的正式镜头与旧正文隔离', () => {
it('新正式镜头仍可操作,但不能回填已失效的旧标题、剧情和时长', () => {
const projectId = 'regenerated-source-project'
const session = getStoryboardSession(projectId)
session.invalidatedEpisodeSources[1] = true
const directions = directionsResult(projectId, 1, false)
directions.beats[0]!.shots[0]!.shotId = 'new-shot-a'
directions.beats[1]!.shots[0]!.shotId = 'new-shot-b'
const rows = mergeDesignedShots(
directions,
visualStatesResult(projectId, 1, false),
currentEpisodeSource(projectId, 1, episodeShots())
)
expect(
rows
.filter(row => row.shotId.startsWith('new-shot'))
.map(row => [row.shotId, row.title, row.description, row.durationSeconds])
).toEqual([
['new-shot-a', '镜头 1', '', undefined],
['new-shot-b', '镜头 1', '', undefined]
])
})
})
it('两集先后重生成后,即使任务句柄被隐藏,重载仍恢复全部失效正文保护', async () => {
const module = await import('@/features/storyboard/model')
const projectId = 'multi-episode-reload-project'
module.invalidateEpisodeSource(projectId, 1)
module.invalidateEpisodeSource(projectId, 2)
localStorage.removeItem(`short-drama:workflow-execution:${projectId}:breakdown`)
vi.resetModules()
const restored = await import('@/features/storyboard/model')
expect(restored.currentEpisodeSource(projectId, 1, episodeShots(1))).toBeUndefined()
expect(restored.currentEpisodeSource(projectId, 2, episodeShots(2))).toBeUndefined()
restored.clearEpisodeSourceInvalidations(projectId)
expect(restored.currentEpisodeSource(projectId, 1, episodeShots(1))?.episodeNo).toBe(1)
})