fix(short-drama-agent-front): 修复代码格式检查问题
This commit is contained in:
1 parent
81d6a85260
commit
48fce3975f
87 files changed
+5714
-1436
No files matched your search
@@ -9,29 +9,100 @@ import { diagnosisCanStart } from '@/features/breakdown/diagnosis'
|
||||
import type { DiagnosisPreflight } from '@/features/breakdown/diagnosis.types'
|
||||
|
||||
/** 当前正式镜头的免费来源检查。 */
|
||||
const checked = (): DiagnosisPreflight => ({ projectId: 'diag-p', shotId: 'db-shot', episodeNo: 1, beatNo: 1, shotNo: 1, policyRevision: 3, policyFingerprint: 'a'.repeat(64), existingDiagnosisId: null, existingValid: false, eligibleForFurtherValidation: true, errors: [], requiresExecutionValidation: true, shouldDiagnose: true, willCallModel: false, willModifyAssets: false })
|
||||
const checked = (): DiagnosisPreflight => ({
|
||||
projectId: 'diag-p',
|
||||
shotId: 'db-shot',
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
policyRevision: 3,
|
||||
policyFingerprint: 'a'.repeat(64),
|
||||
existingDiagnosisId: null,
|
||||
existingValid: false,
|
||||
eligibleForFurtherValidation: true,
|
||||
errors: [],
|
||||
requiresExecutionValidation: true,
|
||||
shouldDiagnose: true,
|
||||
willCallModel: false,
|
||||
willModifyAssets: false
|
||||
})
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** 最近范围的真实形状,不包含可用于编辑的完整动作字段。 */
|
||||
const preview = () => ({ projectId: 'diag-p', episodeNo: 1, candidateCount: 1, needsEvidenceCount: 1, invalidSnapshotCount: 0, candidates: [{ shotId: 'db-shot', episodeNo: 1, beatNo: 1, shotNo: 1, title: '当前镜头', description: '原始描述', durationSeconds: 4, requiredActionCount: 2, hasDurationPlanning: true, hasHandOccupancy: true, status: 'has_evidence' as const }], willCallModel: false as const, willModifyAssets: false as const })
|
||||
const preview = () => ({
|
||||
projectId: 'diag-p',
|
||||
episodeNo: 1,
|
||||
candidateCount: 1,
|
||||
needsEvidenceCount: 1,
|
||||
invalidSnapshotCount: 0,
|
||||
candidates: [
|
||||
{
|
||||
shotId: 'db-shot',
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
title: '当前镜头',
|
||||
description: '原始描述',
|
||||
durationSeconds: 4,
|
||||
requiredActionCount: 2,
|
||||
hasDurationPlanning: true,
|
||||
hasHandOccupancy: true,
|
||||
status: 'has_evidence' as const
|
||||
}
|
||||
],
|
||||
willCallModel: false as const,
|
||||
willModifyAssets: false as const
|
||||
})
|
||||
/** 只读接口全部隔离,任何未授权模型请求均由测试捕获。 */
|
||||
function mocks() {
|
||||
vi.spyOn(workflowExecutionApi, 'latest').mockResolvedValue(null)
|
||||
vi.spyOn(breakdownApi, 'legacyActionDiagnosisResults').mockResolvedValue({ projectId: 'diag-p', episodeNo: 1, counts: { total: 0, conflict: 0, clear: 0, insufficient: 0, invalid: 0, stale: 0, pending: 0 }, shots: [] })
|
||||
vi.spyOn(breakdownApi, 'handOccupancyDiagnostics').mockResolvedValue({ projectId: 'diag-p', shotCount: 0, diagnostics: [] } as never)
|
||||
vi.spyOn(breakdownApi, 'legacyActionDiagnosisResults').mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
episodeNo: 1,
|
||||
counts: { total: 0, conflict: 0, clear: 0, insufficient: 0, invalid: 0, stale: 0, pending: 0 },
|
||||
shots: []
|
||||
})
|
||||
vi.spyOn(breakdownApi, 'handOccupancyDiagnostics').mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotCount: 0,
|
||||
diagnostics: []
|
||||
} as never)
|
||||
vi.spyOn(breakdownApi, 'legacyActionDiagnosisPreview').mockImplementation(async () => preview())
|
||||
return vi.spyOn(breakdownApi, 'startLegacyActionDiagnosis')
|
||||
}
|
||||
beforeEach(() => { vi.spyOn(preparationApi, 'revisions').mockResolvedValue({ projectId: 'diag-p', shotId: 'db-shot', count: 0, revisions: [] }) })
|
||||
afterEach(() => { wrapper?.unmount(); wrapper = undefined; vi.restoreAllMocks(); vi.unstubAllGlobals(); document.body.innerHTML = '' })
|
||||
beforeEach(() => {
|
||||
vi.spyOn(preparationApi, 'revisions').mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotId: 'db-shot',
|
||||
count: 0,
|
||||
revisions: []
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
vi.restoreAllMocks()
|
||||
vi.unstubAllGlobals()
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
describe('单镜头诊断收费前来源检查', () => {
|
||||
it('高级检查保留复查记录与范围,隐藏旧手部统计且不改变诊断启动条件', async () => {
|
||||
const start = mocks()
|
||||
vi.spyOn(breakdownApi, 'diagnosisPreflight').mockResolvedValue(checked())
|
||||
vi.mocked(breakdownApi.handOccupancyDiagnostics).mockResolvedValue({ projectId: 'diag-p', shotCount: 61, evidenceShotCount: 42,
|
||||
warningCount: 0, assessment: 'partial_evidence', diagnostics: [] } as never)
|
||||
wrapper = mount(StoryboardDiagnosis, { attachTo: document.body, props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] } })
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 }); await flushPromises()
|
||||
vi.mocked(breakdownApi.handOccupancyDiagnostics).mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotCount: 61,
|
||||
evidenceShotCount: 42,
|
||||
warningCount: 0,
|
||||
assessment: 'partial_evidence',
|
||||
diagnostics: []
|
||||
} as never)
|
||||
wrapper = mount(StoryboardDiagnosis, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] }
|
||||
})
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 })
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
expect(drawer.text()).toContain('高级检查详情')
|
||||
expect(drawer.find('.diagnosis-counts').exists()).toBe(false)
|
||||
@@ -52,11 +123,33 @@ describe('单镜头诊断收费前来源检查', () => {
|
||||
})
|
||||
it('确实检出的结构化冲突在普通区域可见,不随高级详情一起隐藏', async () => {
|
||||
mocks()
|
||||
vi.mocked(breakdownApi.handOccupancyDiagnostics).mockResolvedValue({ projectId: 'diag-p', shotCount: 1, evidenceShotCount: 1,
|
||||
warningCount: 1, assessment: 'complete_evidence', diagnostics: [{ episodeNo: 1, beatNo: 1, shotNo: 1, phaseNo: 1,
|
||||
characterRef: '@CH0001', actionIds: ['a1','a2'], code: 'hand_occupancy_conflict', severity: 'warning', suggestion: '右手同时执行了冲突动作' }] } as never)
|
||||
wrapper = mount(StoryboardDiagnosis, { attachTo: document.body, props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] } })
|
||||
await flushPromises(); await wrapper.get('button').trigger('click'); await flushPromises()
|
||||
vi.mocked(breakdownApi.handOccupancyDiagnostics).mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotCount: 1,
|
||||
evidenceShotCount: 1,
|
||||
warningCount: 1,
|
||||
assessment: 'complete_evidence',
|
||||
diagnostics: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
phaseNo: 1,
|
||||
characterRef: '@CH0001',
|
||||
actionIds: ['a1', 'a2'],
|
||||
code: 'hand_occupancy_conflict',
|
||||
severity: 'warning',
|
||||
suggestion: '右手同时执行了冲突动作'
|
||||
}
|
||||
]
|
||||
} as never)
|
||||
wrapper = mount(StoryboardDiagnosis, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] }
|
||||
})
|
||||
await flushPromises()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
const drawer = new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
expect(drawer.text()).toContain('右手同时执行了冲突动作')
|
||||
expect(drawer.find('.diagnosis-evidence-collapse').text()).not.toContain('右手同时执行了冲突动作')
|
||||
@@ -65,14 +158,32 @@ describe('单镜头诊断收费前来源检查', () => {
|
||||
|
||||
it('规则缺失、跨项目、已可复用和不完整检查都不能进入新诊断', () => {
|
||||
expect(diagnosisCanStart(checked(), 'diag-p', 'db-shot')).toBe(true)
|
||||
for (const invalid of [{ projectId: 'other' }, { shotId: 'other' }, { existingValid: true }, { shouldDiagnose: false }, { policyRevision: null }, { policyFingerprint: null }, { errors: ['QUALITY_POLICY_SNAPSHOT_UNKNOWN'] }, { eligibleForFurtherValidation: false }])
|
||||
for (const invalid of [
|
||||
{ projectId: 'other' },
|
||||
{ shotId: 'other' },
|
||||
{ existingValid: true },
|
||||
{ shouldDiagnose: false },
|
||||
{ policyRevision: null },
|
||||
{ policyFingerprint: null },
|
||||
{ errors: ['QUALITY_POLICY_SNAPSHOT_UNKNOWN'] },
|
||||
{ eligibleForFurtherValidation: false }
|
||||
])
|
||||
expect(diagnosisCanStart({ ...checked(), ...invalid }, 'diag-p', 'db-shot')).toBe(false)
|
||||
})
|
||||
it('正式单镜头入口先预检查,缺少规则快照显示中文原因且不发收费请求', async () => {
|
||||
const start = mocks()
|
||||
const read = vi.spyOn(breakdownApi, 'diagnosisPreflight').mockResolvedValue({ ...checked(), shouldDiagnose: false, eligibleForFurtherValidation: false, errors: ['QUALITY_POLICY_SNAPSHOT_UNKNOWN'] })
|
||||
wrapper = mount(StoryboardDiagnosis, { attachTo: document.body, props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] } })
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 }); await flushPromises()
|
||||
const read = vi.spyOn(breakdownApi, 'diagnosisPreflight').mockResolvedValue({
|
||||
...checked(),
|
||||
shouldDiagnose: false,
|
||||
eligibleForFurtherValidation: false,
|
||||
errors: ['QUALITY_POLICY_SNAPSHOT_UNKNOWN']
|
||||
})
|
||||
wrapper = mount(StoryboardDiagnosis, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] }
|
||||
})
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 })
|
||||
await flushPromises()
|
||||
expect(read).toHaveBeenCalledWith('diag-p', 'db-shot')
|
||||
const drawer = new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
expect(drawer.text()).toContain('缺少可信的质量规则记录')
|
||||
@@ -81,41 +192,135 @@ describe('单镜头诊断收费前来源检查', () => {
|
||||
})
|
||||
it('费用确认后再次检查,规则变化时保留只读结果并撤销启动', async () => {
|
||||
const start = mocks()
|
||||
vi.spyOn(breakdownApi, 'diagnosisPreflight').mockResolvedValueOnce(checked()).mockResolvedValue({ ...checked(), policyRevision: 4, policyFingerprint: 'b'.repeat(64) })
|
||||
wrapper = mount(StoryboardDiagnosis, { attachTo: document.body, props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] } })
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 }); await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!).get('[aria-label="启动 AI 复查"]').trigger('click')
|
||||
vi.spyOn(breakdownApi, 'diagnosisPreflight')
|
||||
.mockResolvedValueOnce(checked())
|
||||
.mockResolvedValue({ ...checked(), policyRevision: 4, policyFingerprint: 'b'.repeat(64) })
|
||||
wrapper = mount(StoryboardDiagnosis, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] }
|
||||
})
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 })
|
||||
await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
.get('[aria-label="启动 AI 复查"]')
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
const confirmation = new DOMWrapper(document.querySelector('.app-dialog')!)
|
||||
await confirmation.findAll('button').find(button => button.text() === '确认启动 AI 复查')!.trigger('click')
|
||||
await confirmation
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '确认启动 AI 复查')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(start).not.toHaveBeenCalled()
|
||||
expect(new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!).get('[aria-label="启动 AI 复查"]').attributes('disabled')).toBeDefined()
|
||||
expect(
|
||||
new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
.get('[aria-label="启动 AI 复查"]')
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
})
|
||||
it('镜头描述在费用确认期间变化时必须重新预览,不能直接诊断新内容', async () => {
|
||||
const start = mocks()
|
||||
vi.spyOn(breakdownApi, 'diagnosisPreflight').mockResolvedValue(checked())
|
||||
vi.mocked(breakdownApi.legacyActionDiagnosisPreview).mockResolvedValueOnce(preview()).mockResolvedValue({ ...preview(), candidates: [{ ...preview().candidates[0]!, description: '已更改的新镜头' }] })
|
||||
wrapper = mount(StoryboardDiagnosis, { attachTo: document.body, props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] } })
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 }); await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!).get('[aria-label="启动 AI 复查"]').trigger('click'); await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('.app-dialog')!).findAll('button').find(button => button.text() === '确认启动 AI 复查')!.trigger('click'); await flushPromises()
|
||||
vi.mocked(breakdownApi.legacyActionDiagnosisPreview)
|
||||
.mockResolvedValueOnce(preview())
|
||||
.mockResolvedValue({
|
||||
...preview(),
|
||||
candidates: [{ ...preview().candidates[0]!, description: '已更改的新镜头' }]
|
||||
})
|
||||
wrapper = mount(StoryboardDiagnosis, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'diag-p', episodeNo: 1, episodeNos: [1] }
|
||||
})
|
||||
wrapper.getComponent(StoryboardDiagnosis).vm.open({ episodeNo: 1, beatNo: 1, shotNo: 1 })
|
||||
await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('[aria-label="动作诊断"]')!)
|
||||
.get('[aria-label="启动 AI 复查"]')
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
await new DOMWrapper(document.querySelector('.app-dialog')!)
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '确认启动 AI 复查')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(start).not.toHaveBeenCalled()
|
||||
})
|
||||
it('修订条件与历史按需读取,跨项目响应不显示为可修订', async () => {
|
||||
const history = vi.spyOn(breakdownApi, 'diagnosisHistory').mockResolvedValue({ projectId: 'other', shotId: 'db-shot', count: 0, revisions: [] })
|
||||
vi.spyOn(breakdownApi, 'diagnosisRepairReadiness').mockResolvedValue({ projectId: 'other', shotId: 'db-shot', diagnosisId: 'd', eligible: true, repairCandidates: [], blockingReasons: [], requiresManualReview: true, canApplyDirectly: false, willCallModel: false, willModifyAssets: false })
|
||||
wrapper = mount(DiagnosisShotDetails, { props: { projectId: 'diag-p', shot: { shotId: 'db-shot', episodeNo: 1, beatNo: 1, shotNo: 1, title: '镜头', diagnosisId: 'd', status: 'conflict_found', issues: [], createdAt: null } } })
|
||||
const history = vi
|
||||
.spyOn(breakdownApi, 'diagnosisHistory')
|
||||
.mockResolvedValue({ projectId: 'other', shotId: 'db-shot', count: 0, revisions: [] })
|
||||
vi.spyOn(breakdownApi, 'diagnosisRepairReadiness').mockResolvedValue({
|
||||
projectId: 'other',
|
||||
shotId: 'db-shot',
|
||||
diagnosisId: 'd',
|
||||
eligible: true,
|
||||
repairCandidates: [],
|
||||
blockingReasons: [],
|
||||
requiresManualReview: true,
|
||||
canApplyDirectly: false,
|
||||
willCallModel: false,
|
||||
willModifyAssets: false
|
||||
})
|
||||
wrapper = mount(DiagnosisShotDetails, {
|
||||
props: {
|
||||
projectId: 'diag-p',
|
||||
shot: {
|
||||
shotId: 'db-shot',
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
title: '镜头',
|
||||
diagnosisId: 'd',
|
||||
status: 'conflict_found',
|
||||
issues: [],
|
||||
createdAt: null
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(history).not.toHaveBeenCalled()
|
||||
await wrapper.get('button').trigger('click'); await flushPromises()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('记录与当前镜头不一致')
|
||||
expect(wrapper.text()).not.toContain('已满足人工修订')
|
||||
})
|
||||
it('旧诊断即使只读资格返回 eligible,也不能显示成当前可修订', async () => {
|
||||
vi.spyOn(breakdownApi, 'diagnosisHistory').mockResolvedValue({ projectId: 'diag-p', shotId: 'db-shot', count: 0, revisions: [] })
|
||||
vi.spyOn(breakdownApi, 'diagnosisRepairReadiness').mockResolvedValue({ projectId: 'diag-p', shotId: 'db-shot', diagnosisId: 'd', eligible: true, repairCandidates: [], blockingReasons: [], requiresManualReview: true, canApplyDirectly: false, willCallModel: false, willModifyAssets: false })
|
||||
wrapper = mount(DiagnosisShotDetails, { props: { projectId: 'diag-p', shot: { shotId: 'db-shot', episodeNo: 1, beatNo: 1, shotNo: 1, title: '镜头', diagnosisId: 'd', status: 'stale', policyStatus: 'stale', shotStale: false, issues: [], createdAt: null } } })
|
||||
await wrapper.get('button').trigger('click'); await flushPromises()
|
||||
vi.spyOn(breakdownApi, 'diagnosisHistory').mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotId: 'db-shot',
|
||||
count: 0,
|
||||
revisions: []
|
||||
})
|
||||
vi.spyOn(breakdownApi, 'diagnosisRepairReadiness').mockResolvedValue({
|
||||
projectId: 'diag-p',
|
||||
shotId: 'db-shot',
|
||||
diagnosisId: 'd',
|
||||
eligible: true,
|
||||
repairCandidates: [],
|
||||
blockingReasons: [],
|
||||
requiresManualReview: true,
|
||||
canApplyDirectly: false,
|
||||
willCallModel: false,
|
||||
willModifyAssets: false
|
||||
})
|
||||
wrapper = mount(DiagnosisShotDetails, {
|
||||
props: {
|
||||
projectId: 'diag-p',
|
||||
shot: {
|
||||
shotId: 'db-shot',
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
title: '镜头',
|
||||
diagnosisId: 'd',
|
||||
status: 'stale',
|
||||
policyStatus: 'stale',
|
||||
shotStale: false,
|
||||
issues: [],
|
||||
createdAt: null
|
||||
}
|
||||
}
|
||||
})
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('已满足人工修订')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user