feat(short-drama-agent-front): 接入关系修复并优化配置与弹窗

This commit is contained in:
GJ committed 2026-10-31 22:37:22 +08:00
1 parent 2db8549818
commit 41d1cfe3ed
15 files changed
+1134 -323

No files matched your search

+26 -1
View File
@@ -513,7 +513,26 @@ describe('管理后台组件边界', () => {
expect(wrapper.find('.project-header .n-tag').exists()).toBe(false)
})
it('确认按钮有稳定根元素承接调用方间距,生产卡片用网格间距排列操作', () => {
it('公共弹窗状态仅在标题旁提示,默认不显示图标,切换状态不影响正文', async () => {
wrapper = mount(AppDialog, {
attachTo: document.body,
props: { open: true, title: '操作结果' },
slots: { default: '<p>请核对当前内容。</p>' }
})
await flushPromises()
expect(document.querySelector('.n-card-header [role="img"]')).toBeNull()
await wrapper.setProps({ status: 'warning' })
expect(document.querySelector('.n-card-header [aria-label="警告"]')).not.toBeNull()
await wrapper.setProps({ status: 'success' })
expect(document.querySelector('.n-card-header [aria-label="警告"]')).toBeNull()
expect(document.querySelector('.n-card-header [aria-label="成功"]')).not.toBeNull()
await wrapper.setProps({ status: 'error' })
expect(document.querySelector('.n-card-header [aria-label="成功"]')).toBeNull()
expect(document.querySelector('.n-card-header [aria-label="错误"]')).not.toBeNull()
expect(document.querySelector('.dialog-body-scroll')?.textContent).toContain('请核对当前内容。')
})
it('确认按钮有稳定根元素,操作说明始终位于正文,标题说明可省略', async () => {
wrapper = mount(ConfirmAction, {
props: { label: '测试操作', description: '仅展示,不提交请求' },
attrs: { class: 'mt-4' }
@@ -522,6 +541,12 @@ describe('管理后台组件边界', () => {
expect(wrapper.classes()).toContain('confirm-action')
expect(wrapper.classes()).toContain('mt-4')
expect(wrapper.get('button').text()).toBe('测试操作')
await wrapper.get('button').trigger('click')
await flushPromises()
const dialog = document.querySelector('.app-dialog')!
expect(dialog.querySelector('.n-card-header [aria-label="警告"]')).not.toBeNull()
expect(dialog.querySelector('.n-card-header')?.textContent).not.toContain('仅展示,不提交请求')
expect(dialog.querySelector('.dialog-body-scroll')?.textContent).toContain('仅展示,不提交请求')
expect(readAllStyles()).toMatch(/\.production-pipeline-card\s*\{[^}]*display:\s*grid;[^}]*gap:\s*16px;/)
})
})
@@ -24,9 +24,41 @@ import {
import { projectsApi } from '@/features/projects/api'
import type { ProjectQualityPolicy } from '@/features/projects/types'
import { getOperation } from '@/features/workflows/operations'
import { WorkspaceTools } from '@/components/ui'
import BreakdownCandidatePanel from '@/features/breakdown/components/BreakdownCandidatePanel.vue'
import { commitPreview } from '../../fixtures/breakdown-candidate'
let wrapper: VueWrapper | undefined
it('候选预检可从工具栏直达,从设置进入先关闭原抽屉再预检,成功后刷新全部阶段', async () => {
vi.spyOn(breakdownApi, 'revalidateCandidate').mockResolvedValue(
candidateReview({ projectId: 'breakdown-scroll-test' })
)
const preview = vi
.spyOn(breakdownApi, 'candidateCommitPreview')
.mockResolvedValue(commitPreview({ projectId: 'breakdown-scroll-test' }))
const context = mountPage([candidateCheckpoint(candidateState({ projectId: 'breakdown-scroll-test' }))])
await flushPromises()
expect(wrapper!.find('[aria-label="候选安全预检"]').exists()).toBe(true)
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
await drawerPanel()
.findAll('button')
.find(button => button.text() === '候选安全预检')!
.trigger('click')
expect(wrapper!.getComponent(WorkspaceTools).props('open')).toBe(false)
expect(wrapper!.getComponent(BreakdownCandidatePanel).props('open')).toBe(false)
expect(preview).not.toHaveBeenCalled()
wrapper!.getComponent(WorkspaceTools).vm.$emit('closed')
await flushPromises()
expect(wrapper!.getComponent(BreakdownCandidatePanel).props('open')).toBe(true)
expect(preview).toHaveBeenCalledOnce()
wrapper!.getComponent(BreakdownCandidatePanel).vm.$emit('refresh')
await flushPromises()
expect(context.refresh).toHaveBeenCalled()
expect(context.refreshStageReadiness).toHaveBeenCalled()
})
it('没有拆解数据时提供居中的主设置入口,只打开现有抽屉,不预览或生成', async () => {
const preview = vi.spyOn(breakdownApi, 'preview')
const run = vi.spyOn(breakdownApi, 'run')
+229 -63
View File
@@ -7,8 +7,9 @@ import { breakdownQuality, selectBreakdownSource } from '@/features/breakdown/qu
import { getOperation } from '@/features/workflows/operations'
import { candidateCheckpoint, candidateReview, candidateState, commitPreview } from '../../fixtures/breakdown-candidate'
import type { CandidateCommitPreview } from '@/features/breakdown/candidate.types'
import { NButton } from 'naive-ui'
/** 真实确认弹窗挂载于 body,验证完成后清理。 */
/** 真实全屏抽屉挂载于 body,测试仅模拟网络,不接触项目数据。 */
let wrapper: VueWrapper | undefined
beforeEach(() => {
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([candidateCheckpoint()])
@@ -20,11 +21,13 @@ afterEach(() => {
vi.restoreAllMocks()
})
/** 创建质量已通过但尚未经过安全预检查的面板。 */
/** 创建尚未打开的安全预检抽屉,不自动执行请求。 */
function openPanel() {
wrapper = mount(BreakdownCandidatePanel, {
attachTo: document.body,
props: {
open: false,
'onUpdate:open': (value: boolean) => wrapper?.setProps({ open: value }),
projectId: 'candidate-project',
checkpointId: 'candidate-current',
state: candidateState(),
@@ -35,28 +38,68 @@ function openPanel() {
return wrapper
}
/** 点击只读预检查入口,不直接提交。 */
/** 打开只读预检查抽屉,不直接提交。 */
async function checkCandidate() {
await wrapper!
.findAll('button')
.find(button => button.text() === '提交候选为正式结果')!
.trigger('click')
await wrapper!.setProps({ open: true })
await flushPromises()
}
/** 用户勾选并点击最终确认按钮。 */
async function confirmCandidate() {
const dialog = new DOMWrapper(document.querySelector<HTMLElement>('.app-dialog'))
await dialog.get('[role="checkbox"]').trigger('click')
await dialog
/** 取得当前打开的预检抽屉正文及固定底栏。 */
function drawer() {
return new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
}
/**
* 点击抽屉内的真实操作按钮。
* @param label 按钮可见名称
*/
async function clickAction(label: string) {
const button = drawer()
.findAll('button')
.find(button => button.text() === '确认提交候选为正式结果')!
.trigger('click')
.find(item => item.text() === label)
expect(button, `缺少操作:${label}`).toBeDefined()
await button!.trigger('click')
await flushPromises()
}
/** 用户勾选固定底栏的确认,再点击最终提交。 */
async function confirmCandidate() {
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
await clickAction('确认提交候选为正式结果')
}
/** 两条关系仅为隔离测试样例,保留原始证据空格以检验请求不被改写。 */
function relationPreview() {
const result = commitPreview({ ready: false })
result.checks.relationEvidenceValid = false
result.relationIssues = ['@SC0002 位于→测试空地', '@PR0001 悬挂于→测试横木']
result.relationRepairTargets = [
{
subjectRef: '@SC0002',
subjectName: '测试场景',
relation: '位于',
target: '测试空地',
evidence: ' 原始证据 '
},
{
subjectRef: '@PR0001',
subjectName: '测试铜铃',
relation: '悬挂于',
target: '测试横木',
evidence: '另一条证据'
}
]
return result
}
/** 选择第一条真实返回的关系;选择不代表确认。 */
async function selectRelation() {
await drawer().get('input[type="radio"]').setValue(true)
await flushPromises()
}
describe('候选预检查与最终提交门禁', () => {
it('审核通过不会直接提交;预检查及最终确认均通过后只提交一次并刷新', async () => {
it('打开仅预检,固定底栏明确确认后重新核对版本和门禁,只提交一次并刷新', async () => {
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(commitPreview())
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({
projectId: 'candidate-project',
@@ -69,56 +112,46 @@ describe('候选预检查与最终提交门禁', () => {
})
openPanel()
expect(preview).not.toHaveBeenCalled()
expect(commit).not.toHaveBeenCalled()
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(true)
await wrapper!
.findAll('button')
.find(button => button.text() === '重新检查')!
.trigger('click')
expect(wrapper!.emitted('refresh')).toHaveLength(1)
await checkCandidate()
expect(commit).not.toHaveBeenCalled()
expect(document.querySelector('.app-dialog')?.textContent).toContain('确认提交候选为正式结果')
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
await confirmCandidate()
expect(preview).toHaveBeenCalledTimes(2)
expect(commit).toHaveBeenCalledExactlyOnceWith('candidate-project')
expect(wrapper!.emitted('refresh')).toHaveLength(2)
expect(wrapper!.text()).toContain('拆解结果已保存并采用')
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
await wrapper!.setProps({
state: candidateState({ storyboardPersisted: true, candidateCommitted: true }),
quality: breakdownQuality(
selectBreakdownSource([
candidateCheckpoint(candidateState({ storyboardPersisted: true, candidateCommitted: true }))
]),
null
)
})
expect(wrapper!.findAll('button').some(button => button.text() === '提交候选为正式结果')).toBe(false)
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
expect(wrapper!.emitted('refresh')).toHaveLength(1)
expect(wrapper!.emitted('update:open')?.at(-1)).toEqual([false])
})
it('ready=false 显示未通过项且不打开最终确认', async () => {
const result = commitPreview()
result.ready = false
it('ready=false 展示未通过项,禁止最终确认', async () => {
const result = commitPreview({ ready: false })
result.checks.noProtectedShots = false
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
openPanel()
await checkCandidate()
expect(wrapper!.text()).toContain('没有需要保护的镜头资产')
expect(document.querySelector('.app-dialog')).toBeNull()
expect(drawer().text()).toContain('镜头资产')
expect(drawer().text()).not.toContain('确认提交候选为正式结果')
expect(commit).not.toHaveBeenCalled()
})
it('即使 ready=true,缺少一项安全门禁也禁止确认', async () => {
const result = commitPreview()
result.checks.noSubjectImages = false
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
it('已提交分支不伪造缺失检查失败,刷新页面且隐藏所有写入口', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue({
projectId: 'candidate-project',
checkpointId: 'new-committed',
readOnly: true,
ready: false,
status: 'already_committed',
reason: '最新候选已正式提交'
})
openPanel()
await checkCandidate()
expect(document.querySelector('.app-dialog')).toBeNull()
expect(wrapper!.text()).toContain('主体图片')
expect(drawer().text()).toContain('已提交正式结果')
expect(drawer().find('[aria-label="未通过的提交安全检查"]').exists()).toBe(false)
expect(drawer().text()).not.toContain('确认提交候选为正式结果')
expect(wrapper!.emitted('refresh')).toHaveLength(1)
})
it('最终确认重新发现版本变化时禁止替换并要求刷新', async () => {
it('最终提交时发现来源版本变化,拒绝替换并刷新', async () => {
vi.mocked(projectsApi.checkpoints).mockResolvedValue([candidateCheckpoint(candidateState(), 'new')])
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(commitPreview())
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
@@ -129,10 +162,11 @@ describe('候选预检查与最终提交门禁', () => {
expect(getOperation('candidate-project').error).toContain('版本已变化')
expect(wrapper!.emitted('refresh')).toHaveLength(1)
})
it('最终确认时安全条件改变,原先通过的预检查不能继续使用', async () => {
it('最终确认发现安全条件变化,不沿用原许可', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview')
.mockResolvedValueOnce(commitPreview())
.mockResolvedValueOnce(commitPreview({ ready: false }))
.mockResolvedValueOnce(relationPreview())
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
openPanel()
await checkCandidate()
@@ -140,9 +174,10 @@ describe('候选预检查与最终提交门禁', () => {
expect(commit).not.toHaveBeenCalled()
expect(getOperation('candidate-project').error).toContain('安全条件已变化')
})
it('版本变化后晚到的预检查响应不会重新打开确认窗口', async () => {
it.each(['close', 'project'] as const)('读取期间 %s,晚到的响应不回填原抽屉', async action => {
let resolve!: (value: CandidateCommitPreview) => void
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(
() =>
new Promise(done => {
resolve = done
@@ -150,19 +185,150 @@ describe('候选预检查与最终提交门禁', () => {
)
openPanel()
await checkCandidate()
await wrapper!
.findAll('button')
.find(button => button.text() === '提交候选为正式结果')!
.trigger('click')
expect(preview).toHaveBeenCalledTimes(1)
await wrapper!.setProps({ checkpointId: 'new' })
if (action === 'close') await wrapper!.setProps({ open: false })
else await wrapper!.setProps({ projectId: 'other-project', disabled: true })
resolve(commitPreview())
await flushPromises()
expect(document.querySelector('.app-dialog')).toBeNull()
expect(document.body.textContent).not.toContain('确认提交候选为正式结果')
})
it('新快照没有候选标记时不会复用旧候选入口', async () => {
})
describe('候选关系人工修复', () => {
it('真实写入期间按钮保留 loading,锁定关闭,连点不会重复移除', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
let finish!: (value: { checkpointId: string; subjectRef: string; removed: 1 }) => void
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation').mockImplementation(
() =>
new Promise(resolve => {
finish = resolve
})
)
openPanel()
await wrapper!.setProps({ checkpointId: 'new', state: {} })
expect(wrapper!.text()).not.toContain('提交候选为正式结果')
await checkCandidate()
await selectRelation()
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
await clickAction('确认移除这条关系')
await wrapper!.setProps({ disabled: true })
const submit = wrapper!.findAllComponents(NButton).find(button => button.text() === '确认移除这条关系')!
expect(submit.props('loading')).toBe(true)
expect(
drawer()
.findAll('button')
.find(button => button.text() === '关闭')!
.attributes('disabled')
).toBeDefined()
await submit.trigger('click')
expect(repair).toHaveBeenCalledOnce()
finish({ checkpointId: 'new-version', subjectRef: '@SC0002', removed: 1 })
await flushPromises()
})
it('完整展示原始关系,不自动选择、删除或提交', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
openPanel()
await checkCandidate()
expect(drawer().text()).toContain('测试场景')
expect(drawer().text()).toContain('测试空地')
expect(drawer().text()).toContain('原始证据')
expect(
drawer()
.findAll<HTMLInputElement>('input[type="radio"]')
.every(item => !item.element.checked)
).toBe(true)
expect(repair).not.toHaveBeenCalled()
expect(commit).not.toHaveBeenCalled()
})
it('每次仅移除用户明确确认的一条原始关系,新版本到达后重新预检,不自动提交', async () => {
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation').mockResolvedValue({
checkpointId: 'repaired-version',
subjectRef: '@SC0002',
removed: 1
})
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
openPanel()
await checkCandidate()
await selectRelation()
expect(repair).not.toHaveBeenCalled()
const button = drawer()
.findAll('button')
.find(item => item.text() === '确认移除这条关系')!
expect(button.attributes('disabled')).toBeDefined()
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
await button.trigger('click')
await button.trigger('click')
await flushPromises()
expect(repair).toHaveBeenCalledExactlyOnceWith('candidate-project', {
expectedCheckpointId: 'candidate-current',
confirmed: true,
subjectRef: '@SC0002',
relation: '位于',
target: '测试空地',
evidence: ' 原始证据 '
})
expect(wrapper!.emitted('refresh')).toHaveLength(1)
expect(commit).not.toHaveBeenCalled()
expect(drawer().text()).not.toContain('确认移除这条关系')
preview.mockResolvedValue(commitPreview({ checkpointId: 'repaired-version' }))
await wrapper!.setProps({
checkpointId: 'repaired-version',
quality: breakdownQuality(
selectBreakdownSource([candidateCheckpoint(candidateState(), 'repaired-version')]),
candidateReview({ checkpointId: 'repaired-version' })
)
})
await flushPromises()
expect(preview).toHaveBeenCalledTimes(3)
expect(drawer().text()).toContain('确认提交候选为正式结果')
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
expect(commit).not.toHaveBeenCalled()
})
it.each(['version', 'target', 'active'] as const)('提交前 %s 变化,拒绝移除并撤销旧确认', async change => {
const next = relationPreview()
if (change === 'version') next.checkpointId = 'other-version'
if (change === 'target') next.relationRepairTargets = []
if (change === 'active') next.checks.noActiveExecutions = false
vi.spyOn(breakdownApi, 'candidateCommitPreview')
.mockResolvedValueOnce(relationPreview())
.mockResolvedValue(next)
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
openPanel()
await checkCandidate()
await selectRelation()
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
await clickAction('确认移除这条关系')
expect(repair).not.toHaveBeenCalled()
expect(drawer().text()).not.toContain('确认移除这条关系')
expect(wrapper!.emitted('refresh')).toHaveLength(1)
})
it('普通提交失败保留所选关系,清除勾选后允许用户修正重试', async () => {
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
vi.spyOn(breakdownApi, 'repairCandidateRelation').mockRejectedValue(new Error('网络中断,请重新读取状态'))
openPanel()
await checkCandidate()
await selectRelation()
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
await clickAction('确认移除这条关系')
expect(drawer().get<HTMLInputElement>('input[type="radio"]').element.checked).toBe(true)
expect(drawer().text()).toContain('网络中断')
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
})
it('完全相同的重复定位关系不能提交删除', async () => {
const result = relationPreview()
result.relationRepairTargets.push({ ...result.relationRepairTargets[0]! })
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
openPanel()
await checkCandidate()
await selectRelation()
expect(drawer().text()).toContain('定位不唯一')
expect(drawer().text()).not.toContain('确认移除这条关系')
expect(repair).not.toHaveBeenCalled()
})
})
+33 -1
View File
@@ -1,5 +1,6 @@
import { describe, expect, it, vi, afterEach } from 'vitest'
import { candidateCommitIssue } from '@/features/breakdown/candidate'
import { candidateCommitIssue, candidatePreviewReady } from '@/features/breakdown/candidate'
import { commitPreview } from '../../fixtures/breakdown-candidate'
import { breakdownApi } from '@/features/breakdown/api'
import type { BreakdownState } from '@/features/breakdown/types'
@@ -50,6 +51,37 @@ function readyCandidate(): BreakdownState {
afterEach(() => vi.unstubAllGlobals())
describe('候选提交资格', () => {
it('关系来源检查缺失或失败时,即使 ready=true 也不能确认提交', () => {
const preview = commitPreview()
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(true)
delete (preview.checks as Partial<typeof preview.checks>).relationEvidenceValid
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
preview.checks.relationEvidenceValid = false
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
})
it('关系修复只发送最新版本和所选关系原始定位,不扩展成主体删除', async () => {
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: {} })))
vi.stubGlobal('fetch', fetcher)
await breakdownApi.repairCandidateRelation('p/id', {
confirmed: true,
expectedCheckpointId: 'cp-latest',
subjectRef: '@SC0002',
relation: '位于',
target: '测试空地',
evidence: ' 原始证据,保留空格 '
})
expect(fetcher.mock.calls[0]![0]).toBe('/api/projects/p%2Fid/breakdown/candidate-relation-repair')
expect(fetcher.mock.calls[0]![1]?.method).toBe('POST')
expect(JSON.parse(fetcher.mock.calls[0]![1]?.body as string)).toEqual({
confirmed: true,
expectedCheckpointId: 'cp-latest',
subjectRef: '@SC0002',
relation: '位于',
target: '测试空地',
evidence: ' 原始证据,保留空格 '
})
})
it('只允许完整、未提交、审核通过的候选快照进入确认', () => {
expect(candidateCommitIssue(readyCandidate())).toBe('')
expect(candidateCommitIssue({ ...readyCandidate(), candidateOnly: false })).toContain('候选')
+65 -2
View File
@@ -40,6 +40,9 @@ import { drawerPanel, expandSections, selectControl } from '@/testing/naive'
import ProductionPage from '@/features/production/ProductionPage.vue'
import RawDataDetails from '@/components/ui/RawDataDetails.vue'
import { getProductionSession } from '@/features/production/model'
import { generationConfigApi } from '@/features/generation-config/api'
import { AppDialog } from '@/components/ui'
import { projectSettingsOpenKey } from '@/features/generation-config/context'
/**
* 为内存路由补齐页面链接使用的正式项目工作区,避免链接解析时缺少目标路由。
@@ -69,16 +72,23 @@ function createPageRouter(routes: RouteRecordRaw[]) {
* 新资产页面复用已有项目上下文和内存路由,不接入真实模型。
* @param page 要挂载的风格或主体身份页面
* @param query 初始地址的查询参数
* @param openSettings 可选的项目顶栏配置入口
* @returns 当前页面注入的项目上下文
*/
async function mountAssets(page: 'style' | 'identity', query = '') {
async function mountAssets(page: 'style' | 'identity', query = '', openSettings?: () => void) {
const component = page === 'style' ? VisualStylePage : SubjectIdentityPage
const router = createPageRouter([{ path: '/assets', component }])
await router.push('/assets' + query)
const provided = context()
wrapper = mount(component, {
attachTo: document.body,
global: { plugins: [router], provide: { [projectContextKey as symbol]: provided } }
global: {
plugins: [router],
provide: {
[projectContextKey as symbol]: provided,
...(openSettings ? { [projectSettingsOpenKey as symbol]: openSettings } : {})
}
}
})
await flushPromises()
if (page === 'identity') await expandSections()
@@ -389,6 +399,59 @@ describe('内容级滚动下的生产反馈', () => {
})
describe('视觉风格与主体身份工作区', () => {
it.each(['AI 生成角色候选图', '生成辅助参考图', '批量生成角色候选图', '生成场景母版', '生成道具母版'])(
'缺少模型时点击%s先提示配置,不出现费用确认也不发送生成请求',
async label => {
vi.spyOn(generationConfigApi, 'profile').mockResolvedValue(null)
vi.spyOn(subjectIdentityApi, 'castingReadiness').mockResolvedValue({
total: 1,
ready: 0,
missingIdentity: 0,
missingAnchor: 1,
candidatePending: 0,
unlocked: 1,
locked: 0,
items: []
})
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
if (String(url).endsWith('/subject-forms')) return jsonResponse([formFixture()])
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
if (String(url).endsWith('/identity/images')) return jsonResponse([])
return jsonResponse(identityFixture())
})
stubFetch(fetcher)
const openSettings = vi.fn<() => void>()
await mountAssets('identity', '', openSettings)
const batch = label.startsWith('批量') || label.includes('母版')
if (!batch) {
const tools = wrapper!.findComponent({ name: 'WorkspaceTools' })
tools.vm.$emit('update:open', false)
tools.vm.$emit('closed')
await flushPromises()
}
expect(document.body.textContent).not.toContain('立即配置')
expect(button(label).disabled).toBe(false)
button(label).click()
await flushPromises()
if (batch) {
wrapper!.findComponent({ name: 'WorkspaceTools' }).vm.$emit('closed')
await flushPromises()
}
const dialog = document.querySelector('.app-dialog')
expect(dialog?.textContent).toContain('需要配置生成模型')
expect(dialog?.textContent).toContain('项目配置')
expect(dialog?.textContent).not.toContain('我已确认后台任务停止')
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
button('前往项目配置').click()
await flushPromises()
expect(openSettings).not.toHaveBeenCalled()
wrapper!
.findAllComponents(AppDialog)
.find(item => item.props('title') === '需要配置生成模型')!
.vm.$emit('closed')
expect(openSettings).toHaveBeenCalledExactlyOnceWith('generation')
}
)
it('当前主体已确认但其它角色未完成时,隐藏形态入口;保存后按新阶段状态开放', async () => {
/** 当前主体已锁定,其它角色仍未确认,用真实项目准入规则约束页面入口。 */
const saved = identityFixture({ isLocked: true })
+7 -4
View File
@@ -1,5 +1,5 @@
import type { BreakdownState, EpisodePlan } from '@/features/breakdown/types'
import type { CandidateCommitPreview, CandidateRevalidation } from '@/features/breakdown/candidate.types'
import type { CandidateCommitCheckPreview, CandidateRevalidation } from '@/features/breakdown/candidate.types'
import type { Checkpoint } from '@/features/workflows/types'
/**
@@ -192,16 +192,18 @@ export function candidateReview(overrides: Partial<CandidateRevalidation> = {}):
}
/**
* 创建七项门禁均通过的安全预检查响应。
* 创建全部门禁均通过的安全预检查响应。
* @param overrides 本次检查差异
* @returns 只读安全检查
*/
export function commitPreview(overrides: Partial<CandidateCommitPreview> = {}): CandidateCommitPreview {
export function commitPreview(overrides: Partial<CandidateCommitCheckPreview> = {}): CandidateCommitCheckPreview {
return {
projectId: 'candidate-project',
checkpointId: 'candidate-current',
ready: true,
readOnly: true,
relationIssues: [],
relationRepairTargets: [],
checks: {
qualityPolicyMatches: true,
episodeNumbersMatch: true,
@@ -210,7 +212,8 @@ export function commitPreview(overrides: Partial<CandidateCommitPreview> = {}):
noActiveVideos: true,
noSubjectIdentities: true,
noSubjectImages: true,
noProtectedShots: true
noProtectedShots: true,
relationEvidenceValid: true
},
counts: {
episodes: 1,