feat(short-drama-agent-front): 接入正式审核执行历史
This commit is contained in:
1 parent
518b630a46
commit
c808a58a3f
17 files changed
+1129
-175
No files matched your search
@@ -0,0 +1,181 @@
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import KeyframeExecutionHistory from '@/features/production/components/KeyframeExecutionHistory.vue'
|
||||
import KeyframeValidationHistory from '@/features/production/components/KeyframeValidationHistory.vue'
|
||||
import ReadonlyInspection from '@/components/ui/ReadonlyInspection.vue'
|
||||
import {
|
||||
physicalHistoryFixture,
|
||||
validationExecutionFixture,
|
||||
validationHistoryFixture
|
||||
} from '../../fixtures/validation-executions'
|
||||
|
||||
/** 只操作隔离挂载,浏览器布局另在本地 Chrome 验收。 */
|
||||
let wrapper: VueWrapper
|
||||
/**
|
||||
* 通过实际折叠标题触发按需查询,不直接调用组件私有方法。
|
||||
* @param label 可见折叠标题
|
||||
*/
|
||||
async function expand(label: string) {
|
||||
const heading = wrapper.findAll('.n-collapse-item__header-main').find(item => item.text().includes(label))
|
||||
expect(heading).toBeDefined()
|
||||
await heading!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
/**
|
||||
* 包装正式响应。
|
||||
* @param data 公开返回值
|
||||
* @returns Mock HTTP
|
||||
*/
|
||||
function response(data: unknown) {
|
||||
return new Response(JSON.stringify({ data }))
|
||||
}
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('按任务读取执行历史的页面流程', () => {
|
||||
it('无缓存按需分页,原 General 计量只标复用;旧失败和未记录步骤独立展示', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async input =>
|
||||
response(
|
||||
String(input).includes('cursor=opaque')
|
||||
? validationHistoryFixture([validationExecutionFixture('old-run')])
|
||||
: validationHistoryFixture([physicalHistoryFixture], { nextCursor: 'opaque' })
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeExecutionHistory, {
|
||||
props: { projectId: 'project', shotId: 'shot', keyframeId: 'keyframe', validationTaskId: 'task' }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await expand('执行记录')
|
||||
expect(wrapper.text()).toContain('仅补跑物理专项')
|
||||
expect(wrapper.text()).toContain('执行完成,质量待复核')
|
||||
expect(wrapper.text()).toContain('本次新提交步骤:物理关系;复用已有步骤:通用画面')
|
||||
await expand('通用画面')
|
||||
expect(wrapper.text()).toContain('原调用计量,不重复计入本次')
|
||||
await expand('高级详情')
|
||||
expect(wrapper.text()).toContain('输入词元:100')
|
||||
expect(wrapper.text()).toContain('复用来源执行:old-run')
|
||||
expect(wrapper.text()).not.toContain('合计词元:0')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '加载更多')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('历史执行') // 显示历史行,具体错误由该执行本身提供
|
||||
expect(wrapper.text()).toContain('未记录本次步骤证据')
|
||||
expect(wrapper.text()).not.toContain('加载更多')
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('当前关联不可用不选择第一条;归档步骤的未知范围不补成空计划', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>(async () =>
|
||||
response(
|
||||
validationHistoryFixture(
|
||||
[validationExecutionFixture('archive', { stepsEvidence: 'archived_audit' })],
|
||||
{ currentExecutionId: null, integrity: { currentExecution: 'unavailable' } }
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
wrapper = mount(KeyframeExecutionHistory, {
|
||||
props: { projectId: 'project', shotId: 'shot', keyframeId: 'keyframe', validationTaskId: 'task' }
|
||||
})
|
||||
await expand('执行记录')
|
||||
expect(wrapper.text()).toContain('当前执行关联需要核查')
|
||||
expect(wrapper.text()).toContain('执行范围未记录')
|
||||
expect(wrapper.text()).toContain('本次新提交步骤:未记录')
|
||||
expect(wrapper.text()).toContain('已核对的历史审计')
|
||||
expect(wrapper.text()).not.toContain('当前执行 ·')
|
||||
})
|
||||
it('只接收同一范围的实时变化,终态只刷新首屏一次,不新建 SSE', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async () => response(validationHistoryFixture([physicalHistoryFixture])))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const source = vi.fn<() => void>()
|
||||
vi.stubGlobal('EventSource', source)
|
||||
wrapper = mount(KeyframeExecutionHistory, {
|
||||
props: { projectId: 'project', shotId: 'shot', keyframeId: 'keyframe', validationTaskId: 'task' }
|
||||
})
|
||||
await expand('执行记录')
|
||||
await wrapper.setProps({
|
||||
liveExecution: {
|
||||
...physicalHistoryFixture.execution,
|
||||
id: 'foreign-run',
|
||||
metadata: { validationTaskId: 'other-task', shotId: 'shot', keyframeId: 'keyframe' }
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(1)
|
||||
await wrapper.setProps({ latestExecutionId: 'new-run' })
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
expect(source).not.toHaveBeenCalled()
|
||||
})
|
||||
it('人工终止旧任务可读空列表,刷新候选摘要不卸载已展开的正式执行记录', async () => {
|
||||
let pending = false
|
||||
let resolveHistory!: (value: Response) => void
|
||||
const task = {
|
||||
id: 'task',
|
||||
status: 'running',
|
||||
output: null,
|
||||
error: null,
|
||||
createdAt: '2026-11-07',
|
||||
legacyTermination: {
|
||||
auditId: 'audit',
|
||||
terminatedAt: '2026-11-07',
|
||||
billingFinding: 'unresolved',
|
||||
requiresNewAuthorization: true
|
||||
}
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>(async input => {
|
||||
const path = String(input)
|
||||
if (path.includes('/executions?'))
|
||||
return response(
|
||||
validationHistoryFixture([], {
|
||||
total: 0,
|
||||
currentExecutionId: null,
|
||||
taskStatus: 'running',
|
||||
integrity: { currentExecution: 'not_recorded' }
|
||||
})
|
||||
)
|
||||
if (path.includes('/validations'))
|
||||
return pending
|
||||
? new Promise(resolve => {
|
||||
resolveHistory = resolve
|
||||
})
|
||||
: response([task])
|
||||
return response({
|
||||
validationTaskId: 'task',
|
||||
qualityDecision: 'unknown',
|
||||
effectiveQualityStatus: 'unknown',
|
||||
historicalGazePreview: [],
|
||||
manualReviewAvailable: false
|
||||
})
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeValidationHistory, {
|
||||
props: { projectId: 'project', shotId: 'shot', keyframeId: 'keyframe', initialOpen: true }
|
||||
})
|
||||
await flushPromises()
|
||||
await expand('执行记录')
|
||||
expect(wrapper.text()).toContain('暂无已保存的执行记录')
|
||||
expect(wrapper.text()).toContain('历史审核已人工终止')
|
||||
const original = wrapper.findComponent(KeyframeExecutionHistory).vm.$.uid
|
||||
pending = true
|
||||
wrapper.findComponent(ReadonlyInspection).vm.$emit('refresh')
|
||||
await flushPromises()
|
||||
expect(wrapper.findComponent(KeyframeExecutionHistory).vm.$.uid).toBe(original)
|
||||
expect(wrapper.text()).toContain('暂无已保存的执行记录')
|
||||
resolveHistory(response([task]))
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.filter(([input]) => String(input).includes('/executions?'))).toHaveLength(1)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user