fix(short-drama-agent-front): 统一全屏布局与问题处理交互
This commit is contained in:
1 parent
db91a4b871
commit
cc27d463e0
25 files changed
+838
-316
No files matched your search
@@ -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 = '新依据'
|
||||
|
||||
Reference in new issue
Block a user