feat(short-drama-agent-front): 完善质量规则确认与中文交互
This commit is contained in:
1 parent
190333d4f9
commit
c4b43b9725
85 files changed
+2059
-480
No files matched your search
@@ -14,9 +14,106 @@ 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 } 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'
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
|
||||
it('首次点击生成先读取并确认质量规则,不直接打开模型启动确认', async () => {
|
||||
const readPolicy = vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue({
|
||||
projectId: 'breakdown-scroll-test',
|
||||
policy: { 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,
|
||||
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 flushPromises()
|
||||
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(readPolicy).toHaveBeenCalledTimes(1)
|
||||
expect(drawerPanel().text()).toContain('拆解前确认质量规则')
|
||||
expect(document.querySelector('.app-dialog')).toBeNull()
|
||||
expect(start).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('规则确认保留分组预览,隐藏空白例外,确认不调用模型,未变规则不重复打开表单', async () => {
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue({
|
||||
projectId: 'breakdown-scroll-test',
|
||||
policy: { 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,
|
||||
groups: [{ groupId: 'preview-group', groupNo: 1, startEpisodeNo: 1, endEpisodeNo: 1, episodes: [] }]
|
||||
})
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy')
|
||||
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 flushPromises()
|
||||
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
|
||||
await flushPromises()
|
||||
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 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')
|
||||
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 flushPromises()
|
||||
await drawerPanel().findAll('button').find(button => button.text() === '生成拆解候选')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().text()).not.toContain('拆解前确认质量规则')
|
||||
expect(document.querySelector('.app-dialog')?.textContent).toContain('可能产生模型费用')
|
||||
expect(start).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('当前动作问题在问题抽屉中提供例外修订,保存期间锁定关闭且保存后仍需审核', async () => {
|
||||
let policy: ProjectQualityPolicy = { version: 1, physicsMode: 'realistic', allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] }
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockImplementation(async () => ({ projectId: 'breakdown-scroll-test', policy }))
|
||||
let finish!: () => void
|
||||
const save = vi.spyOn(projectsApi, 'saveQualityPolicy').mockImplementation(async (id, input) => {
|
||||
await new Promise<void>(resolve => { finish = resolve })
|
||||
policy = input
|
||||
return { projectId: id, policy: 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]
|
||||
}))
|
||||
mountPage([candidateCheckpoint(resourceConflictState({ projectId: 'breakdown-scroll-test' }))])
|
||||
await flushPromises()
|
||||
await wrapper!.get('.breakdown-desktop-issues').trigger('click')
|
||||
await flushPromises()
|
||||
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().get('textarea').setValue('剧本中的明确允许设定')
|
||||
await panel().findAll('button').find(button => button.text() === '保存动作例外')!.trigger('click')
|
||||
await flushPromises()
|
||||
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()
|
||||
Object.assign(getOperation('breakdown-scroll-test'), { error: '', notice: '', label: '' })
|
||||
})
|
||||
/** 跨组件后台任务观察器,验证结束时释放。 */
|
||||
let taskScope: ReturnType<typeof effectScope> | undefined
|
||||
afterEach(() => {
|
||||
|
||||
Reference in new issue
Block a user