feat(short-drama-agent-front): 接入审核人工确认与延期验证
This commit is contained in:
1 parent
5836b90934
commit
c6ef595a8e
23 files changed
+3923
-67
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import { dramaReviewApi, loadDramaReview } from '@/features/create-drama/review/api'
|
||||
import { confirmationPreview, latestReview } from './fixtures'
|
||||
import type { DramaReviewPreview } from '@/features/create-drama/review/types'
|
||||
|
||||
describe('剧本恢复的明确确认契约', () => {
|
||||
it('正式审核的问题格式损坏时显示读取错误,不让页面因空问题对象崩溃', async () => {
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue({
|
||||
...latestReview(),
|
||||
qualityReview: { issues: [null], uncertainty: [] }
|
||||
} as unknown as ReturnType<typeof latestReview>)
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview())
|
||||
await expect(loadDramaReview('review-project')).rejects.toThrow('不完整')
|
||||
})
|
||||
it('预检数据格式异常时保留正式审核并阻止确认,不把原始错误当作问题列表', async () => {
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview())
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(),
|
||||
pendingQualityIssues: [null]
|
||||
} as unknown as DramaReviewPreview)
|
||||
const snapshot = await loadDramaReview('review-project')
|
||||
expect(snapshot.latest?.id).toBe('review-1')
|
||||
expect(snapshot.preview).toBeNull()
|
||||
expect(snapshot.previewError).toContain('不完整')
|
||||
})
|
||||
it('最新审核与预检版本不同不混合展示为可确认状态', async () => {
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview())
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({ ...confirmationPreview(), reviewId: 'another-review' })
|
||||
const snapshot = await loadDramaReview('review-project')
|
||||
expect(snapshot.preview).toBeNull()
|
||||
expect(snapshot.previewError).toContain('版本已变化')
|
||||
})
|
||||
it('恢复改写携带 confirmed,恢复生成不新增未约定参数', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(
|
||||
async () =>
|
||||
new Response(JSON.stringify({ data: { executionId: 'task', status: 'running' } }), { status: 202 })
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await projectsApi.resume('project/id', 'resume-rewrite')
|
||||
await projectsApi.resume('project/id', 'resume-generation')
|
||||
expect(fetcher.mock.calls[0]![0]).toBe('/api/projects/project%2Fid/resume-rewrite')
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]![1]!.body ?? 'null'))).toEqual({ confirmed: true })
|
||||
expect(fetcher.mock.calls[1]![1]!.body).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user