fix(short-drama-agent-front): 修复拆解进度展示与问题交互

This commit is contained in:
GJ committed 2026-10-17 10:21:44 +08:00
1 parent 3414cc8232
commit db91a4b871
19 files changed
+870 -150

No files matched your search

+61 -2
View File
@@ -10,13 +10,62 @@ import type { Checkpoint } from '@/features/workflows/types'
import type { BreakdownModule, EpisodePlan } from '@/features/breakdown/types'
import { drawerPanel } from '@/testing/naive'
import { readAllStyles } from '@/testing/styles'
import { effectScope } from 'vue'
import { useWorkflowExecution } from '@/features/workflows/execution'
import { workflowExecutionApi } from '@/features/workflows/execution-api'
let wrapper: VueWrapper | undefined
/** 跨组件后台任务观察器,验证结束时释放。 */
let taskScope: ReturnType<typeof effectScope> | undefined
afterEach(() => {
taskScope?.stop()
taskScope = undefined
wrapper?.unmount()
wrapper = undefined
document.body.innerHTML = ''
vi.unstubAllGlobals()
vi.restoreAllMocks()
localStorage.clear()
})
it('后台重新拆解时显示真实运行状态并隐藏所有诊断入口,终态后恢复', async () => {
vi.stubGlobal(
'fetch',
vi.fn<typeof fetch>().mockImplementation(async () => diagnosisResultsResponse())
)
const provided = mountPage()
await selectTab('分镜')
const record = {
id: 'external-breakdown-ui',
projectId: 'breakdown-scroll-test',
workflowName: 'breakdown',
status: 'running' as 'running' | 'completed',
stage: 'storyboard_plan_ready',
current: 1,
total: 3,
currentResourceId: null,
metadata: { progressUnit: 'storyboard_episodes' },
result: null,
error: null,
startedAt: '2026-10-17T00:00:00Z',
completedAt: null,
createdAt: '2026-10-17T00:00:00Z',
updatedAt: '2026-10-17T00:01:00Z'
}
vi.spyOn(workflowExecutionApi, 'get').mockImplementation(async () => ({ ...record }))
taskScope = effectScope()
const tracker = taskScope.run(() => useWorkflowExecution(ref(record.projectId), 'breakdown'))!
await tracker.track(record.id)
await flushPromises()
expect(wrapper!.text()).toContain('拆解进行中')
expect(wrapper!.find('.storyboard-diagnosis-summary').exists()).toBe(false)
expect(wrapper!.find('.diagnose-hover-action').exists()).toBe(false)
record.status = 'completed'
await tracker.query.refresh()
await flushPromises()
expect(wrapper!.find('.storyboard-diagnosis-summary').exists()).toBe(true)
expect(provided.refresh).toHaveBeenCalled()
tracker.dismiss()
})
/** 长主体、长分镜与长任务列表,用真实 Naive 滚动组件验证内容边界。 */
@@ -495,7 +544,7 @@ describe('拆解页内容滚动', () => {
expect(fetcher).not.toHaveBeenCalled()
})
it('关闭设置时保留问题入口,详细校验与恢复在面板内,不挤占结果高度', async () => {
it('问题入口打开独立错误弹窗,拆解设置不再包含详细错误', async () => {
const record = checkpoint()
record.state.workflowExecution!.status = 'failed'
record.state.workflowExecution!.errorMessage = '工作流中断'
@@ -509,7 +558,17 @@ describe('拆解页内容滚动', () => {
const action = wrapper!.findAll('button').find(item => item.text() === '查看拆解问题')!
await action.trigger('click')
await flushPromises()
expect(drawerPanel().text()).toContain('缺少形态绑定')
const issues = document.querySelector<HTMLElement>('.app-dialog[aria-label="拆解问题"]')
expect(issues?.textContent).toContain('缺少形态绑定')
expect(issues?.textContent).toContain('工作流中断')
expect(issues?.textContent).not.toContain('重试失败抽取')
await new DOMWrapper(issues!).get('.n-card-header__close').trigger('click')
await flushPromises()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
expect(drawerPanel().text()).not.toContain('缺少形态绑定')
expect(drawerPanel().text()).not.toContain('工作流中断')
expect(drawerPanel().text()).toContain('查看问题')
expect(drawerPanel().text()).toContain('重试失败抽取')
})
@@ -0,0 +1,40 @@
import { afterEach, describe, expect, it } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import BreakdownIssuesDialog from '@/features/breakdown/components/BreakdownIssuesDialog.vue'
import AppDialog from '@/components/ui/AppDialog.vue'
/** 独立问题弹窗实例,验证后移除 Teleport。 */
let wrapper: VueWrapper | undefined
afterEach(() => {
wrapper?.unmount()
document.body.innerHTML = ''
})
describe('拆解问题弹窗', () => {
it('同镜头问题合并展示并去重,定位等待弹窗离场后发出', async () => {
wrapper = mount(BreakdownIssuesDialog, {
attachTo: document.body,
props: {
open: true,
locatable: true,
issues: [
{ episodeNo: 1, beatNo: 2, shotNo: 3, message: '缺少场景' },
{ episodeNo: 1, beatNo: 2, shotNo: 3, message: '缺少道具' },
{ episodeNo: 1, beatNo: 2, shotNo: 3, message: '缺少场景' },
{ episodeNo: 2, beatNo: 1, shotNo: 1, message: '缺少人物' }
]
}
})
await flushPromises()
expect(document.querySelectorAll('.breakdown-issue-group')).toHaveLength(2)
expect(document.body.textContent).toContain('3 项校验问题 · 2 个位置')
const button = [...document.querySelectorAll<HTMLButtonElement>('button')].find(
item => item.textContent?.trim() === '定位分镜'
)!
button.click()
await flushPromises()
expect(wrapper.emitted('locate')).toBeUndefined()
wrapper.getComponent(AppDialog).vm.$emit('closed')
expect(wrapper.emitted('locate')?.[0]?.[0]).toMatchObject({ episodeNo: 1, beatNo: 2, shotNo: 3 })
})
})