fix(short-drama-agent-front): 修复代码格式检查问题

This commit is contained in:
GJ committed 2026-10-21 17:04:02 +08:00
1 parent 81d6a85260
commit 48fce3975f
87 files changed
+5714 -1436

No files matched your search

+178 -37
View File
@@ -15,7 +15,12 @@ import { effectScope } from 'vue'
import { useWorkflowExecution } from '@/features/workflows/execution'
import { workflowExecutionApi } from '@/features/workflows/execution-api'
import { breakdownApi } from '@/features/breakdown/api'
import { candidateCheckpoint, candidateReview, candidateState, resourceConflictState } from '../../fixtures/breakdown-candidate'
import {
candidateCheckpoint,
candidateReview,
candidateState,
resourceConflictState
} from '../../fixtures/breakdown-candidate'
import { projectsApi } from '@/features/projects/api'
import type { ProjectQualityPolicy } from '@/features/projects/types'
import { getOperation } from '@/features/workflows/operations'
@@ -23,18 +28,38 @@ import { getOperation } from '@/features/workflows/operations'
let wrapper: VueWrapper | undefined
it('首次点击生成先读取并确认质量规则,不直接打开模型启动确认', async () => {
const readPolicy = vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('breakdown-scroll-test', { version: 1, physicsMode: 'realistic', allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] }))
const readPolicy = vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(
policyReceipt('breakdown-scroll-test', {
version: 1,
physicsMode: 'realistic',
allowExaggeratedMotion: false,
allowNonPhysicalActions: false,
allowSupernaturalAbilities: false,
customRules: []
})
)
vi.spyOn(breakdownApi, 'preview').mockResolvedValue({
episodeCount: 1, groupCount: 1, estimatedTaskCount: 3, tasks: [], modules: ['character', 'scene', 'prop'], groupSize: 3,
episodeCount: 1,
groupCount: 1,
estimatedTaskCount: 3,
tasks: [],
modules: ['character', 'scene', 'prop'],
groupSize: 3,
groups: [{ groupId: 'preview-group', groupNo: 1, startEpisodeNo: 1, endEpisodeNo: 1, episodes: [] }]
})
const start = vi.spyOn(breakdownApi, 'run')
mountPage()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '预览分组')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '预览分组')!
.trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '生成拆解候选')!
.trigger('click')
await flushPromises()
expect(readPolicy).toHaveBeenCalledTimes(1)
expect(drawerPanel().text()).toContain('拆解前确认质量规则')
@@ -43,14 +68,26 @@ it('首次点击生成先读取并确认质量规则,不直接打开模型启
})
it('规则确认保留分组预览,隐藏空白例外,确认不调用模型,未变规则不重复打开表单', async () => {
const result = policyReceipt('breakdown-scroll-test', { version: 1, physicsMode: 'realistic', allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] })
const result = policyReceipt('breakdown-scroll-test', {
version: 1,
physicsMode: 'realistic',
allowExaggeratedMotion: false,
allowNonPhysicalActions: false,
allowSupernaturalAbilities: false,
customRules: []
})
vi.spyOn(projectsApi, 'qualityPolicy').mockImplementation(async () => structuredClone(result))
vi.spyOn(projectsApi, 'confirmQualityPolicy').mockImplementation(async () => {
Object.assign(result, { confirmed: true, confirmedRevision: 2, confirmedAt: '2026-10-17T15:00:00Z' })
return structuredClone(result)
})
vi.spyOn(breakdownApi, 'preview').mockResolvedValue({
episodeCount: 1, groupCount: 1, estimatedTaskCount: 3, tasks: [], modules: ['character', 'scene', 'prop'], groupSize: 3,
episodeCount: 1,
groupCount: 1,
estimatedTaskCount: 3,
tasks: [],
modules: ['character', 'scene', 'prop'],
groupSize: 3,
groups: [{ groupId: 'preview-group', groupNo: 1, startEpisodeNo: 1, endEpisodeNo: 1, episodes: [] }]
})
const save = vi.spyOn(projectsApi, 'saveQualityPolicy')
@@ -58,24 +95,52 @@ it('规则确认保留分组预览,隐藏空白例外,确认不调用模型
mountPage()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '预览分组')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '预览分组')!
.trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '生成拆解候选')!
.trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '取消')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '取消')!
.trigger('click')
expect(drawerPanel().text()).toContain('第 1–1 集')
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '生成拆解候选')!
.trigger('click')
await flushPromises()
expect(drawerPanel().findAll('button').some(button => button.text() === '添加例外')).toBe(false)
await drawerPanel().findAll('[role="checkbox"]').find(box => box.text().includes('我已核对'))!.trigger('click')
await drawerPanel().findAll('button').find(button => button.text() === '确认规则并继续')!.trigger('click')
expect(
drawerPanel()
.findAll('button')
.some(button => button.text() === '添加例外')
).toBe(false)
await drawerPanel()
.findAll('[role="checkbox"]')
.find(box => box.text().includes('我已核对'))!
.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '确认规则并继续')!
.trigger('click')
await flushPromises()
expect(document.querySelector('.app-dialog')?.textContent).toContain('可能产生模型费用')
expect(save).not.toHaveBeenCalled()
expect(start).not.toHaveBeenCalled()
await new DOMWrapper(document.querySelector('.app-dialog')!).findAll('button').find(button => button.text() === '取消')!.trigger('click')
await new DOMWrapper(document.querySelector('.app-dialog')!)
.findAll('button')
.find(button => button.text() === '取消')!
.trigger('click')
await flushPromises()
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
await drawerPanel()
.findAll('button')
.find(button => button.text() === '生成拆解候选')!
.trigger('click')
await flushPromises()
expect(drawerPanel().text()).not.toContain('拆解前确认质量规则')
expect(document.querySelector('.app-dialog')?.textContent).toContain('可能产生模型费用')
@@ -83,17 +148,42 @@ it('规则确认保留分组预览,隐藏空白例外,确认不调用模型
})
it('当前动作问题在问题抽屉中提供例外修订,保存期间锁定关闭且保存后仍需审核', async () => {
let policy: ProjectQualityPolicy = { version: 1, physicsMode: 'realistic', allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] }
vi.spyOn(projectsApi, 'qualityPolicy').mockImplementation(async () => policyReceipt('breakdown-scroll-test', policy))
let policy: ProjectQualityPolicy = {
version: 1,
physicsMode: 'realistic',
allowExaggeratedMotion: false,
allowNonPhysicalActions: false,
allowSupernaturalAbilities: false,
customRules: []
}
vi.spyOn(projectsApi, 'qualityPolicy').mockImplementation(async () =>
policyReceipt('breakdown-scroll-test', policy)
)
let finish!: () => void
const save = vi.spyOn(projectsApi, 'saveQualityPolicy').mockImplementation(async (id, input) => {
await new Promise<void>(resolve => { finish = resolve })
await new Promise<void>(resolve => {
finish = resolve
})
policy = input
return policyReceipt(id, input)
})
vi.spyOn(breakdownApi, 'revalidateCandidate').mockResolvedValue(candidateReview({
projectId: 'breakdown-scroll-test', actionQualityBlocks: [{ episodeNo: 1, beatNo: 1, shotNo: 1, status: 'blocked', blockingCodes: ['action_resource_conflict'], warningCodes: [], isPendingEpisode: true }], pendingQualityEpisodeNos: [1]
}))
vi.spyOn(breakdownApi, 'revalidateCandidate').mockResolvedValue(
candidateReview({
projectId: 'breakdown-scroll-test',
actionQualityBlocks: [
{
episodeNo: 1,
beatNo: 1,
shotNo: 1,
status: 'blocked',
blockingCodes: ['action_resource_conflict'],
warningCodes: [],
isPendingEpisode: true
}
],
pendingQualityEpisodeNos: [1]
})
)
mountPage([candidateCheckpoint(resourceConflictState({ projectId: 'breakdown-scroll-test' }))])
await flushPromises()
await wrapper!.get('.breakdown-desktop-issues').trigger('click')
@@ -101,17 +191,33 @@ it('当前动作问题在问题抽屉中提供例外修订,保存期间锁定
const drawer = new DOMWrapper(document.querySelector('.breakdown-issues-drawer')!)
const panel = () => drawer.get('[aria-label="动作例外修订"]')
expect(panel().text()).toContain('左手握住铜铃')
await panel().findAll('button').find(button => button.text() === '添加例外')!.trigger('click')
await panel()
.findAll('button')
.find(button => button.text() === '添加例外')!
.trigger('click')
await panel().get('textarea').setValue('剧本中的明确允许设定')
await panel().findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
await panel()
.findAll('button')
.find(button => button.text() === '保存动作例外')!
.trigger('click')
await flushPromises()
expect(drawer.findAll('button').find(button => button.text() === '关闭')!.attributes('disabled')).toBeDefined()
expect(
drawer
.findAll('button')
.find(button => button.text() === '关闭')!
.attributes('disabled')
).toBeDefined()
expect(save).toHaveBeenCalledOnce()
finish()
await flushPromises()
expect(drawer.text()).toContain('动作质量阻断')
expect(panel().text()).toContain('已有例外')
expect(drawer.findAll('button').find(button => button.text() === '关闭')!.attributes('disabled')).toBeUndefined()
expect(
drawer
.findAll('button')
.find(button => button.text() === '关闭')!
.attributes('disabled')
).toBeUndefined()
Object.assign(getOperation('breakdown-scroll-test'), { error: '', notice: '', label: '' })
})
/** 跨组件后台任务观察器,验证结束时释放。 */
@@ -169,8 +275,15 @@ it('后台重新拆解时显示真实运行状态并隐藏所有诊断入口,
it('候选审核通过后只展示候选,修复后的正式结果不再被嵌套历史五个错误污染', async () => {
const old = Array.from({ length: 5 }, (_, index) => ({ episodeNo: 1, message: `历史错误 ${index}` }))
const current = candidateCheckpoint(candidateState({ projectId: 'breakdown-scroll-test', breakdownResult: { storyboardShotValidation: { valid: false, issues: old } } }))
const read = vi.spyOn(breakdownApi, 'revalidateCandidate').mockResolvedValue(candidateReview({ projectId: 'breakdown-scroll-test', previousIssues: old }))
const current = candidateCheckpoint(
candidateState({
projectId: 'breakdown-scroll-test',
breakdownResult: { storyboardShotValidation: { valid: false, issues: old } }
})
)
const read = vi
.spyOn(breakdownApi, 'revalidateCandidate')
.mockResolvedValue(candidateReview({ projectId: 'breakdown-scroll-test', previousIssues: old }))
const provided = mountPage([current])
expect(wrapper!.text()).not.toContain('分镜校验未通过')
await flushPromises()
@@ -180,7 +293,9 @@ it('候选审核通过后只展示候选,修复后的正式结果不再被嵌
await selectTab('分镜')
expect(wrapper!.find('.storyboard-diagnosis-summary').exists()).toBe(false)
expect(read).toHaveBeenCalledTimes(1)
provided.data.value!.checkpoints = [{ ...current, state: { ...current.state, storyboardPersisted: true, candidateCommitted: true } }]
provided.data.value!.checkpoints = [
{ ...current, state: { ...current.state, storyboardPersisted: true, candidateCommitted: true } }
]
await selectTab('人物')
await flushPromises()
expect(wrapper!.text()).toContain('正式拆解结果')
@@ -190,14 +305,26 @@ it('候选审核通过后只展示候选,修复后的正式结果不再被嵌
})
it('历史修复元数据不能掩盖之后新任务的真实失败', async () => {
const current = candidateCheckpoint(candidateState({ projectId: 'breakdown-scroll-test', storyboardPersisted: true, candidateCommitted: true }))
const current = candidateCheckpoint(
candidateState({ projectId: 'breakdown-scroll-test', storyboardPersisted: true, candidateCommitted: true })
)
mountPage([current])
const record = {
id: 'new-failed-breakdown', projectId: 'breakdown-scroll-test', workflowName: 'breakdown',
status: 'failed' as const, stage: 'failed', current: 0, total: 3, currentResourceId: null,
metadata: null, result: null, error: '新任务执行失败',
startedAt: '2026-10-17T10:00:00Z', completedAt: '2026-10-17T10:01:00Z',
createdAt: '2026-10-17T10:00:00Z', updatedAt: '2026-10-17T10:01:00Z'
id: 'new-failed-breakdown',
projectId: 'breakdown-scroll-test',
workflowName: 'breakdown',
status: 'failed' as const,
stage: 'failed',
current: 0,
total: 3,
currentResourceId: null,
metadata: null,
result: null,
error: '新任务执行失败',
startedAt: '2026-10-17T10:00:00Z',
completedAt: '2026-10-17T10:01:00Z',
createdAt: '2026-10-17T10:00:00Z',
updatedAt: '2026-10-17T10:01:00Z'
}
vi.spyOn(workflowExecutionApi, 'get').mockResolvedValue(record)
taskScope = effectScope()
@@ -921,8 +1048,22 @@ describe('拆解页内容滚动', () => {
await flushPromises()
const late = await handDiagnosticsResponse(25).json()
late.data.warningCount = 1
late.data.diagnostics = [{ episodeNo: 1, beatNo: 1, shotNo: 1, phaseNo: 1, characterRef: '@CH0001', actionIds: ['a1', 'a2'], code: 'hand_occupancy_conflict', severity: 'warning', suggestion: '已失效的动作检查问题' }]
resolveFirst!(new Response(JSON.stringify(late), { status: 200, headers: { 'Content-Type': 'application/json' } }))
late.data.diagnostics = [
{
episodeNo: 1,
beatNo: 1,
shotNo: 1,
phaseNo: 1,
characterRef: '@CH0001',
actionIds: ['a1', 'a2'],
code: 'hand_occupancy_conflict',
severity: 'warning',
suggestion: '已失效的动作检查问题'
}
]
resolveFirst!(
new Response(JSON.stringify(late), { status: 200, headers: { 'Content-Type': 'application/json' } })
)
await flushPromises()
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
await flushPromises()