feat(short-drama-agent-front): 补齐后端生产与质量功能
This commit is contained in:
1 parent
967c4ebea1
commit
470b52e26d
52 files changed
+3754
-1075
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { afterEach, describe, expect, expectTypeOf, it, vi } from 'vitest'
|
||||
import { storyboardApi } from '@/features/storyboard/api'
|
||||
import { productionApi } from '@/features/production/api'
|
||||
import type { WorkflowExecutionStart } from '@/features/workflows/execution.types'
|
||||
|
||||
/** 清除网络替身,保证边界用例相互隔离。 */
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
/** 既有批处理入口只接收真实 202 句柄,不产生最终回执或重复请求。 */
|
||||
describe('既有生成入口异步契约', () => {
|
||||
it('所有启动入口返回202句柄并保留原请求范围', async () => {
|
||||
const start = { executionId: 'execution-1', status: 'running' as const }
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: start }), { status: 202 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const batch = { concurrency: 2, force: false }
|
||||
const calls = [
|
||||
storyboardApi.regenerateEpisodeShots('project-1', 3),
|
||||
storyboardApi.generateDirections('project-1', batch),
|
||||
storyboardApi.generateVisualStates('project-1', { ...batch, maxRepairAttempts: 2 }),
|
||||
storyboardApi.generatePrompts('project-1', batch),
|
||||
productionApi.generateKeyframes('project-1', { ...batch, episodeNo: 3, limit: 1 })
|
||||
]
|
||||
for (const result of await Promise.all(calls)) expect(result).toEqual(start)
|
||||
expect(fetcher).toHaveBeenCalledTimes(5)
|
||||
expect(fetcher.mock.calls[0]?.[1]?.body).toBe(JSON.stringify({ episodeNo: 3 }))
|
||||
expect(fetcher.mock.calls[4]?.[1]?.body).toBe(JSON.stringify({ ...batch, episodeNo: 3, limit: 1 }))
|
||||
})
|
||||
it('启动类型与最终批量回执严格分开', () => {
|
||||
expectTypeOf<
|
||||
Awaited<ReturnType<typeof storyboardApi.regenerateEpisodeShots>>
|
||||
>().toEqualTypeOf<WorkflowExecutionStart>()
|
||||
expectTypeOf<
|
||||
Awaited<ReturnType<typeof storyboardApi.generateDirections>>
|
||||
>().toEqualTypeOf<WorkflowExecutionStart>()
|
||||
expectTypeOf<
|
||||
Awaited<ReturnType<typeof storyboardApi.generateVisualStates>>
|
||||
>().toEqualTypeOf<WorkflowExecutionStart>()
|
||||
expectTypeOf<
|
||||
Awaited<ReturnType<typeof storyboardApi.generatePrompts>>
|
||||
>().toEqualTypeOf<WorkflowExecutionStart>()
|
||||
expectTypeOf<
|
||||
Awaited<ReturnType<typeof productionApi.generateKeyframes>>
|
||||
>().toEqualTypeOf<WorkflowExecutionStart>()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
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)
|
||||
})
|
||||
Reference in new issue
Block a user