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,74 @@
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { NTabs } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import CreateDramaPage from '@/features/create-drama/CreateDramaPage.vue'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
|
||||
/** 当前导航测试页面,审核业务由独立测试覆盖。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
/**
|
||||
* 挂载实际创作页面,隔离审核查询以只验证首次导航。
|
||||
* @param context 当前正式项目上下文
|
||||
* @returns 当前创作页面
|
||||
*/
|
||||
async function openGuidance(context: ReturnType<typeof testProjectContext>) {
|
||||
wrapper = mount(CreateDramaPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context }, stubs: { DramaReviewPanel: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
|
||||
describe('首次进入剧本创作的审核引导', () => {
|
||||
it('待审核项目首次进入直接显示审核记录,不自动打开确认或启动任务', async () => {
|
||||
const context = testProjectContext('guide-pending')
|
||||
context.data.value!.project.status = 'need_review'
|
||||
const page = await openGuidance(context)
|
||||
expect(page.getComponent(NTabs).props('value')).toBe('review')
|
||||
expect(page.find('drama-review-panel-stub').exists()).toBe(true)
|
||||
expect(document.querySelector('.app-drawer, .app-dialog')).toBeNull()
|
||||
})
|
||||
it('失败项目保留当前未通过审核时,引导到审核和改写入口', async () => {
|
||||
const context = testProjectContext('guide-rewrite')
|
||||
context.data.value!.project.status = 'failed'
|
||||
context.data.value!.checkpoints = [
|
||||
{
|
||||
checkpointId: 'rewrite-source',
|
||||
workflowName: 'create-drama',
|
||||
createdAt: '2026-10-28T00:00:00Z',
|
||||
state: { reviewPassed: false, review: { passed: false } }
|
||||
}
|
||||
]
|
||||
const page = await openGuidance(context)
|
||||
expect(page.getComponent(NTabs).props('value')).toBe('review')
|
||||
})
|
||||
it('用户切换到其它内容后,项目刷新不再次切回审核记录', async () => {
|
||||
const context = testProjectContext('guide-no-steal')
|
||||
context.data.value!.project.status = 'need_review'
|
||||
const page = await openGuidance(context)
|
||||
await page.getComponent(NTabs).vm.$emit('update:value', 'world')
|
||||
context.data.value = { ...context.data.value!, project: { ...context.project.value! } }
|
||||
await flushPromises()
|
||||
expect(page.getComponent(NTabs).props('value')).toBe('world')
|
||||
})
|
||||
it('完成或尚未进入审核的项目保留正文,切换项目时按新项目重新定位', async () => {
|
||||
const context = testProjectContext('guide-completed')
|
||||
const page = await openGuidance(context)
|
||||
expect(page.getComponent(NTabs).props('value')).toBe('episodes')
|
||||
context.data.value = {
|
||||
...context.data.value!,
|
||||
project: { ...context.project.value!, id: 'guide-other-project', status: 'need_review' }
|
||||
}
|
||||
await flushPromises()
|
||||
expect(page.getComponent(NTabs).props('value')).toBe('review')
|
||||
})
|
||||
})
|
||||
@@ -83,7 +83,7 @@ async function open(task: WorkflowExecution | null) {
|
||||
}
|
||||
wrapper = mount(CreateDramaPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context } }
|
||||
global: { provide: { [projectContextKey as symbol]: context }, stubs: { DramaReviewPanel: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
@@ -109,6 +109,24 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('故事规划创作进度与恢复', () => {
|
||||
it('人工审核已完成时,旧任务的待修订回执只作为历史记录展示', async () => {
|
||||
context = testProjectContext('manual-review-current-complete')
|
||||
context.data.value!.checkpoints = [
|
||||
checkpoint({ reviewPassed: true, review: { passed: true } }, 'manual-confirm')
|
||||
]
|
||||
const page = await open(
|
||||
execution(context.project.value!.id, {
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
result: { projectStatus: 'need_review' }
|
||||
})
|
||||
)
|
||||
const dialog = await openTask(page)
|
||||
expect(dialog.text()).toContain('当前剧本已完成审核')
|
||||
expect(dialog.text()).not.toContain('审核仍需处理')
|
||||
expect(dialog.text()).not.toContain('执行结束 · 待修订')
|
||||
expect(dialog.text()).toContain('历史执行记录')
|
||||
})
|
||||
it('页面仅保留摘要和入口,任务与恢复说明按需进入弹窗且操作都在固定底栏', async () => {
|
||||
context = testProjectContext('compact-task')
|
||||
context.data.value!.project.status = 'failed'
|
||||
@@ -240,10 +258,10 @@ describe('故事规划创作进度与恢复', () => {
|
||||
expect(page.get('[data-stage="generateStoryPlan"]').attributes('data-status')).toBe('completed')
|
||||
expect(page.get('[data-stage="generateEpisode"]').attributes('data-status')).toBeUndefined()
|
||||
expect(dialog.get('button[aria-label="恢复生成"]').attributes('disabled')).toBeUndefined()
|
||||
expect(dialog.get('button[aria-label="恢复改写"]').attributes('disabled')).toBeDefined()
|
||||
expect(dialog.get('button[aria-label="恢复改写"]').attributes('aria-haspopup')).toBe('dialog')
|
||||
})
|
||||
|
||||
it('派生设定失败且正式剧集已齐全时仍允许恢复生成,不误开恢复改写', async () => {
|
||||
it('派生设定失败仍允许恢复生成,改写入口先打开只读预检', async () => {
|
||||
context = testProjectContext('derive-failed')
|
||||
context.data.value!.project.status = 'failed'
|
||||
context.data.value!.checkpoints = [
|
||||
@@ -254,7 +272,7 @@ describe('故事规划创作进度与恢复', () => {
|
||||
expect(page.get('[data-stage="generateEpisode"]').attributes('data-status')).toBe('completed')
|
||||
expect(page.get('[data-stage="generateCharacter"]').attributes('data-status')).toBeUndefined()
|
||||
expect(dialog.get('button[aria-label="恢复生成"]').attributes('disabled')).toBeUndefined()
|
||||
expect(dialog.get('button[aria-label="恢复改写"]').attributes('disabled')).toBeDefined()
|
||||
expect(dialog.get('button[aria-label="恢复改写"]').attributes('aria-haspopup')).toBe('dialog')
|
||||
})
|
||||
|
||||
it('恢复期间不以旧保存记录或数据库设定把当前节点及审核标为完成', async () => {
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,203 @@
|
||||
import { effectScope, ref } from 'vue'
|
||||
import { flushPromises } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { useDramaReview } from '@/features/create-drama/review/useDramaReview'
|
||||
import { confirmationPreview, latestReview } from './fixtures'
|
||||
import type { ConfirmDramaIssuesResult } from '@/features/create-drama/review/types'
|
||||
|
||||
/** 当前测试拥有的组件作用域。 */
|
||||
let scope: ReturnType<typeof effectScope> | undefined
|
||||
afterEach(() => {
|
||||
scope?.stop()
|
||||
scope = undefined
|
||||
})
|
||||
|
||||
/**
|
||||
* 为真实裁决流程提供隔离的接口响应。
|
||||
* @param id 当前项目
|
||||
* @returns 流程与刷新回调
|
||||
*/
|
||||
async function createFlow(id: string) {
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
const changed = vi.fn<() => Promise<void>>().mockResolvedValue()
|
||||
scope = effectScope()
|
||||
const flow = scope.run(() => useDramaReview(ref(id), changed))!
|
||||
await flushPromises()
|
||||
return { flow, changed }
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造仍有改写问题的真实回执。
|
||||
* @param id 当前项目
|
||||
* @returns 裁决回执
|
||||
*/
|
||||
function receipt(id: string): ConfirmDramaIssuesResult {
|
||||
return {
|
||||
projectId: id,
|
||||
reviewId: 'review-1',
|
||||
checkpointId: 'confirmed-cp',
|
||||
confirmedEpisodes: [1],
|
||||
acceptedWarningIndexes: [2],
|
||||
acceptedUncertaintyIndexes: [1],
|
||||
remainingBlockers: 3,
|
||||
blockers: { pendingIssues: 1, uncertainty: 0, confirmedErrors: 1, affectedEpisodes: 1, contentSafety: 0 },
|
||||
finalized: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('人工确认审核问题', () => {
|
||||
it('项目切换发生在二次预检期间时,不把旧项目选择提交到任何项目', async () => {
|
||||
const id = 'review-project-switch'
|
||||
const project = ref(id)
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockImplementation(async value => latestReview(value))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
scope = effectScope()
|
||||
const flow = scope.run(() => useDramaReview(project, vi.fn<() => Promise<void>>().mockResolvedValue()))!
|
||||
await flushPromises()
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
let resolve!: (value: ReturnType<typeof confirmationPreview>) => void
|
||||
vi.mocked(dramaReviewApi.preview)
|
||||
.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise(done => {
|
||||
resolve = done
|
||||
})
|
||||
)
|
||||
.mockResolvedValue(confirmationPreview('another-project'))
|
||||
flow.editorOpen.value = true
|
||||
flow.selectedErrors.value = [1]
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
const action = flow.confirm()
|
||||
await flushPromises()
|
||||
project.value = 'another-project'
|
||||
await flushPromises()
|
||||
resolve(confirmationPreview(id))
|
||||
await action
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.editorOpen.value).toBe(false)
|
||||
})
|
||||
it('新的正式审核到达后不保留上一轮人工完成的成功回执', async () => {
|
||||
const id = 'review-receipt-stale'
|
||||
const { flow } = await createFlow(id)
|
||||
flow.receipt.value = { ...receipt(id), finalized: true }
|
||||
vi.mocked(dramaReviewApi.latest).mockResolvedValue({ ...latestReview(id), id: 'review-2' })
|
||||
vi.mocked(dramaReviewApi.preview).mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
reviewId: 'review-2',
|
||||
checkpointId: 'cp-new'
|
||||
})
|
||||
await flow.query.refresh()
|
||||
expect(flow.receipt.value).toBeNull()
|
||||
})
|
||||
it('人工核实的补充证据按完整错误结构提交,不丢失严重程度或原文', async () => {
|
||||
const id = 'review-manual-complete'
|
||||
const { flow } = await createFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm').mockResolvedValue(receipt(id))
|
||||
flow.editorOpen.value = true
|
||||
flow.addManual()
|
||||
Object.assign(flow.manualDrafts.value[0]!, {
|
||||
code: '动作衔接',
|
||||
sourceQuote: '林夏放下信件后打开房门。',
|
||||
message: '缺少动作过程',
|
||||
suggestion: '补齐动作'
|
||||
})
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(confirm.mock.calls[0]![1].manualIssues).toEqual([
|
||||
{
|
||||
episode: 1,
|
||||
category: 'action_continuity',
|
||||
code: '动作衔接',
|
||||
severity: 'error',
|
||||
sourceQuote: '林夏放下信件后打开房门。',
|
||||
message: '缺少动作过程',
|
||||
suggestion: '补齐动作',
|
||||
evidenceConfidence: 'explicit',
|
||||
policyException: false
|
||||
}
|
||||
])
|
||||
})
|
||||
it('提交原始索引、明确确认和当前审核编号,成功后重读且不自动改写或放行', async () => {
|
||||
const id = 'review-confirm-source'
|
||||
const { flow, changed } = await createFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm').mockResolvedValue(receipt(id))
|
||||
flow.editorOpen.value = true
|
||||
flow.selectedErrors.value = [1]
|
||||
flow.selectedWarnings.value = [2]
|
||||
flow.selectedUncertainty.value = [1]
|
||||
await flushPromises()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(confirm).toHaveBeenCalledWith(id, {
|
||||
confirmed: true,
|
||||
reviewId: 'review-1',
|
||||
issueIndexes: [1],
|
||||
acceptedWarningIndexes: [2],
|
||||
acceptedUncertaintyIndexes: [1]
|
||||
})
|
||||
expect(changed).toHaveBeenCalledOnce()
|
||||
expect(flow.receipt.value?.finalized).toBe(false)
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
})
|
||||
|
||||
it('预检来源变化后清除旧选择,不提交过期裁决', async () => {
|
||||
const id = 'review-source-change'
|
||||
const { flow } = await createFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
flow.editorOpen.value = true
|
||||
flow.selectedErrors.value = [1]
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
vi.mocked(dramaReviewApi.preview).mockResolvedValue({ ...confirmationPreview(id), checkpointId: 'new-cp' })
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.actionError.value).toContain('已变化')
|
||||
expect(flow.selectedErrors.value).toEqual([])
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
})
|
||||
|
||||
it('没有人工勾选或原文不匹配时不发送任何确认', async () => {
|
||||
const id = 'review-manual-validation'
|
||||
const { flow } = await createFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
flow.editorOpen.value = true
|
||||
flow.addManual()
|
||||
Object.assign(flow.manualDrafts.value[0]!, {
|
||||
code: '动作衔接',
|
||||
sourceQuote: '不存在的原文',
|
||||
message: '缺少动作',
|
||||
suggestion: '补齐动作'
|
||||
})
|
||||
await flushPromises()
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.manualErrors.value[0]).toContain('原文')
|
||||
flow.removeManual(flow.manualDrafts.value[0]!.id)
|
||||
await flushPromises()
|
||||
expect(flow.actionError.value).toBe('')
|
||||
})
|
||||
|
||||
it('后端明确 finalized 才展示完成,不凭阻断计数归零自行通过', async () => {
|
||||
const id = 'review-finalized'
|
||||
const { flow } = await createFlow(id)
|
||||
vi.spyOn(dramaReviewApi, 'confirm').mockResolvedValue({
|
||||
...receipt(id),
|
||||
remainingBlockers: 0,
|
||||
finalized: false
|
||||
})
|
||||
flow.editorOpen.value = true
|
||||
flow.selectedUncertainty.value = [1]
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(flow.receipt.value?.finalized).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,172 @@
|
||||
import { effectScope, ref } from 'vue'
|
||||
import { flushPromises } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { useDramaReview } from '@/features/create-drama/review/useDramaReview'
|
||||
import { ApiError } from '@/lib/http'
|
||||
import { latestReview, suggestedPreview } from './fixtures'
|
||||
import type { ConfirmDramaIssuesResult } from '@/features/create-drama/review/types'
|
||||
|
||||
/** 当前测试作用域,不连接真实数据。 */
|
||||
let scope: ReturnType<typeof effectScope> | undefined
|
||||
afterEach(() => {
|
||||
scope?.stop()
|
||||
scope = undefined
|
||||
})
|
||||
|
||||
/**
|
||||
* 为真实人工选择逻辑提供包含建议的隔离预检。
|
||||
* @param id 正式测试项目
|
||||
* @returns 当前人工确认流程
|
||||
*/
|
||||
async function resolutionFlow(id: string) {
|
||||
const preview = suggestedPreview(id)
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue({
|
||||
...latestReview(id),
|
||||
pendingQualityIssues: [],
|
||||
qualityReview: { issues: [], uncertainty: preview.uncertainty }
|
||||
})
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(preview)
|
||||
scope = effectScope()
|
||||
const flow = scope.run(() => useDramaReview(ref(id), vi.fn<() => Promise<void>>().mockResolvedValue()))!
|
||||
await flushPromises()
|
||||
flow.editorOpen.value = true
|
||||
await flushPromises()
|
||||
return flow
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回仍有待处理事项的正式结构回执。
|
||||
* @param id 正式测试项目
|
||||
* @returns 人工确认回执
|
||||
*/
|
||||
function result(id: string): ConfirmDramaIssuesResult {
|
||||
return {
|
||||
projectId: id,
|
||||
reviewId: 'review-1',
|
||||
checkpointId: 'cp-saved',
|
||||
confirmedEpisodes: [],
|
||||
acceptedWarningIndexes: [],
|
||||
acceptedUncertaintyIndexes: [2],
|
||||
remainingBlockers: 1,
|
||||
blockers: { pendingIssues: 0, uncertainty: 1, confirmedErrors: 0, affectedEpisodes: 0, contentSafety: 0 },
|
||||
finalized: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('延期验证的明确人工选择', () => {
|
||||
it('读取建议不会自动接受或创建延期草稿,manual_review 默认保留待处理', async () => {
|
||||
const flow = await resolutionFlow('defer-no-auto')
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
expect(flow.deferredDrafts.value).toEqual({})
|
||||
expect(flow.selectedUncertainty.value).toEqual([])
|
||||
expect(flow.selectionCount.value).toBe(0)
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
})
|
||||
it('明确选集后可同时提交接受和延期,使用原始索引与用户修改的要求', async () => {
|
||||
const id = 'defer-payload'
|
||||
const flow = await resolutionFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm').mockResolvedValue(result(id))
|
||||
flow.setUncertaintyAction(0, 'defer')
|
||||
flow.setUncertaintyAction(1, 'defer')
|
||||
flow.setUncertaintyAction(2, 'accept')
|
||||
expect(flow.deferredDrafts.value[0]!.episode).toBeNull()
|
||||
flow.deferredDrafts.value[0]!.episode = 2
|
||||
flow.deferredDrafts.value[0]!.verificationCriteria = '用户核对后的空间要求。'
|
||||
flow.deferredDrafts.value[1]!.episode = 3
|
||||
flow.deferredDrafts.value[1]!.verificationTarget = 'breakdown'
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(confirm.mock.calls[0]![1]).toEqual({
|
||||
confirmed: true,
|
||||
reviewId: 'review-1',
|
||||
issueIndexes: [],
|
||||
acceptedWarningIndexes: [],
|
||||
acceptedUncertaintyIndexes: [2],
|
||||
deferredUncertainties: [
|
||||
{
|
||||
index: 0,
|
||||
episode: 2,
|
||||
verificationTarget: 'storyboard',
|
||||
verificationCriteria: '用户核对后的空间要求。'
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
episode: 3,
|
||||
verificationTarget: 'breakdown',
|
||||
verificationCriteria: '核对空间关系与动作连续性。'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
it('必须选集且标准非空,不完整时不发送请求并保留当前草稿', async () => {
|
||||
const flow = await resolutionFlow('defer-required')
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
flow.setUncertaintyAction(0, 'defer')
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(flow.deferredErrors.value[0]).toContain('剧集')
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.deferredDrafts.value[0]!.verificationCriteria).toBe('核对空间关系与动作连续性。')
|
||||
flow.deferredDrafts.value[0]!.episode = 2
|
||||
flow.deferredDrafts.value[0]!.verificationCriteria = ' '
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(flow.deferredErrors.value[0]).toContain('标准')
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
})
|
||||
it('同一原始问题不能同时接受和延期', async () => {
|
||||
const flow = await resolutionFlow('defer-overlap')
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
flow.setUncertaintyAction(0, 'defer')
|
||||
flow.deferredDrafts.value[0]!.episode = 2
|
||||
flow.selectedUncertainty.value = [0]
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.actionError.value).toContain('不能同时')
|
||||
})
|
||||
it('提交失败且来源未变时保留选项、集号、阶段和编辑标准', async () => {
|
||||
const id = 'defer-retained'
|
||||
const flow = await resolutionFlow(id)
|
||||
vi.spyOn(dramaReviewApi, 'confirm').mockRejectedValue(new ApiError('核验要求需修正', 409))
|
||||
flow.setUncertaintyAction(0, 'defer')
|
||||
Object.assign(flow.deferredDrafts.value[0]!, {
|
||||
episode: 3,
|
||||
verificationTarget: 'breakdown',
|
||||
verificationCriteria: '保留用户编辑的标准。'
|
||||
})
|
||||
flow.setUncertaintyAction(2, 'accept')
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
await flow.confirm()
|
||||
expect(flow.deferredDrafts.value[0]).toEqual({
|
||||
index: 0,
|
||||
episode: 3,
|
||||
verificationTarget: 'breakdown',
|
||||
verificationCriteria: '保留用户编辑的标准。'
|
||||
})
|
||||
expect(flow.selectedUncertainty.value).toEqual([2])
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
})
|
||||
it('来源变化不提交旧选择,并保留旧草稿供重新核对', async () => {
|
||||
const id = 'defer-new-source'
|
||||
const flow = await resolutionFlow(id)
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
flow.setUncertaintyAction(0, 'defer')
|
||||
flow.deferredDrafts.value[0]!.episode = 2
|
||||
await flushPromises()
|
||||
flow.acknowledged.value = true
|
||||
vi.mocked(dramaReviewApi.preview).mockResolvedValue({ ...suggestedPreview(id), checkpointId: 'changed' })
|
||||
await flow.confirm()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(flow.deferredDrafts.value).toEqual({})
|
||||
expect(flow.preservedDraft.value?.reviewId).toBe('review-1')
|
||||
expect(flow.preservedDraft.value?.deferredUncertainties[0]?.episode).toBe(2)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,132 @@
|
||||
import type {
|
||||
DramaReviewIssue,
|
||||
DramaReviewPreview,
|
||||
DramaRewritePreview,
|
||||
LatestDramaReview
|
||||
} from '@/features/create-drama/review/types'
|
||||
|
||||
/**
|
||||
* 构造真实结构化问题字段。
|
||||
* @param overrides 当前问题差异
|
||||
* @returns 完整问题
|
||||
*/
|
||||
export function reviewIssue(overrides: Partial<DramaReviewIssue> = {}): DramaReviewIssue {
|
||||
return {
|
||||
episode: 1,
|
||||
category: 'action_continuity',
|
||||
code: 'fall_support',
|
||||
severity: 'error',
|
||||
sourceQuote: '林夏放下信件后打开房门。',
|
||||
message: '动作承接需要核对',
|
||||
suggestion: '补齐必要的动作过程',
|
||||
policyException: false,
|
||||
evidenceConfidence: 'explicit',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造最新审核。
|
||||
* @param id 正式项目编号
|
||||
* @returns 真实最新审核回执
|
||||
*/
|
||||
export function latestReview(id = 'review-project'): LatestDramaReview {
|
||||
return {
|
||||
id: 'review-1',
|
||||
projectId: id,
|
||||
passed: false,
|
||||
message: '有待核对的剧本问题。',
|
||||
createdAt: '2026-10-28T00:00:00Z',
|
||||
qualityReview: { issues: [], uncertainty: ['空间信息尚未说明', '动作过程尚待核对'] },
|
||||
pendingQualityIssues: [
|
||||
reviewIssue({ severity: 'warning', code: 'warning-old' }),
|
||||
reviewIssue(),
|
||||
reviewIssue({ episode: 2, severity: 'warning', code: 'warning-current' })
|
||||
],
|
||||
manualUncertaintyDecisions: [],
|
||||
affectedEpisodes: [],
|
||||
hitWords: []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造多轮裁决后的预检,保留原始索引。
|
||||
* @param id 正式项目编号
|
||||
* @returns 完整只读预检
|
||||
*/
|
||||
export function confirmationPreview(id = 'review-project'): DramaReviewPreview {
|
||||
const review = latestReview(id)
|
||||
return {
|
||||
projectId: id,
|
||||
reviewId: review.id,
|
||||
checkpointId: 'cp-1',
|
||||
readOnly: true,
|
||||
ready: true,
|
||||
sourceValid: true,
|
||||
reviewSourceValid: true,
|
||||
hasActiveExecution: false,
|
||||
pendingQualityIssues: review.pendingQualityIssues,
|
||||
uncertainty: review.qualityReview!.uncertainty,
|
||||
remainingPendingQualityIssues: review.pendingQualityIssues.slice(1),
|
||||
remainingUncertainty: ['动作过程尚待核对'],
|
||||
confirmedRewriteEpisodes: [],
|
||||
episodes: [
|
||||
{ episode: 1, content: '林夏放下信件后打开房门。随后走入院中。' },
|
||||
{ episode: 2, content: '林夏放下信件后打开房门。另一人走来。' }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造真实改写范围。
|
||||
* @param id 正式项目编号
|
||||
* @returns 只读改写预检
|
||||
*/
|
||||
export function rewritePreview(id = 'review-project'): DramaRewritePreview {
|
||||
return {
|
||||
projectId: id,
|
||||
checkpointId: 'cp-1',
|
||||
readOnly: true,
|
||||
ready: true,
|
||||
status: 'ready',
|
||||
episodeNumbers: [1, 2],
|
||||
rewriteCharacters: false,
|
||||
rewriteWorld: false,
|
||||
rewriteEpisodes: true,
|
||||
requiresConfirmation: true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造带多集候选的建议预检,所有建议尚未被人工采用。
|
||||
* @param id 正式项目编号
|
||||
* @returns 包含三种待处理说明与建议的预检
|
||||
*/
|
||||
export function suggestedPreview(id = 'suggestion-project'): DramaReviewPreview {
|
||||
const descriptions = [
|
||||
'铜铃与木凳的空间关系需要在画面中核对',
|
||||
'人物站位与动作接触关系需要核对',
|
||||
'第二、三集的重复对白需人工确认'
|
||||
]
|
||||
return {
|
||||
...confirmationPreview(id),
|
||||
pendingQualityIssues: [],
|
||||
remainingPendingQualityIssues: [],
|
||||
uncertainty: descriptions,
|
||||
remainingUncertainty: descriptions,
|
||||
episodes: [1, 2, 3].map(episode => ({ episode, content: `第${episode}集正式正文。` })),
|
||||
resolutionSuggestions: descriptions.map((description, index) => ({
|
||||
index,
|
||||
description,
|
||||
suggestedAction: index < 2 ? 'defer' : 'manual_review',
|
||||
requiresEpisodeSelection: index < 2,
|
||||
requiresManualConfirmation: true,
|
||||
episode: null,
|
||||
episodeCandidates: index === 0 ? [1, 2, 3] : [2, 3],
|
||||
confidence: 'none',
|
||||
verificationTarget: index < 2 ? 'storyboard' : null,
|
||||
verificationCriteria: index < 2 ? '核对空间关系与动作连续性。' : null,
|
||||
reason: index < 2 ? '涉及多集视觉问题,需人工选集' : '需人工核对跨集叙事'
|
||||
}))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
indexedPendingIssues,
|
||||
indexedUncertainties,
|
||||
sameReviewSource,
|
||||
sameRewriteScope,
|
||||
manualIssueError
|
||||
} from '@/features/create-drama/review/model'
|
||||
import { confirmationPreview, rewritePreview } from './fixtures'
|
||||
|
||||
describe('审核原始索引与来源保护', () => {
|
||||
it('已接受第一项后,分组排序仍提交原始问题和不确定项索引', () => {
|
||||
const preview = confirmationPreview()
|
||||
expect(indexedPendingIssues(preview).map(row => row.originalIndex)).toEqual([1, 2])
|
||||
expect(indexedUncertainties(preview).map(row => row.originalIndex)).toEqual([1])
|
||||
})
|
||||
it('剩余列表缺失时不伪造已处理结果', () => {
|
||||
const preview = confirmationPreview()
|
||||
delete preview.remainingPendingQualityIssues
|
||||
delete preview.remainingUncertainty
|
||||
expect(indexedPendingIssues(preview).map(row => row.originalIndex)).toEqual([0, 1, 2])
|
||||
expect(indexedUncertainties(preview).map(row => row.originalIndex)).toEqual([0, 1])
|
||||
})
|
||||
it('审核、保存记录或正式正文变化都使本次选择失效', () => {
|
||||
const preview = confirmationPreview()
|
||||
expect(sameReviewSource(preview, structuredClone(preview))).toBe(true)
|
||||
expect(sameReviewSource(preview, { ...preview, checkpointId: 'cp-new' })).toBe(false)
|
||||
expect(sameReviewSource(preview, { ...preview, reviewId: 'review-new' })).toBe(false)
|
||||
expect(sameReviewSource(preview, { ...preview, episodes: [{ episode: 1, content: '正文已变化' }] })).toBe(false)
|
||||
})
|
||||
it('保存记录或改写范围变化必须重新确认,集号顺序变化不视为范围变化', () => {
|
||||
const preview = rewritePreview()
|
||||
expect(sameRewriteScope(preview, { ...preview, episodeNumbers: [2, 1] })).toBe(true)
|
||||
expect(sameRewriteScope(preview, { ...preview, checkpointId: 'new' })).toBe(false)
|
||||
expect(sameRewriteScope(preview, { ...preview, rewriteWorld: true })).toBe(false)
|
||||
expect(sameRewriteScope(preview, { ...preview, episodeNumbers: [1] })).toBe(false)
|
||||
})
|
||||
it('人工补充必须填写真实集号、逐字引用、说明和建议', () => {
|
||||
const draft = {
|
||||
id: 'draft',
|
||||
episode: 1,
|
||||
category: 'action_continuity' as const,
|
||||
code: '动作衔接',
|
||||
sourceQuote: '不存在的引用',
|
||||
message: '核对动作',
|
||||
suggestion: '补齐动作',
|
||||
subjectRef: ''
|
||||
}
|
||||
expect(manualIssueError(draft, confirmationPreview().episodes)).toContain('原文')
|
||||
expect(
|
||||
manualIssueError({ ...draft, sourceQuote: '林夏放下信件后打开房门。' }, confirmationPreview().episodes)
|
||||
).toBe('')
|
||||
expect(manualIssueError({ ...draft, episode: 9 }, confirmationPreview().episodes)).toContain('剧集')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,400 @@
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NButton, NCheckbox, NTag } from 'naive-ui'
|
||||
import DramaReviewPanel from '@/features/create-drama/review/DramaReviewPanel.vue'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { confirmationPreview, latestReview, rewritePreview } from './fixtures'
|
||||
|
||||
/** 当前审核页面。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
beforeEach(() => {
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview').mockImplementation(async id => ({
|
||||
...rewritePreview(id),
|
||||
ready: false,
|
||||
status: 'needs_review',
|
||||
episodeNumbers: [],
|
||||
rewriteEpisodes: false
|
||||
}))
|
||||
})
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
describe('审核记录中的人工问题处理', () => {
|
||||
it.each([
|
||||
{
|
||||
episodes: [],
|
||||
title: '请先核对审核问题',
|
||||
description: '点击“人工确认”对照原文逐项处理',
|
||||
actions: [['人工确认', 'primary']]
|
||||
},
|
||||
{
|
||||
episodes: [2],
|
||||
title: '已有改写依据,请检查改写范围',
|
||||
description: '第 2 集已有改写依据',
|
||||
actions: [
|
||||
['人工确认', 'default'],
|
||||
['改写预检', 'primary']
|
||||
]
|
||||
}
|
||||
])('显示当前审核的下一步引导:$title', async ({ episodes, title, description, actions }) => {
|
||||
const id = `review-guidance-${episodes.length}`
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
confirmedRewriteEpisodes: episodes
|
||||
})
|
||||
vi.mocked(dramaReviewApi.rewritePreview).mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
ready: episodes.length > 0,
|
||||
status: episodes.length ? 'ready' : 'needs_review',
|
||||
episodeNumbers: episodes,
|
||||
rewriteEpisodes: episodes.length > 0
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain(title)
|
||||
expect(wrapper.text()).toContain(description)
|
||||
const entries = wrapper
|
||||
.findAllComponents(NButton)
|
||||
.filter(button => ['人工确认', '改写预检'].includes(button.attributes('aria-label') ?? ''))
|
||||
const refresh = wrapper.findAllComponents(NButton).find(button => button.text() === '刷新审核')!
|
||||
expect(entries.map(button => [button.attributes('aria-label'), button.props('type')])).toEqual(actions)
|
||||
expect(refresh.props('type')).toBe('default')
|
||||
expect(document.querySelector('.app-drawer, .app-dialog')).toBeNull()
|
||||
})
|
||||
it.each([
|
||||
{ name: '仅需改写', targets: [2], passed: false, actions: ['改写预检'] },
|
||||
{ name: '没有可处理事项', targets: [], passed: false, actions: [] },
|
||||
{ name: '审核已通过', targets: [], passed: true, actions: [] }
|
||||
])('$name 时只显示实际存在的入口', async ({ name, targets, passed, actions }) => {
|
||||
const id = `review-visible-${name}`
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue({ ...latestReview(id), passed })
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
confirmedRewriteEpisodes: targets,
|
||||
remainingPendingQualityIssues: [],
|
||||
remainingUncertainty: []
|
||||
})
|
||||
vi.mocked(dramaReviewApi.rewritePreview).mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
ready: targets.length > 0,
|
||||
status: targets.length ? 'ready' : 'needs_review',
|
||||
episodeNumbers: targets,
|
||||
rewriteEpisodes: targets.length > 0
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
const entries = wrapper
|
||||
.findAllComponents(NButton)
|
||||
.map(button => button.attributes('aria-label'))
|
||||
.filter(label => ['人工确认', '改写预检'].includes(label ?? ''))
|
||||
expect(entries).toEqual(actions)
|
||||
expect(wrapper.findAllComponents(NButton).some(button => button.text() === '刷新审核')).toBe(true)
|
||||
expect(wrapper.text()).not.toContain('待确认问题仍可继续人工处理')
|
||||
})
|
||||
it('角色或世界观单独改写没有集号时,仍按真实改写预检显示入口', async () => {
|
||||
const id = 'review-visible-world-rewrite'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
confirmedRewriteEpisodes: [],
|
||||
remainingPendingQualityIssues: [],
|
||||
remainingUncertainty: []
|
||||
})
|
||||
vi.mocked(dramaReviewApi.rewritePreview).mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
episodeNumbers: [],
|
||||
rewriteEpisodes: false,
|
||||
rewriteWorld: true
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
const entries = wrapper
|
||||
.findAllComponents(NButton)
|
||||
.filter(button => ['人工确认', '改写预检'].includes(button.attributes('aria-label') ?? ''))
|
||||
expect(entries.map(button => [button.attributes('aria-label'), button.props('type')])).toEqual([
|
||||
['改写预检', 'primary']
|
||||
])
|
||||
expect(wrapper.text()).toContain('世界观')
|
||||
})
|
||||
it('改写预检与当前审核保存记录不一致时隐藏旧范围并允许刷新', async () => {
|
||||
const id = 'review-visible-stale-rewrite'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
vi.mocked(dramaReviewApi.rewritePreview).mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
checkpointId: 'another-checkpoint'
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('button[aria-label="改写预检"]').exists()).toBe(false)
|
||||
expect(wrapper.text()).toContain('保存记录已变化')
|
||||
expect(
|
||||
wrapper
|
||||
.findAllComponents(NButton)
|
||||
.find(button => button.text() === '刷新审核')!
|
||||
.props('disabled')
|
||||
).toBe(false)
|
||||
})
|
||||
it('预检读取失败时不展示没有当前依据的处理入口', async () => {
|
||||
const id = 'review-visible-preview-error'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockRejectedValue(new Error('预检读取失败'))
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('button[aria-label="人工确认"]').exists()).toBe(false)
|
||||
expect(wrapper.find('button[aria-label="改写预检"]').exists()).toBe(false)
|
||||
expect(wrapper.text()).toContain('预检读取失败')
|
||||
})
|
||||
it.each([
|
||||
{ name: '来源失效', sourceValid: false, hasActiveExecution: false },
|
||||
{ name: '活动任务', sourceValid: true, hasActiveExecution: true }
|
||||
])('$name 时保留只读入口,不强调人工确认或改写', async ({ name, sourceValid, hasActiveExecution }) => {
|
||||
const id = `review-primary-blocked-${name}`
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
confirmedRewriteEpisodes: [2],
|
||||
ready: false,
|
||||
sourceValid,
|
||||
hasActiveExecution
|
||||
})
|
||||
vi.mocked(dramaReviewApi.rewritePreview).mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
ready: false,
|
||||
status: hasActiveExecution ? 'blocked' : 'stale',
|
||||
rewriteEpisodes: hasActiveExecution
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
const entryButtons = wrapper
|
||||
.findAllComponents(NButton)
|
||||
.filter(button => ['人工确认', '改写预检'].includes(button.attributes('aria-label') ?? ''))
|
||||
expect(entryButtons.map(button => button.props('type'))).toEqual(
|
||||
hasActiveExecution ? ['default', 'default'] : ['default']
|
||||
)
|
||||
})
|
||||
it('手机默认收起完整正文,点击查看本集原文后展开核对区', async () => {
|
||||
vi.spyOn(window, 'matchMedia').mockReturnValue({
|
||||
matches: false,
|
||||
media: '(min-width: 1024px)',
|
||||
onchange: null,
|
||||
addEventListener: vi.fn<() => void>(),
|
||||
removeEventListener: vi.fn<() => void>(),
|
||||
addListener: vi.fn<() => void>(),
|
||||
removeListener: vi.fn<() => void>(),
|
||||
dispatchEvent: () => true
|
||||
})
|
||||
vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(() => {})
|
||||
const id = 'review-mobile-source'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.get('button[aria-label="人工确认"]').trigger('click')
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
expect(drawer.find('.review-source-content').exists()).toBe(false)
|
||||
await drawer
|
||||
.get('[data-review-issue="1"]')
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '查看本集原文')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawer.get('.review-source-content').text()).toContain('林夏放下信件后打开房门。')
|
||||
})
|
||||
it('人工处理完成审核后仍可只读核对正式正文,不再显示可提交表单', async () => {
|
||||
const id = 'review-panel-finalized'
|
||||
const preview = confirmationPreview(id)
|
||||
preview.pendingQualityIssues = [preview.pendingQualityIssues[2]!]
|
||||
preview.remainingPendingQualityIssues = preview.pendingQualityIssues
|
||||
preview.uncertainty = []
|
||||
preview.remainingUncertainty = []
|
||||
const initial = {
|
||||
...latestReview(id),
|
||||
pendingQualityIssues: preview.pendingQualityIssues,
|
||||
qualityReview: { issues: [], uncertainty: [] }
|
||||
}
|
||||
const latest = vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(initial)
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(preview)
|
||||
const context = testProjectContext(id)
|
||||
context.data.value!.project.status = 'need_review'
|
||||
context.data.value!.project.episodes = confirmationPreview(id).episodes.map(item => ({
|
||||
...item,
|
||||
title: `第${item.episode}集`,
|
||||
targetDurationSeconds: null
|
||||
}))
|
||||
vi.spyOn(dramaReviewApi, 'confirm').mockImplementation(async () => {
|
||||
latest.mockResolvedValue({ ...initial, id: 'review-passed', passed: true, pendingQualityIssues: [] })
|
||||
context.data.value!.project.status = 'completed'
|
||||
return {
|
||||
projectId: id,
|
||||
reviewId: 'review-1',
|
||||
checkpointId: 'final-cp',
|
||||
confirmedEpisodes: [],
|
||||
acceptedWarningIndexes: [0],
|
||||
acceptedUncertaintyIndexes: [],
|
||||
finalized: true,
|
||||
remainingBlockers: 0,
|
||||
blockers: {
|
||||
pendingIssues: 0,
|
||||
uncertainty: 0,
|
||||
confirmedErrors: 0,
|
||||
affectedEpisodes: 0,
|
||||
contentSafety: 0
|
||||
}
|
||||
}
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: context } }
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.get('button[aria-label="人工确认"]').trigger('click')
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
await drawer.get('[data-review-issue="0"] [role="checkbox"]').trigger('click')
|
||||
await drawer.get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await drawer
|
||||
.get('.app-drawer-footer')
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '确认本次处理')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawer.text()).toContain('本次处理已完成审核')
|
||||
expect(drawer.text()).toContain('林夏放下信件后打开房门。')
|
||||
expect(drawer.text()).not.toContain('当前没有可核对的正式正文')
|
||||
expect(drawer.findAll('button').some(item => item.text() === '确认本次处理')).toBe(false)
|
||||
})
|
||||
it('刷新失败保留旧记录时不把旧通过结论继续标为当前成功', async () => {
|
||||
const id = 'review-read-failed'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue({ ...latestReview(id), passed: true })
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
vi.mocked(dramaReviewApi.latest).mockRejectedValue(new Error('审核读取中断'))
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '刷新审核')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NTag).props('type')).toBe('default')
|
||||
expect(wrapper.text()).not.toContain('当前审核已通过')
|
||||
})
|
||||
it('按集核对正式原文,默认不勾选,实际提交仍使用原始索引', async () => {
|
||||
const id = 'review-panel-index'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm').mockResolvedValue({
|
||||
projectId: id,
|
||||
reviewId: 'review-1',
|
||||
checkpointId: 'saved-cp',
|
||||
confirmedEpisodes: [1],
|
||||
acceptedWarningIndexes: [],
|
||||
acceptedUncertaintyIndexes: [],
|
||||
finalized: false,
|
||||
remainingBlockers: 2,
|
||||
blockers: {
|
||||
pendingIssues: 1,
|
||||
uncertainty: 0,
|
||||
confirmedErrors: 1,
|
||||
affectedEpisodes: 0,
|
||||
contentSafety: 0
|
||||
}
|
||||
})
|
||||
const context = testProjectContext(id)
|
||||
context.data.value!.project.status = 'need_review'
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: context } }
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.get('button[aria-label="人工确认"]').trigger('click')
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
expect(drawer.text()).toContain('正式剧本原文')
|
||||
const footer = drawer.get('.app-drawer-footer')
|
||||
const submit = footer.findAll('button').find(item => item.text() === '确认本次处理')!
|
||||
expect(submit.attributes('disabled')).toBeDefined()
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
await drawer.get('[data-review-issue="1"] [role="checkbox"]').trigger('click')
|
||||
await footer.get('[role="checkbox"]').trigger('click')
|
||||
await submit.trigger('click')
|
||||
await flushPromises()
|
||||
expect(confirm.mock.calls[0]![1]).toMatchObject({ confirmed: true, reviewId: 'review-1', issueIndexes: [1] })
|
||||
expect(context.refresh).toHaveBeenCalled()
|
||||
expect(drawer.text()).not.toContain('当前审核已通过')
|
||||
})
|
||||
it('来源过期只读展示,界面不开放人工确认', async () => {
|
||||
const id = 'review-panel-stale'
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue({
|
||||
...confirmationPreview(id),
|
||||
ready: false,
|
||||
sourceValid: false
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('来源不一致')
|
||||
await wrapper.get('button[aria-label="人工确认"]').trigger('click')
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
expect(drawer.get('[data-review-issue="1"] [role="checkbox"]').attributes('aria-disabled')).toBe('true')
|
||||
expect(
|
||||
wrapper
|
||||
.findAllComponents(NCheckbox)
|
||||
.find(item => item.element.closest('[data-review-issue="1"]'))!
|
||||
.props('disabled')
|
||||
).toBe(true)
|
||||
expect(
|
||||
drawer
|
||||
.get('.app-drawer-footer')
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '确认本次处理')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,70 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
deferredDraftError,
|
||||
newDeferredDraft,
|
||||
suggestionForUncertainty,
|
||||
savedReviewDecisions
|
||||
} from '@/features/create-drama/review/model'
|
||||
import { suggestedPreview } from './fixtures'
|
||||
|
||||
describe('延期建议与原始索引', () => {
|
||||
it('部分处理后从当前保存记录读取同一审核的裁决,不混入其它来源', () => {
|
||||
const decision = {
|
||||
reviewId: 'review-current',
|
||||
originalIndex: 0,
|
||||
description: '空间关系',
|
||||
disposition: 'deferred',
|
||||
episode: 2,
|
||||
verificationTarget: 'storyboard',
|
||||
verificationCriteria: '核对可达性。'
|
||||
}
|
||||
expect(
|
||||
savedReviewDecisions(
|
||||
{ manualUncertaintyDecisions: [decision, { ...decision, reviewId: 'old' }] },
|
||||
'review-current'
|
||||
)
|
||||
).toEqual([decision])
|
||||
expect(savedReviewDecisions({}, 'review-current')).toBeNull()
|
||||
})
|
||||
it('建议按剩余项重编号后,仍通过原文对应原始审核问题', () => {
|
||||
const preview = suggestedPreview()
|
||||
preview.remainingUncertainty = preview.uncertainty.slice(1)
|
||||
preview.resolutionSuggestions = preview
|
||||
.resolutionSuggestions!.slice(1)
|
||||
.map((item, index) => ({ ...item, index }))
|
||||
expect(suggestionForUncertainty(preview, 1)?.description).toBe(preview.uncertainty[1])
|
||||
expect(suggestionForUncertainty(preview, 2)?.suggestedAction).toBe('manual_review')
|
||||
expect(suggestionForUncertainty(preview, 0)).toBeNull()
|
||||
})
|
||||
it('低置信度或要求选集时不预选集号,但预填可编辑的阶段与标准', () => {
|
||||
const preview = suggestedPreview()
|
||||
const suggestion = { ...preview.resolutionSuggestions![0]!, episode: 2, confidence: 'low' as const }
|
||||
expect(newDeferredDraft(0, suggestion, preview.episodes)).toEqual({
|
||||
index: 0,
|
||||
episode: null,
|
||||
verificationTarget: 'storyboard',
|
||||
verificationCriteria: '核对空间关系与动作连续性。'
|
||||
})
|
||||
expect(
|
||||
newDeferredDraft(
|
||||
0,
|
||||
{ ...suggestion, confidence: 'high', requiresEpisodeSelection: false },
|
||||
preview.episodes
|
||||
).episode
|
||||
).toBe(2)
|
||||
})
|
||||
it('允许选择候选之外的正式剧集,拒绝空标准、未知阶段与不存在集号', () => {
|
||||
const preview = suggestedPreview()
|
||||
const draft = {
|
||||
index: 1,
|
||||
episode: 1,
|
||||
verificationTarget: 'breakdown' as const,
|
||||
verificationCriteria: '核对动作。'
|
||||
}
|
||||
expect(deferredDraftError(draft, preview.episodes)).toBe('')
|
||||
expect(deferredDraftError({ ...draft, episode: null }, preview.episodes)).toContain('剧集')
|
||||
expect(deferredDraftError({ ...draft, episode: 9 }, preview.episodes)).toContain('剧集')
|
||||
expect(deferredDraftError({ ...draft, verificationCriteria: ' ' }, preview.episodes)).toContain('标准')
|
||||
expect(deferredDraftError({ ...draft, verificationTarget: null }, preview.episodes)).toContain('阶段')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,113 @@
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import DramaRewriteAction from '@/features/create-drama/review/DramaRewriteAction.vue'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { workflowExecutionApi } from '@/features/workflows/execution-api'
|
||||
import { rewritePreview } from './fixtures'
|
||||
|
||||
/** 当前挂载的改写入口。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
|
||||
/**
|
||||
* 从实际入口打开改写预检。
|
||||
* @param id 当前测试项目
|
||||
* @returns 当前确认弹窗
|
||||
*/
|
||||
async function openRewrite(id: string) {
|
||||
wrapper = mount(DramaRewriteAction, { attachTo: document.body, props: { projectId: id } })
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
return new DOMWrapper(document.querySelector<HTMLElement>('.app-dialog[aria-label="恢复改写"]')!)
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
describe('恢复改写前的范围与费用确认', () => {
|
||||
it('打开和关闭只做预检,明确确认后才提交 confirmed 并跟踪后台任务', async () => {
|
||||
const id = 'rewrite-confirmed'
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview').mockResolvedValue(rewritePreview(id))
|
||||
vi.spyOn(workflowExecutionApi, 'get').mockResolvedValue({
|
||||
id: 'rewrite-task',
|
||||
projectId: id,
|
||||
workflowName: 'create-drama',
|
||||
status: 'running',
|
||||
stage: 'resumeRewrite',
|
||||
current: 0,
|
||||
total: 0,
|
||||
currentResourceId: null,
|
||||
metadata: null,
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
createdAt: '2026-10-28T00:00:00Z',
|
||||
updatedAt: '2026-10-28T00:00:00Z'
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async () =>
|
||||
new Response(JSON.stringify({ data: { executionId: 'rewrite-task', status: 'running' } }), {
|
||||
status: 202
|
||||
})
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const dialog = await openRewrite(id)
|
||||
expect(dialog.text()).toContain('第 1、2 集')
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
const confirm = dialog.findAll('button').find(button => button.text() === '确认恢复改写')!
|
||||
expect(confirm.attributes('disabled')).toBeDefined()
|
||||
await dialog.get('[role="checkbox"]').trigger('click')
|
||||
await confirm.trigger('click')
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(1)
|
||||
expect(fetcher.mock.calls[0]![0]).toBe(`/api/projects/${id}/resume-rewrite`)
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]![1]!.body))).toEqual({ confirmed: true })
|
||||
expect(localStorage.getItem(`short-drama:workflow-execution:${id}:create-drama`)).toBe('rewrite-task')
|
||||
})
|
||||
|
||||
it('二次预检发现保存记录或集数变化时撤销旧确认,不发送改写请求', async () => {
|
||||
const id = 'rewrite-changed'
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview')
|
||||
.mockResolvedValueOnce(rewritePreview(id))
|
||||
.mockResolvedValue({ ...rewritePreview(id), checkpointId: 'cp-new', episodeNumbers: [2] })
|
||||
const fetcher = vi.fn<typeof fetch>()
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const dialog = await openRewrite(id)
|
||||
await dialog.get('[role="checkbox"]').trigger('click')
|
||||
await dialog
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '确认恢复改写')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
expect(dialog.text()).toContain('已变化')
|
||||
expect(dialog.get('[role="checkbox"]').attributes('aria-checked')).toBe('false')
|
||||
})
|
||||
|
||||
it('服务端未就绪时可关闭和重新读取,但不能启动改写', async () => {
|
||||
const id = 'rewrite-blocked'
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview').mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
ready: false,
|
||||
status: 'needs_review'
|
||||
})
|
||||
const dialog = await openRewrite(id)
|
||||
expect(dialog.text()).toContain('没有可执行的改写目标')
|
||||
expect(
|
||||
dialog
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '确认恢复改写')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
expect(
|
||||
dialog
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '取消')!
|
||||
.attributes('disabled')
|
||||
).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,90 @@
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import DramaReviewPanel from '@/features/create-drama/review/DramaReviewPanel.vue'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { latestReview, suggestedPreview, rewritePreview } from './fixtures'
|
||||
|
||||
/** 当前挂载页面。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
beforeEach(() => {
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview').mockImplementation(async id => ({
|
||||
...rewritePreview(id),
|
||||
ready: false,
|
||||
status: 'needs_review',
|
||||
episodeNumbers: [],
|
||||
rewriteEpisodes: false
|
||||
}))
|
||||
})
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
/**
|
||||
* 通过真实审核入口打开含建议的处理抽屉。
|
||||
* @param id 测试项目编号
|
||||
* @returns 当前抽屉
|
||||
*/
|
||||
async function openSuggestions(id: string) {
|
||||
const preview = suggestedPreview(id)
|
||||
preview.resolutionSuggestions![0]!.episodeCandidates = [2, 3]
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue({
|
||||
...latestReview(id),
|
||||
pendingQualityIssues: [],
|
||||
qualityReview: { issues: [], uncertainty: preview.uncertainty }
|
||||
})
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(preview)
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.get('button[aria-label="人工确认"]').trigger('click')
|
||||
await flushPromises()
|
||||
return new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
}
|
||||
|
||||
describe('审核建议卡片', () => {
|
||||
it('低置信度延期建议展示候选但不默认采用,选择延期后预填标准且剧集留空', async () => {
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
const drawer = await openSuggestions('suggestion-ui-defer')
|
||||
const card = drawer.get('[data-review-uncertainty="0"]')
|
||||
expect(card.text()).toContain('延期验证')
|
||||
expect(card.text()).toContain('第 2、3 集')
|
||||
expect(card.get('[data-resolution-action="defer"]').text()).toContain('建议')
|
||||
expect((card.get('[data-resolution-action="pending"] input').element as HTMLInputElement).checked).toBe(true)
|
||||
await card.get('[data-resolution-action="defer"] input').setValue(true)
|
||||
await flushPromises()
|
||||
const episode = wrapper!
|
||||
.findAllComponents(NSelect)
|
||||
.find(item => item.attributes('aria-label') === '问题 1 负责验证的剧集')!
|
||||
expect(episode.props('value')).toBeNull()
|
||||
expect(episode.props('options')!.map(item => ('value' in item ? item.value : undefined))).toEqual([2, 3, 1])
|
||||
expect((card.get('textarea[aria-label="问题 1 验证标准"]').element as HTMLTextAreaElement).value).toBe(
|
||||
'核对空间关系与动作连续性。'
|
||||
)
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
expect(
|
||||
drawer
|
||||
.get('.app-drawer-footer')
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '确认本次处理')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
})
|
||||
it('人工核对建议仍默认保留,不能由 manual_review 自动接受', async () => {
|
||||
const confirm = vi.spyOn(dramaReviewApi, 'confirm')
|
||||
const drawer = await openSuggestions('suggestion-ui-manual')
|
||||
const card = drawer.get('[data-review-uncertainty="2"]')
|
||||
expect(card.text()).toContain('人工核对')
|
||||
expect((card.get('[data-resolution-action="pending"] input').element as HTMLInputElement).checked).toBe(true)
|
||||
expect((card.get('[data-resolution-action="accept"] input').element as HTMLInputElement).checked).toBe(false)
|
||||
expect(card.find('textarea').exists()).toBe(false)
|
||||
expect(confirm).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user