feat(short-drama-agent-front): 新增拆解候选与质量修订
This commit is contained in:
1 parent
49ad08a63e
commit
3414cc8232
32 files changed
+2319
-454
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { NSelect, NSpin } from 'naive-ui'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import BreakdownPage from '@/features/breakdown/BreakdownPage.vue'
|
||||
import { projectContextKey, type useProjectData } from '@/features/projects/context'
|
||||
@@ -206,12 +206,12 @@ function handDiagnosticsResponse(evidenceShotCount: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从真实挂载的抽屉读取内容,不把诊断抽屉误当成拆解设置弹窗。
|
||||
* @returns 当前动作诊断抽屉
|
||||
* 从真实挂载的动作诊断弹窗读取内容,避免误取拆解设置弹窗。
|
||||
* @returns 当前动作诊断弹窗
|
||||
*/
|
||||
function qualityDrawer() {
|
||||
const panel = document.querySelector<HTMLElement>('.storyboard-diagnosis-drawer')
|
||||
if (!panel) throw new Error('动作诊断抽屉未打开')
|
||||
function qualityDialog() {
|
||||
const panel = document.querySelector<HTMLElement>('.app-dialog[aria-label="动作诊断"]')
|
||||
if (!panel) throw new Error('动作诊断弹窗未打开')
|
||||
return new DOMWrapper(panel)
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\);/)
|
||||
})
|
||||
|
||||
it('分镜选择与计数、入口同排,默认显示实际剧集,切换后内容和统计同步', async () => {
|
||||
it('分镜选择与计数同排且没有阶段快捷入口,切换后内容和统计同步', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async () => diagnosisResultsResponse())
|
||||
@@ -410,9 +410,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(select.props('value')).toBe(1)
|
||||
expect(toolbar.text()).toContain('长剧集')
|
||||
expect(toolbar.get('.breakdown-storyboard-summary').text()).toContain('25 个节拍 · 25 个镜头')
|
||||
expect(toolbar.get('.breakdown-storyboard-summary router-link-stub').attributes('to')).toBe(
|
||||
'/projects/breakdown-scroll-test/storyboard'
|
||||
)
|
||||
expect(toolbar.find('router-link-stub').exists()).toBe(false)
|
||||
expect(wrapper!.find('.breakdown-storyboard > .surface-inset').exists()).toBe(false)
|
||||
select.vm.$emit('update:value', 2)
|
||||
await flushPromises()
|
||||
@@ -427,7 +425,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(wrapper!.findAll('.beat-section')).toHaveLength(25)
|
||||
})
|
||||
|
||||
it('分镜为空时保留空提示与进入设计入口,不显示空选择器', async () => {
|
||||
it('分镜为空时仅保留空提示,不显示空选择器或阶段快捷入口', async () => {
|
||||
const record = checkpoint()
|
||||
record.state.breakdownResult!.storyboardPlans = []
|
||||
record.state.breakdownResult!.storyboardEpisodeShots = []
|
||||
@@ -435,9 +433,8 @@ describe('拆解页内容滚动', () => {
|
||||
await selectTab('分镜')
|
||||
expect(wrapper!.get('.breakdown-storyboard').text()).toContain('分镜规划尚未生成')
|
||||
expect(wrapper!.find('.breakdown-episode-picker').exists()).toBe(false)
|
||||
expect(wrapper!.get('.breakdown-storyboard-summary router-link-stub').attributes('to')).toBe(
|
||||
'/projects/breakdown-scroll-test/storyboard'
|
||||
)
|
||||
expect(wrapper!.find('.breakdown-storyboard-toolbar').exists()).toBe(false)
|
||||
expect(wrapper!.find('.breakdown-storyboard router-link-stub').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('分镜顶部无叠加操作行,选择标签保持单行且统计操作垂直居中', () => {
|
||||
@@ -516,7 +513,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(drawerPanel().text()).toContain('重试失败抽取')
|
||||
})
|
||||
|
||||
it('诊断摘要与抽屉按需读取,展开结构化校验后展示证据不足', async () => {
|
||||
it('诊断摘要与弹窗按需读取,展开结构化校验后展示证据不足', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) return diagnosisResultsResponse()
|
||||
@@ -531,17 +528,124 @@ describe('拆解页内容滚动', () => {
|
||||
expect(String(fetcher.mock.calls[0]?.[0])).toContain('diagnosis-results?episodeNo=1')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDrawer()
|
||||
const panel = qualityDialog()
|
||||
expect(panel.findAll('button').some(button => button.text() === '刷新校验')).toBe(false)
|
||||
expect(panel.get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('false')
|
||||
const footer = panel.get('.n-card__footer')
|
||||
expect(footer.text()).toContain('预览诊断范围')
|
||||
expect(footer.text()).toContain('启动 AI 诊断')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.text()).toContain('有效动作证据 0 / 25 镜')
|
||||
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()
|
||||
expect(panel.findAll('button').some(button => button.text() === '刷新校验')).toBe(false)
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([input]) => String(input).endsWith('storyboard-hand-occupancy-diagnostics'))
|
||||
).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('关闭抽屉后的迟到校验响应不会污染再次打开的状态', async () => {
|
||||
it('刷新已加载的诊断结果只显示按钮加载,保留正文节点、折叠展开和滚动位置', async () => {
|
||||
let resultRequests = 0
|
||||
let resolveRefresh: ((value: Response) => void) | undefined
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) {
|
||||
resultRequests++
|
||||
if (resultRequests > 2)
|
||||
return new Promise<Response>(resolve => {
|
||||
resolveRefresh = resolve
|
||||
})
|
||||
return diagnosisResultsResponse()
|
||||
}
|
||||
if (url.endsWith('storyboard-hand-occupancy-diagnostics')) return handDiagnosticsResponse(0)
|
||||
throw new Error(`未预期的诊断请求:${url}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
mountPage()
|
||||
await selectTab('分镜')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDialog()
|
||||
await panel.findAll('.n-collapse-item__header-main')[1]!.trigger('click')
|
||||
await flushPromises()
|
||||
const content = panel.get('.diagnosis-dialog-content').element
|
||||
const scroll = panel.get<HTMLElement>('.dialog-body-scroll .n-scrollbar-container').element
|
||||
scroll.scrollTop = 80
|
||||
const refreshButton = panel.findAll('button').find(button => button.text() === '刷新结果')!
|
||||
const refreshIcon = refreshButton.get('.n-button__icon').element
|
||||
await refreshButton.trigger('click')
|
||||
await flushPromises()
|
||||
try {
|
||||
const spin = wrapper!
|
||||
.findAllComponents(NSpin)
|
||||
.find(item => item.classes().includes('storyboard-diagnosis-dialog'))!
|
||||
expect(spin.props('show')).toBe(false)
|
||||
expect(refreshButton.classes()).toContain('n-button--loading')
|
||||
expect(refreshButton.get('.n-button__icon').element).toBe(refreshIcon)
|
||||
expect(panel.get('.diagnosis-dialog-content').element).toBe(content)
|
||||
expect(panel.find('.diagnosis-concurrency').isVisible()).toBe(true)
|
||||
expect(scroll.scrollTop).toBe(80)
|
||||
expect(panel.text()).toContain('当前范围尚无镜头')
|
||||
} finally {
|
||||
resolveRefresh!(diagnosisResultsResponse())
|
||||
await flushPromises()
|
||||
}
|
||||
expect(refreshButton.classes()).not.toContain('n-button--loading')
|
||||
expect(panel.get('.diagnosis-dialog-content').element).toBe(content)
|
||||
})
|
||||
|
||||
it('刷新已加载的结构化校验保留证据正文和图标占位,不触发整窗遮罩', async () => {
|
||||
let handRequests = 0
|
||||
let resolveRefresh: ((value: Response) => void) | undefined
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) return diagnosisResultsResponse()
|
||||
if (url.endsWith('storyboard-hand-occupancy-diagnostics')) {
|
||||
handRequests++
|
||||
if (handRequests > 1)
|
||||
return new Promise<Response>(resolve => {
|
||||
resolveRefresh = resolve
|
||||
})
|
||||
return handDiagnosticsResponse(0)
|
||||
}
|
||||
throw new Error(`未预期的诊断请求:${url}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
mountPage()
|
||||
await selectTab('分镜')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDialog()
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
const evidence = panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element
|
||||
const refreshButton = panel.findAll('button').find(button => button.text() === '刷新校验')!
|
||||
const refreshIcon = refreshButton.find('.n-button__icon')
|
||||
await refreshButton.trigger('click')
|
||||
await flushPromises()
|
||||
try {
|
||||
expect(panel.text()).toContain('有效动作证据 0 / 25 镜')
|
||||
expect(panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element).toBe(evidence)
|
||||
const spin = wrapper!
|
||||
.findAllComponents(NSpin)
|
||||
.find(item => item.classes().includes('storyboard-diagnosis-dialog'))!
|
||||
expect(spin.props('show')).toBe(false)
|
||||
expect(refreshButton.classes()).toContain('n-button--loading')
|
||||
expect(refreshIcon.exists()).toBe(true)
|
||||
expect(refreshButton.get('.n-button__icon').element).toBe(refreshIcon.element)
|
||||
} finally {
|
||||
resolveRefresh!(handDiagnosticsResponse(0))
|
||||
await flushPromises()
|
||||
}
|
||||
expect(refreshButton.classes()).not.toContain('n-button--loading')
|
||||
expect(panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element).toBe(evidence)
|
||||
expect(panel.get('.n-collapse-item__header-extra button').element).toBe(refreshButton.element)
|
||||
})
|
||||
|
||||
it('打开诊断弹窗时展示加载态,关闭后的迟到校验响应不污染新状态', async () => {
|
||||
let resolveFirst: ((value: Response) => void) | undefined
|
||||
let handRequests = 0
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
@@ -563,13 +667,22 @@ describe('拆解页内容滚动', () => {
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(handRequests).toBe(1)
|
||||
await qualityDrawer().get('.n-drawer-header__close').trigger('click')
|
||||
expect(qualityDialog().get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('true')
|
||||
expect(qualityDialog().text()).not.toContain('诊断结果')
|
||||
expect(
|
||||
qualityDialog()
|
||||
.get('.n-card__footer')
|
||||
.findAll('button')
|
||||
.every(button => (button.element as HTMLButtonElement).disabled)
|
||||
).toBe(true)
|
||||
await qualityDialog().get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
resolveFirst!(handDiagnosticsResponse(25))
|
||||
await flushPromises()
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDrawer()
|
||||
const panel = qualityDialog()
|
||||
expect(panel.get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('false')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.text()).not.toContain('有效动作证据 25 / 25')
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import BreakdownCandidatePanel from '@/features/breakdown/components/BreakdownCandidatePanel.vue'
|
||||
import ConfirmAction from '@/features/workflows/ConfirmAction.vue'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
|
||||
/** 候选完整性只使用最新原始状态。 */
|
||||
const state = {
|
||||
candidateOnly: true,
|
||||
storyboardShotValidation: { valid: true, issues: [] },
|
||||
expectedEpisodeFingerprints: { 1: 'fingerprint' },
|
||||
runConfig: { groupSize: 3, modules: [] as [], episodeGroups: [], sourceEpisodes: [{ episodeNo: 1 }] },
|
||||
subjectCandidates: [
|
||||
{
|
||||
profileId: 'p',
|
||||
name: '人物',
|
||||
ref: '@人物',
|
||||
module: 'character' as const,
|
||||
description: '',
|
||||
appearance_prompt: ''
|
||||
}
|
||||
],
|
||||
subjectForms: [],
|
||||
storyboardEpisodeShots: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
episodePlan: { episodeNo: 1 } as never,
|
||||
beatShots: [
|
||||
{
|
||||
beatNo: 1,
|
||||
shots: [
|
||||
{ shotNo: 1, title: '', description: '', visualFocus: '', subjectRefs: [], durationSeconds: 2 }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
vi.restoreAllMocks()
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
describe('候选版本与提交保护', () => {
|
||||
it('当前版本仍有效时仅提交一次并刷新正式结果', async () => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([
|
||||
{ checkpointId: 'ready', createdAt: '', workflowName: 'breakdown', state }
|
||||
])
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({
|
||||
projectId: 'candidate-ready-test',
|
||||
subjectCount: 1,
|
||||
subjectFormCount: 0,
|
||||
episodeCount: 1,
|
||||
beatCount: 1,
|
||||
shotCount: 1,
|
||||
shotSubjectCount: 0
|
||||
})
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-ready-test', checkpointId: 'ready', state, disabled: false }
|
||||
})
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
await flushPromises()
|
||||
expect(commit).toHaveBeenCalledExactlyOnceWith('candidate-ready-test')
|
||||
expect(wrapper.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('确认之后发现服务端版本已变化时禁止提交正式替换', async () => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([
|
||||
{ checkpointId: 'new', createdAt: '', workflowName: 'breakdown', state }
|
||||
])
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-version-test', checkpointId: 'old', state, disabled: false }
|
||||
})
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
await flushPromises()
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(wrapper.text()).toContain('候选版本已变化')
|
||||
expect(wrapper.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('新快照无明确候选标记时不恢复旧候选提交入口', async () => {
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-marker-test', checkpointId: 'old', state, disabled: false }
|
||||
})
|
||||
expect(wrapper.text()).toContain('提交候选为正式结果')
|
||||
await wrapper.setProps({ checkpointId: 'new', state: {} })
|
||||
expect(wrapper.findComponent(ConfirmAction).exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it, vi, afterEach } from 'vitest'
|
||||
import { candidateCommitIssue } from '@/features/breakdown/candidate'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
import type { BreakdownState } from '@/features/breakdown/types'
|
||||
|
||||
/** 构造已完成审核但尚未入库的候选快照。 */
|
||||
function readyCandidate(): BreakdownState {
|
||||
return {
|
||||
candidateOnly: true,
|
||||
storyboardPersisted: false,
|
||||
expectedEpisodeFingerprints: { 1: 'fingerprint' },
|
||||
runConfig: { groupSize: 3, modules: ['character'], episodeGroups: [], sourceEpisodes: [{ episodeNo: 1 }] },
|
||||
subjectCandidates: [
|
||||
{
|
||||
profileId: 'person',
|
||||
name: '人物',
|
||||
ref: '@人物',
|
||||
description: '',
|
||||
module: 'character',
|
||||
appearance_prompt: ''
|
||||
}
|
||||
],
|
||||
subjectForms: [],
|
||||
storyboardEpisodeShots: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
episodePlan: { episodeNo: 1 } as never,
|
||||
beatShots: [
|
||||
{
|
||||
beatNo: 1,
|
||||
shots: [
|
||||
{
|
||||
shotNo: 1,
|
||||
title: '镜头',
|
||||
description: '',
|
||||
visualFocus: '',
|
||||
subjectRefs: [],
|
||||
durationSeconds: 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
storyboardShotValidation: { valid: true, issues: [] },
|
||||
storyboardPendingQualityEpisodeNos: []
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('候选提交资格', () => {
|
||||
it('只允许完整、未提交、审核通过的候选快照进入确认', () => {
|
||||
expect(candidateCommitIssue(readyCandidate())).toBe('')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), candidateOnly: false })).toContain('候选')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardPersisted: true })).toContain('提交')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardPendingQualityEpisodeNos: [1] })).toContain('审核')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardShotValidation: undefined })).toContain('校验')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), expectedEpisodeFingerprints: undefined })).toContain('版本')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardEpisodeShots: [] })).toContain('完整')
|
||||
})
|
||||
|
||||
it('启动明确发送候选模式,提交不发送客户端资产', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: { projectId: 'p/id' } })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await breakdownApi.run('p/id', 'start', { groupSize: 3, modules: ['character'], candidateOnly: true })
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string).candidateOnly).toBe(true)
|
||||
await breakdownApi.commitCandidate('p/id')
|
||||
expect(fetcher.mock.calls[1]![0]).toContain('/projects/p%2Fid/breakdown/commit-candidate')
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1]!.body as string)).toEqual({ confirmed: true })
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { actionDraft, actionDraftIssue } from '@/features/breakdown/repair'
|
||||
import type { ShotActionDraft } from '@/features/breakdown/repair.types'
|
||||
|
||||
/** 含手部和身体资源证据的真实字段夹具。 */
|
||||
const saved: ShotActionDraft = {
|
||||
requiredActions: [{ id: 'a', description: '扶住栏杆', kind: 'action', mustPerformInShot: true }],
|
||||
durationPlanning: {
|
||||
complexity: 'low',
|
||||
phases: [
|
||||
{
|
||||
action: '站稳',
|
||||
actionIds: ['a'],
|
||||
estimatedSeconds: 2,
|
||||
handOccupancy: [{ actionId: 'a', characterRef: '@人物', hands: 'left' }],
|
||||
resourceOccupancy: [
|
||||
{ actionId: 'a', ownerRef: '@人物', resource: 'left_hand', usage: 'hold', shareable: false }
|
||||
]
|
||||
}
|
||||
],
|
||||
transitionSeconds: 0,
|
||||
recommendedDurationSeconds: 2,
|
||||
reason: '保持稳定'
|
||||
}
|
||||
}
|
||||
describe('镜头动作修订草稿', () => {
|
||||
it('完整保留证据且编辑草稿不污染源镜头', () => {
|
||||
const draft = actionDraft(saved)
|
||||
draft.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage = 'support'
|
||||
expect(saved.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage).toBe('hold')
|
||||
expect(draft.durationPlanning.phases[0]!.handOccupancy).toEqual(saved.durationPlanning.phases[0]!.handOccupancy)
|
||||
expect(actionDraftIssue(draft)).toBe('')
|
||||
})
|
||||
it('拒绝失效的动作引用、重复编号和无效阶段时长', () => {
|
||||
const draft = actionDraft(saved)
|
||||
draft.requiredActions[0]!.id = 'changed'
|
||||
expect(actionDraftIssue(draft)).toContain('引用')
|
||||
draft.requiredActions.push({ ...draft.requiredActions[0]! })
|
||||
expect(actionDraftIssue(draft)).toContain('编号')
|
||||
draft.requiredActions = [{ ...saved.requiredActions[0]! }]
|
||||
draft.durationPlanning.phases[0]!.estimatedSeconds = 0
|
||||
expect(actionDraftIssue(draft)).toContain('时长')
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { productionApi } from '@/features/production/api'
|
||||
import { validateProductionScope } from '@/features/production/useAdvancedProduction'
|
||||
import { productionResumeIssues, validateProductionScope } from '@/features/production/useAdvancedProduction'
|
||||
import type { ProductionStartInput } from '@/features/production/types'
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
@@ -59,4 +59,23 @@ describe('生产后端真实请求契约', () => {
|
||||
validateProductionScope({ startFrom: 'subjectImages', stopAfter: 'subjectImages', videoPromptLimit: 1 })
|
||||
).toBe('')
|
||||
})
|
||||
|
||||
it('指定续跑阶段时要求已有有效资产,不能把可生成误判为已完成', () => {
|
||||
const stage = { total: 1, planned: 1, skipped: 0, upstreamResolvable: 0, manualBlocked: 0 }
|
||||
const plan = { subjectImages: stage, keyframes: stage }
|
||||
expect(productionResumeIssues(plan, {})).toEqual([])
|
||||
expect(productionResumeIssues(plan, { startFrom: 'subjectImages' }).join()).toContain('角色身份')
|
||||
expect(productionResumeIssues(plan, { startFrom: 'keyframes' }).join()).toContain('主体参考图')
|
||||
expect(productionResumeIssues(plan, { startFrom: 'videoPrompts' }).join()).toContain('有效首帧')
|
||||
expect(
|
||||
productionResumeIssues(
|
||||
{
|
||||
characterIdentity: { total: 1, ready: 1, pending: 0, autoResolvable: 0, manualBlocked: 0 },
|
||||
subjectImages: { ...stage, skipped: 1, planned: 0 },
|
||||
keyframes: { ...stage, skipped: 1, planned: 0 }
|
||||
},
|
||||
{ startFrom: 'videoPrompts' }
|
||||
)
|
||||
).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,45 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { policyDraft, policyIssue } from '@/features/projects/quality-policy'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import type { ProjectQualityPolicy } from '@/features/projects/types'
|
||||
|
||||
/** 保留已有精确例外的服务端完整策略。 */
|
||||
const saved: ProjectQualityPolicy = {
|
||||
version: 1,
|
||||
physicsMode: 'realistic',
|
||||
allowExaggeratedMotion: false,
|
||||
allowNonPhysicalActions: false,
|
||||
allowSupernaturalAbilities: false,
|
||||
customRules: ['规则'],
|
||||
actionExceptions: [
|
||||
{ code: 'action_resource_conflict', ownerRef: '@人物', resource: 'left_hand', reason: '明确依据' }
|
||||
]
|
||||
}
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
describe('项目质量策略', () => {
|
||||
it('草稿编辑不污染已保存策略,完整保留精确例外', () => {
|
||||
const draft = policyDraft(saved)
|
||||
draft.actionExceptions![0]!.reason = '新依据'
|
||||
draft.customRules.push('新规则')
|
||||
expect(saved.actionExceptions![0]!.reason).toBe('明确依据')
|
||||
expect(saved.customRules).toEqual(['规则'])
|
||||
expect(policyIssue(draft)).toBe('')
|
||||
})
|
||||
it('拒绝超过上限或缺少精确例外依据的规则', () => {
|
||||
expect(policyIssue({ ...saved, customRules: [''] })).toContain('规则')
|
||||
expect(policyIssue({ ...saved, customRules: Array(31).fill('规则') })).toContain('30')
|
||||
expect(policyIssue({ ...saved, actionExceptions: [{ ...saved.actionExceptions![0]!, reason: '' }] })).toContain(
|
||||
'依据'
|
||||
)
|
||||
})
|
||||
it('完整提交正式质量策略接口,保留用户明确的权限选择', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: { projectId: 'p', policy: saved } })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await projectsApi.saveQualityPolicy('p', saved)
|
||||
expect(fetcher.mock.calls[0]![0]).toContain('/projects/p/quality-policy')
|
||||
expect(fetcher.mock.calls[0]![1]!.method).toBe('PUT')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string)).toEqual(saved)
|
||||
})
|
||||
})
|
||||
@@ -2094,18 +2094,22 @@ describe('工作台页面交互', () => {
|
||||
await expandSections()
|
||||
button('预览分组').click()
|
||||
await flushPromises()
|
||||
expect(button('开始拆解').disabled).toBe(false)
|
||||
expect(button('生成拆解候选').disabled).toBe(false)
|
||||
await drawerPanel().get('#group-size').setValue('2')
|
||||
expect(document.body.textContent).not.toContain('开始拆解')
|
||||
expect(document.body.textContent).not.toContain('生成拆解候选')
|
||||
button('预览分组').click()
|
||||
await flushPromises()
|
||||
button('开始拆解').click()
|
||||
button('生成拆解候选').click()
|
||||
await flushPromises()
|
||||
button('确认开始拆解').click()
|
||||
button('确认生成拆解候选').click()
|
||||
await flushPromises()
|
||||
const post = fetcher.mock.calls.find(call => call[1]?.method === 'POST')
|
||||
expect(post?.[0]).toBe('/api/projects/page-test-project/breakdown/start')
|
||||
expect(JSON.parse(post![1]!.body as string)).toEqual({ groupSize: 2, modules: ['character', 'scene', 'prop'] })
|
||||
expect(JSON.parse(post![1]!.body as string)).toEqual({
|
||||
groupSize: 2,
|
||||
modules: ['character', 'scene', 'prop'],
|
||||
candidateOnly: true
|
||||
})
|
||||
expect(provided.refresh).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user