fix(short-drama-agent-front): 统一全屏布局与问题处理交互

This commit is contained in:
GJ committed 2026-10-17 17:40:39 +08:00
1 parent db91a4b871
commit cc27d463e0
25 files changed
+838 -316

No files matched your search

+25 -7
View File
@@ -1,11 +1,12 @@
import { h, ref } from 'vue'
import { createMemoryHistory, createRouter } from 'vue-router'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { NConfigProvider, NMenu, NModal, NPopover, NScrollbar, NTooltip } from 'naive-ui'
import { NConfigProvider, NDrawer, NMenu, NModal, NPopover, NScrollbar, NTooltip } from 'naive-ui'
import App from '@/App.vue'
import WorkspacePage from '@/components/ui/WorkspacePage.vue'
import AppDialog from '@/components/ui/AppDialog.vue'
import AppDrawer from '@/components/ui/AppDrawer.vue'
import WorkspaceTools from '@/components/ui/WorkspaceTools.vue'
import ProjectLayout from '@/features/projects/ProjectLayout.vue'
import ConfirmAction from '@/features/workflows/ConfirmAction.vue'
@@ -348,19 +349,36 @@ describe('管理后台组件边界', () => {
expect(wrapper.get('.admin-sider-footer [aria-label="连接设置"]').text()).toBe('连接设置')
})
it('长弹窗使用内部滚动,提交期间禁止遮罩和 Esc 关闭', async () => {
wrapper = mount(AppDialog, {
it.each([
['弹窗', AppDialog, '.app-dialog .n-card__footer'],
['全屏抽屉', AppDrawer, '.app-drawer .n-drawer-footer']
] as const)('%s 默认底栏可关闭,提交期间继续锁定所有关闭入口', async (kind, component, selector) => {
wrapper = mount(component, {
attachTo: document.body,
props: { open: true, title: '确认生图', description: '费用确认', busy: true },
slots: { default: '<p>内容</p>' }
})
await flushPromises()
expect(wrapper.getComponent(NModal).props()).toMatchObject({
closable: false,
const frame = kind === '弹窗' ? wrapper.getComponent(NModal) : wrapper.getComponent(NDrawer)
expect(frame.props()).toMatchObject({
maskClosable: false,
closeOnEsc: false
})
expect(document.querySelector('.dialog-body-scroll .n-scrollbar-container')).not.toBeNull()
expect(
document.querySelector(
kind === '弹窗' ? '.app-dialog .n-card-header__close' : '.app-drawer .n-drawer-header__close'
)
).toBeNull()
const footer = document.querySelector<HTMLElement>(selector)
expect(footer).not.toBeNull()
const close = new DOMWrapper(footer!).get<HTMLButtonElement>('button')
expect(close.text()).toBe('关闭')
expect(close.element.disabled).toBe(true)
await close.trigger('click')
expect(wrapper.emitted('update:open')).toBeUndefined()
await wrapper.setProps({ busy: false })
await close.trigger('click')
expect(wrapper.emitted('update:open')?.at(-1)).toEqual([false])
})
it('操作弹窗挂载 body 并限制视口尺寸,开关保留列表与配置草稿', async () => {
+50 -9
View File
@@ -528,7 +528,7 @@ describe('拆解页内容滚动', () => {
await flushPromises()
expect(drawerPanel().element.closest('.workspace-split')).toBeNull()
await drawerPanel().get('#group-size').setValue('2')
await drawerPanel().get('.n-card-header__close').trigger('click')
await drawerPanel().get('.n-drawer-header__close').trigger('click')
provided.data.value!.checkpoints = [checkpoint()]
await flushPromises()
expect(wrapper!.get('.breakdown-results-scroll .n-scrollbar-container').element).toBe(results)
@@ -544,7 +544,7 @@ describe('拆解页内容滚动', () => {
expect(fetcher).not.toHaveBeenCalled()
})
it('问题入口打开独立错误弹窗,拆解设置不再包含详细错误', async () => {
it('问题窗口集中查看、修订和恢复,拆解设置只保留生成与候选流程', async () => {
const record = checkpoint()
record.state.workflowExecution!.status = 'failed'
record.state.workflowExecution!.errorMessage = '工作流中断'
@@ -555,21 +555,55 @@ describe('拆解页内容滚动', () => {
mountPage([record])
expect(wrapper!.find('.workspace-feedback').exists()).toBe(false)
expect(wrapper!.text()).not.toContain('缺少形态绑定')
const action = wrapper!.findAll('button').find(item => item.text() === '查看拆解问题')!
const action = wrapper!.get('button.breakdown-desktop-issues')
await action.trigger('click')
await flushPromises()
const issues = document.querySelector<HTMLElement>('.app-dialog[aria-label="拆解问题"]')
const issues = document.querySelector<HTMLElement>('.app-drawer[aria-label="拆解问题"]')
expect(issues?.textContent).toContain('缺少形态绑定')
expect(issues?.textContent).toContain('工作流中断')
expect(issues?.textContent).not.toContain('重试失败抽取')
await new DOMWrapper(issues!).get('.n-card-header__close').trigger('click')
expect(issues?.textContent).toContain('重试失败抽取')
expect(issues?.textContent).toContain('读取修复清单')
expect(issues?.textContent).not.toContain('预览分组')
expect(issues?.textContent).not.toContain('提交候选为正式结果')
await new DOMWrapper(issues!).get('.n-drawer-header__close').trigger('click')
await flushPromises()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
expect(drawerPanel().text()).not.toContain('缺少形态绑定')
expect(drawerPanel().text()).not.toContain('工作流中断')
expect(drawerPanel().text()).toContain('查看问题')
expect(drawerPanel().text()).toContain('重试失败抽取')
expect(drawerPanel().text()).toContain('预览分组')
expect(drawerPanel().text()).not.toContain('查看问题')
expect(drawerPanel().text()).not.toContain('重试失败抽取')
expect(drawerPanel().text()).not.toContain('读取修复清单')
})
it('问题窗口在任务执行期间仅可查看,修订与恢复继续受活动锁保护', async () => {
const record = checkpoint()
record.state.workflowExecution!.status = 'running'
record.state.breakdownResult!.storyboardShotValidation = {
valid: false,
issues: [{ episodeNo: 1, message: '待修复问题' }]
}
mountPage([record])
await wrapper!.get('button.breakdown-desktop-issues').trigger('click')
await flushPromises()
const issues = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer[aria-label="拆解问题"]')!)
expect(issues.text()).toContain('待修复问题')
for (const label of ['读取修复清单', '重试失败抽取', '补齐缺失镜头', '修复分镜绑定']) {
const action = issues.findAll('button').find(button => button.text() === label)!
expect((action.element as HTMLButtonElement).disabled).toBe(true)
}
})
it('质量待审核但没有结构错误时仍可进入问题窗口读取修复清单', async () => {
const record = checkpoint()
record.state.storyboardPendingQualityEpisodeNos = [1]
record.state.breakdownResult!.storyboardShotValidation = { valid: true, issues: [] }
mountPage([record])
await wrapper!.get('button.breakdown-desktop-issues').trigger('click')
await flushPromises()
const issues = document.querySelector<HTMLElement>('.app-drawer[aria-label="拆解问题"]')
expect(issues?.textContent).toContain('读取修复清单')
})
it('诊断摘要与弹窗按需读取,展开结构化校验后展示证据不足', async () => {
@@ -593,6 +627,7 @@ describe('拆解页内容滚动', () => {
const footer = panel.get('.n-card__footer')
expect(footer.text()).toContain('预览诊断范围')
expect(footer.text()).toContain('启动 AI 诊断')
expect(footer.text()).toContain('关闭')
await panel.get('.n-collapse-item__header-main').trigger('click')
await flushPromises()
expect(panel.text()).toContain('有效动作证据 0 / 25 镜')
@@ -732,9 +767,15 @@ describe('拆解页内容滚动', () => {
qualityDialog()
.get('.n-card__footer')
.findAll('button')
.filter(button => button.text() !== '关闭')
.every(button => (button.element as HTMLButtonElement).disabled)
).toBe(true)
await qualityDialog().get('.n-card-header__close').trigger('click')
const close = qualityDialog()
.get('.n-card__footer')
.findAll('button')
.find(button => button.text() === '关闭')!
expect((close.element as HTMLButtonElement).disabled).toBe(false)
await close.trigger('click')
await flushPromises()
resolveFirst!(handDiagnosticsResponse(25))
await flushPromises()
@@ -1,17 +1,17 @@
import { afterEach, describe, expect, it } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import BreakdownIssuesDialog from '@/features/breakdown/components/BreakdownIssuesDialog.vue'
import AppDialog from '@/components/ui/AppDialog.vue'
import AppDrawer from '@/components/ui/AppDrawer.vue'
/** 独立问题弹窗实例,验证后移除 Teleport。 */
/** 独立全屏问题抽屉实例,验证后移除 Teleport。 */
let wrapper: VueWrapper | undefined
afterEach(() => {
wrapper?.unmount()
document.body.innerHTML = ''
})
describe('拆解问题弹窗', () => {
it('同镜头问题合并展示并去重,定位等待弹窗离场后发出', async () => {
describe('拆解问题抽屉', () => {
it('同镜头问题合并展示并去重,定位等待抽屉离场后发出', async () => {
wrapper = mount(BreakdownIssuesDialog, {
attachTo: document.body,
props: {
@@ -34,7 +34,7 @@ describe('拆解问题弹窗', () => {
button.click()
await flushPromises()
expect(wrapper.emitted('locate')).toBeUndefined()
wrapper.getComponent(AppDialog).vm.$emit('closed')
wrapper.getComponent(AppDrawer).vm.$emit('closed')
expect(wrapper.emitted('locate')?.[0]?.[0]).toMatchObject({ episodeNo: 1, beatNo: 2, shotNo: 3 })
})
})
+68 -1
View File
@@ -1,7 +1,9 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { policyDraft, policyIssue } from '@/features/projects/quality-policy'
import { projectsApi } from '@/features/projects/api'
import type { ProjectQualityPolicy } from '@/features/projects/types'
import QualityPolicySettings from '@/features/generation-config/components/QualityPolicySettings.vue'
/** 保留已有精确例外的服务端完整策略。 */
const saved: ProjectQualityPolicy = {
@@ -15,8 +17,73 @@ const saved: ProjectQualityPolicy = {
{ code: 'action_resource_conflict', ownerRef: '@人物', resource: 'left_hand', reason: '明确依据' }
]
}
afterEach(() => vi.unstubAllGlobals())
/** 真实策略表单实例,验证结束后移除组件与事件监听。 */
let settings: VueWrapper | undefined
afterEach(() => {
settings?.unmount()
settings = undefined
vi.unstubAllGlobals()
})
describe('项目质量策略', () => {
it('进入和新增例外不立即报错,保存时拦截缺失字段,修正后才写入', async () => {
const fetcher = vi.fn<typeof fetch>().mockImplementation(
async (_url, init) =>
new Response(
JSON.stringify({
data: {
projectId: 'p',
policy:
init?.method === 'PUT'
? JSON.parse(String(init.body))
: { ...saved, actionExceptions: [] }
}
})
)
)
vi.stubGlobal('fetch', fetcher)
const wrapper = mount(QualityPolicySettings, { props: { projectId: 'p', disabled: false } })
settings = wrapper
await flushPromises()
expect(wrapper.find('.text-danger').exists()).toBe(false)
await wrapper
.findAll('button')
.find(button => button.text() === '添加例外')!
.trigger('click')
expect(wrapper.text()).not.toContain('精确例外需填写')
expect(wrapper.vm.canSave).toBe(true)
await wrapper.vm.save()
expect(wrapper.text()).toContain('精确例外需填写')
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(0)
await wrapper.get('[aria-label="例外 1 主体引用"] input').setValue('@CH0001')
expect(wrapper.text()).not.toContain('精确例外需填写')
await wrapper.vm.save()
expect(wrapper.text()).toContain('精确例外需填写')
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(0)
await wrapper.get('[aria-label="例外 1 确认依据"] input').setValue('剧本明确的动作许可')
await wrapper.vm.save()
await flushPromises()
const writes = fetcher.mock.calls.filter(([, init]) => init?.method === 'PUT')
expect(writes).toHaveLength(1)
expect(JSON.parse(String(writes[0]?.[1]?.body))).toEqual({
version: 1,
physicsMode: 'realistic',
allowExaggeratedMotion: false,
allowNonPhysicalActions: false,
allowSupernaturalAbilities: false,
customRules: ['规则'],
actionExceptions: [
{
code: 'action_resource_conflict',
ownerRef: '@CH0001',
resource: 'left_hand',
reason: '剧本明确的动作许可'
}
]
})
expect(wrapper.text()).toContain('质量策略已保存')
})
it('草稿编辑不污染已保存策略,完整保留精确例外', () => {
const draft = policyDraft(saved)
draft.actionExceptions![0]!.reason = '新依据'
+26 -1
View File
@@ -45,11 +45,36 @@ describe('WorkflowExecution 前端契约', () => {
error: ''
}
})
expect(wrapper.text()).toContain('抽取任务 3 / 3')
expect(wrapper.text().replace(/\s/g, '')).toContain('抽取任务3/3')
expect(wrapper.text()).toContain('校验未通过')
expect(wrapper.get('section').attributes('data-task-state')).toBe('error')
expect(wrapper.find('details').exists()).toBe(false)
expect(wrapper.text()).not.toContain('最新镜头资产状态')
wrapper.unmount()
})
it.each([
{ result: { storyboardShotValidation: { valid: true, issues: [] } }, state: 'success', label: '已完成' },
{ result: null, state: 'unknown', label: '结果待确认' },
{
result: { storyboardShotValidation: { valid: true, issues: [] }, storyboardPendingQualityEpisodeNos: [1] },
state: 'error',
label: '待修订'
}
])('拆解终态仅在明确通过校验且没有待修订剧集时显示成功底色:$state', ({ result, state, label }) => {
const wrapper = mount(WorkflowExecutionPanel, {
props: {
execution: execution({ workflowName: 'breakdown', status: 'completed', result }),
loading: false,
error: '',
showStatusHint: false
}
})
expect(wrapper.get('section').attributes('data-task-state')).toBe(state)
expect(wrapper.text()).toContain(label)
expect(wrapper.find('details').exists()).toBe(false)
expect(wrapper.text()).toContain('更新时间')
wrapper.unmount()
})
it('保留未知阶段并限制真实进度范围', () => {
expect(executionStageLabel('repairing')).toBe('自动修复')
expect(executionStageLabel('new_backend_stage')).toBe('new_backend_stage')