Files

75 lines
2.8 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import StoryboardList from '@/features/breakdown/components/StoryboardList.vue'
import type { EpisodePlan, EpisodeShots } from '@/features/breakdown/types'
/** 一条不涉及实际服务的正式分镜,用于验证定位语义。 */
const plan: EpisodePlan = {
episodeNo: 1,
episodeTitle: '第一集',
storyGoal: '',
centralConflict: '',
emotionalArc: '',
pacing: '',
endingHook: '',
beats: [
{
beatNo: 1,
title: '场景',
purpose: 'establish',
description: '内容',
visualFocus: '',
narrativeGoal: '',
emotionalTone: '',
estimatedDurationSeconds: 5,
subjectRefs: [],
isKeyBeat: false
}
]
}
/** 当前正式镜头正文。 */
const episode: EpisodeShots = {
episodeNo: 1,
episodePlan: plan,
beatShots: [
{
beatNo: 1,
shots: [
{
shotNo: 1,
title: '无问题镜头',
description: '正文',
visualFocus: '',
subjectRefs: [],
durationSeconds: 5
}
]
}
]
}
let wrapper: VueWrapper | undefined
afterEach(() => {
wrapper?.unmount()
vi.restoreAllMocks()
})
describe('分镜定位与问题状态分离', () => {
it('只有从当前实际问题定位时使用错误标记,普通定位会清除旧错误标记', async () => {
wrapper = mount(StoryboardList, { props: { plans: [plan], episodes: [episode] } })
const target = wrapper.get('[data-shot-position="1-1-1"]')
await wrapper.getComponent(StoryboardList).vm.locate({ episodeNo: 1, beatNo: 1, shotNo: 1 }, { problem: true })
expect(target.classes()).toContain('diagnosis-problem-located')
await wrapper.getComponent(StoryboardList).vm.locate({ episodeNo: 1, beatNo: 1, shotNo: 1 })
expect(target.classes()).toContain('diagnosis-located')
expect(target.classes()).not.toContain('diagnosis-problem-located')
})
it('正式数据刷新后清除旧定位,不让已处理的问题继续标红', async () => {
wrapper = mount(StoryboardList, { props: { plans: [plan], episodes: [episode] } })
await wrapper.getComponent(StoryboardList).vm.locate({ episodeNo: 1, beatNo: 1, shotNo: 1 }, { problem: true })
await wrapper.setProps({ episodes: [structuredClone(episode)] })
await flushPromises()
expect(wrapper.find('.diagnosis-problem-located').exists()).toBe(false)
expect(wrapper.find('.diagnosis-located').exists()).toBe(false)
})
})