Files
short-drama-agent-front/src/testing/project-context.ts
T

43 lines
1.7 KiB
TypeScript

import { computed, ref } from 'vue'
import { vi } from 'vitest'
import type { ProjectDetail, ProjectStageReadiness } from '../features/projects/types'
import type { Checkpoint } from '../features/workflows/types'
import type { useProjectData } from '../features/projects/context'
/** 模拟正式项目上下文,测试不连接真实模型或数据库。 */
export function testProjectContext(id = 'capability-test'): ReturnType<typeof useProjectData> {
const project: ProjectDetail = {
id,
title: '测试剧本',
topic: '测试',
style: '写实',
status: 'completed',
createdAt: '2026-09-01T00:00:00Z',
updatedAt: '2026-09-01T00:00:00Z',
episodes: [{ episode: 1, title: '第一集', content: '内容' }],
characters: [],
world: null
}
const stageReadiness: ProjectStageReadiness = {
projectId: id,
script: { ready: true, reason: null },
breakdown: { ready: true, reason: null },
visualStyle: { ready: true, reason: null },
identity: { ready: true, reason: null },
subjectAssets: { ready: true, reason: null },
storyboard: { ready: true, reason: null }
}
const data = ref({ project, checkpoints: [] as Checkpoint[], stageReadiness })
return {
data,
project: computed(() => data.value.project),
checkpoints: computed(() => data.value.checkpoints),
stageReadiness: computed(() => data.value.stageReadiness),
loading: ref(false),
error: ref(''),
updatedAt: ref(''),
refresh: vi.fn<() => Promise<void>>().mockResolvedValue(),
refreshStageReadiness: vi.fn<() => Promise<void>>().mockResolvedValue()
}
}