feat(short-drama-agent-front): 完善镜头定位与项目配置
This commit is contained in:
1 parent
470b52e26d
commit
5b134207b8
66 files changed
+2042
-984
No files matched your search
@@ -0,0 +1,113 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { creativeProfileDraft, creativeProfileIssues } from '../../../src/features/generation-config/profile-draft'
|
||||
import type { CreativeProfileInput, GenerationModelCatalog } from '../../../src/features/generation-config/types'
|
||||
|
||||
/** 后端已保存的竖屏自定义尺寸,不限于目录的尺寸预设。 */
|
||||
const saved: CreativeProfileInput = {
|
||||
aspectRatio: '9:16',
|
||||
imageProvider: 'qwen-image',
|
||||
imageModel: 'qwen-image-3.0-pro',
|
||||
imageOptions: { size: '1080*1920', count: 1, promptExtend: false },
|
||||
videoProvider: 'wan',
|
||||
videoModel: 'wan3.0-video',
|
||||
videoOptions: { aspectRatio: 'adaptive', resolution: '1080P', duration: 5, audio: false }
|
||||
}
|
||||
|
||||
describe('项目配置编辑草稿', () => {
|
||||
it('读取与保存草稿保留真实自定义尺寸和未显示的供应方参数', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
expect(draft.imageOptions).toEqual({ size: '1080*1920', count: 1, promptExtend: false })
|
||||
expect(draft.videoOptions).toEqual({ aspectRatio: 'adaptive', resolution: '1080P', duration: 5, audio: false })
|
||||
})
|
||||
it('未保存的图片和视频参数修改不会污染实际已保存对象', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
draft.imageOptions.size = '2048*2048'
|
||||
draft.videoOptions.duration = 10
|
||||
expect(saved.imageOptions.size).toBe('1080*1920')
|
||||
expect(saved.videoOptions.duration).toBe(5)
|
||||
})
|
||||
})
|
||||
|
||||
/** 模型目录枚举与数字限制以真实后端 schema 规则为准。 */
|
||||
const catalog: GenerationModelCatalog = {
|
||||
defaults: { imageProvider: 'qwen-image', videoProvider: 'wan' },
|
||||
images: [
|
||||
{
|
||||
type: 'image',
|
||||
provider: 'qwen-image',
|
||||
providerLabel: 'Qwen',
|
||||
model: 'qwen-image-3.0-pro',
|
||||
modelLabel: 'Qwen',
|
||||
supported: true,
|
||||
enabled: true,
|
||||
isDefault: true,
|
||||
capabilities: {},
|
||||
defaults: {},
|
||||
projectConstraints: [],
|
||||
generationOptions: [
|
||||
{
|
||||
key: 'size',
|
||||
label: '图片尺寸',
|
||||
type: 'size',
|
||||
required: true,
|
||||
options: [{ label: '竖屏', value: '1536*2688' }]
|
||||
},
|
||||
{ key: 'count', label: '数量', type: 'integer', required: true, min: 1, max: 1 }
|
||||
]
|
||||
}
|
||||
],
|
||||
videos: [
|
||||
{
|
||||
type: 'video',
|
||||
provider: 'wan',
|
||||
providerLabel: 'Wan',
|
||||
model: 'wan3.0-video',
|
||||
modelLabel: 'Wan',
|
||||
supported: true,
|
||||
enabled: true,
|
||||
isDefault: true,
|
||||
capabilities: {},
|
||||
defaults: {},
|
||||
projectConstraints: [],
|
||||
generationOptions: [
|
||||
{
|
||||
key: 'duration',
|
||||
label: '时长',
|
||||
type: 'integer',
|
||||
required: true,
|
||||
min: 2,
|
||||
max: 30,
|
||||
specialValues: [{ label: '自动', value: -1 }]
|
||||
},
|
||||
{ key: 'audio', label: '音轨', type: 'boolean', required: true }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
describe('项目配置保存前校验', () => {
|
||||
it('保留但提示不再支持的历史尺寸,选择有效尺寸后可保存', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
expect(creativeProfileIssues(draft, catalog)).toHaveLength(1)
|
||||
expect(draft.imageOptions.size).toBe('1080*1920')
|
||||
draft.imageOptions.size = '1536*2688'
|
||||
expect(creativeProfileIssues(draft, catalog)).toEqual([])
|
||||
})
|
||||
it('拒绝无效数值与缺失必填参数,允许后端支持的特殊时长', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
draft.imageOptions.size = '1536*2688'
|
||||
draft.imageOptions.count = 2
|
||||
delete draft.videoOptions.audio
|
||||
draft.videoOptions.duration = -1
|
||||
expect(creativeProfileIssues(draft, catalog)).toHaveLength(2)
|
||||
draft.imageOptions.count = 1
|
||||
draft.videoOptions.audio = false
|
||||
expect(creativeProfileIssues(draft, catalog)).toEqual([])
|
||||
})
|
||||
it('模型更新后拒绝目录中已不存在的旧模型', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
draft.imageOptions.size = '1536*2688'
|
||||
draft.imageModel = 'removed-image-model'
|
||||
expect(creativeProfileIssues(draft, catalog)).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user