perf(short-drama-agent-front): 优化记录加载与工作区体验
This commit is contained in:
1 parent
d0264c08ce
commit
db9aea1694
111 files changed
+1680
-1290
No files matched your search
@@ -1,11 +1,13 @@
|
||||
import { testProjectContextFrom } from '@/testing/project-context'
|
||||
import { policyReceipt } from '../../fixtures/quality-policy'
|
||||
import { computed, ref } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NButton, NSelect, NSpin } from 'naive-ui'
|
||||
import { NButton, NSelect, NSpin, type MessageApi } from 'naive-ui'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import BreakdownPage from '@/features/breakdown/BreakdownPage.vue'
|
||||
import { projectContextKey, type useProjectData } from '@/features/projects/context'
|
||||
import { actionMessageKey } from '@/components/ui/useActionMessage'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import type { ProjectDetail } from '@/features/projects/types'
|
||||
import type { Checkpoint } from '@/features/workflows/types'
|
||||
import type { BreakdownModule, EpisodePlan } from '@/features/breakdown/types'
|
||||
@@ -446,7 +448,9 @@ it('原位采用的正式分镜显示完整统计,先前失败仅进入历史
|
||||
...candidateCheckpoint(state),
|
||||
updatedAt: '2026-10-17T10:05:00Z'
|
||||
}
|
||||
mountPage([current], 4)
|
||||
const warning = vi.fn<MessageApi['warning']>()
|
||||
const context = mountPage([], 4, warning)
|
||||
context.loading.value = true
|
||||
const record = {
|
||||
id: 'failed-before-in-place-adoption',
|
||||
projectId: 'breakdown-scroll-test',
|
||||
@@ -470,6 +474,11 @@ it('原位采用的正式分镜显示完整统计,先前失败仅进入历史
|
||||
const tracker = taskScope.run(() => useWorkflowExecution(ref(record.projectId), 'breakdown'))!
|
||||
await tracker.track(record.id)
|
||||
await flushPromises()
|
||||
expect(warning).not.toHaveBeenCalled()
|
||||
context.data.value.checkpoints = [current]
|
||||
context.loading.value = false
|
||||
await flushPromises()
|
||||
expect(warning).not.toHaveBeenCalled()
|
||||
expect(wrapper!.text()).toMatch(/正式拆解结果\s*·\s*4 集\s*·\s*60 镜\s*·\s*247 条绑定/)
|
||||
expect(wrapper!.text()).toContain('已提交正式结果')
|
||||
expect(wrapper!.text()).not.toContain('工作流失败')
|
||||
@@ -489,7 +498,9 @@ it('历史修复元数据不能掩盖之后新任务的真实失败', async () =
|
||||
const current = candidateCheckpoint(
|
||||
candidateState({ projectId: 'breakdown-scroll-test', storyboardPersisted: true, candidateCommitted: true })
|
||||
)
|
||||
mountPage([current])
|
||||
const warning = vi.fn<MessageApi['warning']>()
|
||||
const context = mountPage([current], 1, warning)
|
||||
context.loading.value = true
|
||||
const record = {
|
||||
id: 'new-failed-breakdown',
|
||||
projectId: 'breakdown-scroll-test',
|
||||
@@ -512,6 +523,10 @@ it('历史修复元数据不能掩盖之后新任务的真实失败', async () =
|
||||
const tracker = taskScope.run(() => useWorkflowExecution(ref(record.projectId), 'breakdown'))!
|
||||
await tracker.track(record.id)
|
||||
await flushPromises()
|
||||
expect(warning).not.toHaveBeenCalled()
|
||||
context.loading.value = false
|
||||
await flushPromises()
|
||||
expect(warning).toHaveBeenCalledOnce()
|
||||
expect(wrapper!.text()).toContain('工作流失败')
|
||||
expect(wrapper!.find('button.breakdown-desktop-issues').exists()).toBe(true)
|
||||
tracker.dismiss()
|
||||
@@ -597,8 +612,18 @@ function checkpoint(): Checkpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/** 提供响应式 checkpoint,模拟轮询更新但不连接后端或启动模型任务。 */
|
||||
function mountPage(records = [checkpoint()], episodes = 1): ReturnType<typeof useProjectData> {
|
||||
/**
|
||||
* 提供响应式保存记录,模拟更新但不连接后端或启动模型任务。
|
||||
* @param records 已读取的拆解记录
|
||||
* @param episodes 项目集数
|
||||
* @param warning 可选的提示观察函数
|
||||
* @returns 可更新的测试项目上下文
|
||||
*/
|
||||
function mountPage(
|
||||
records = [checkpoint()],
|
||||
episodes = 1,
|
||||
warning?: MessageApi['warning']
|
||||
): ReturnType<typeof testProjectContextFrom> {
|
||||
const project: ProjectDetail = {
|
||||
id: 'breakdown-scroll-test',
|
||||
title: '滚动回归',
|
||||
@@ -636,20 +661,13 @@ function mountPage(records = [checkpoint()], episodes = 1): ReturnType<typeof us
|
||||
storyboard: { ready: true, reason: null }
|
||||
}
|
||||
})
|
||||
const provided: ReturnType<typeof useProjectData> = {
|
||||
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()
|
||||
}
|
||||
const provided = testProjectContextFrom(data)
|
||||
wrapper = mount(BreakdownPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: provided }, stubs: { RouterLink: true } }
|
||||
global: {
|
||||
provide: { [projectContextKey as symbol]: provided, ...(warning && { [actionMessageKey]: { warning } }) },
|
||||
stubs: { RouterLink: true }
|
||||
}
|
||||
})
|
||||
return provided
|
||||
}
|
||||
@@ -1094,7 +1112,7 @@ describe('拆解页内容滚动', () => {
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.text()).not.toContain('手部记录覆盖')
|
||||
expect(panel.text()).toContain('未填写记录不代表镜头有误')
|
||||
expect(panel.text()).toContain('缺少记录不代表镜头有误')
|
||||
expect(panel.get('.n-collapse-item__header-extra button').text()).toBe('刷新校验')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
Reference in new issue
Block a user