feat(short-drama-agent-front): 完善分镜审核与制作准备流程
This commit is contained in:
1 parent
c4b43b9725
commit
1da56e0d46
72 files changed
+2801
-528
No files matched your search
@@ -16,6 +16,15 @@ function mountFields(schemas: GenerationOptionSchema[]) {
|
||||
}
|
||||
|
||||
describe('生成模型参数字段', () => {
|
||||
it('只有目录声明支持的模型才提供智能时长,不按模型品牌补造 -1', () => {
|
||||
for (const supported of [false, true]) {
|
||||
const wrapper = mountFields([{ key: 'durationSeconds', label: '生成时长', type: 'integer', required: true,
|
||||
min: 4, max: 6, ...(supported ? { specialValues: [{ label: '智能时长', value: -1 }] } : {}) }])
|
||||
const options = wrapper.getComponent(NSelect).props('options') as { value: number }[]
|
||||
expect(options.some(item => item.value === -1)).toBe(supported)
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
it('图片尺寸只保留当前 Provider 枚举、默认值与当前值', () => {
|
||||
const wrapper = mountFields([
|
||||
{
|
||||
|
||||
@@ -86,6 +86,14 @@ const catalog: GenerationModelCatalog = {
|
||||
}
|
||||
|
||||
describe('项目配置保存前校验', () => {
|
||||
it('项目竖屏画布允许目录支持的方形参考图尺寸,不把两者强制绑定', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
const squareCatalog = structuredClone(catalog)
|
||||
squareCatalog.images[0]!.generationOptions[0]!.options = [{ label: '方形参考图', value: '2048*2048' }]
|
||||
draft.imageOptions.size = '2048*2048'
|
||||
expect(draft.aspectRatio).toBe('9:16')
|
||||
expect(creativeProfileIssues(draft, squareCatalog)).toEqual([])
|
||||
})
|
||||
it('保留但提示不再支持的历史尺寸,选择有效尺寸后可保存', () => {
|
||||
const draft = creativeProfileDraft(saved)
|
||||
expect(creativeProfileIssues(draft, catalog)).toHaveLength(1)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { NSelect, type MessageApi } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import CreativeProfileSettings from '@/features/generation-config/components/CreativeProfileSettings.vue'
|
||||
import { generationConfigApi } from '@/features/generation-config/api'
|
||||
import { projectGenerationRevisionKey } from '@/features/generation-config/context'
|
||||
import { actionMessageKey } from '@/components/ui/useActionMessage'
|
||||
import { ApiError } from '@/lib/http'
|
||||
import { generationProfile, imageCatalog } from '../../fixtures/generation'
|
||||
|
||||
/** 当前配置表单实例,测试后释放观察器。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => wrapper?.unmount())
|
||||
|
||||
/**
|
||||
* 使用真实表单和隔离消息层,不请求真实服务或保存项目数据。
|
||||
* @returns 草稿原值、保存接口、消息及配置修订号
|
||||
*/
|
||||
async function settings() {
|
||||
const saved = generationProfile('config-contract')
|
||||
const catalog = { ...imageCatalog, videos: [{ ...imageCatalog.images[0]!, type: 'video' as const, provider: 'seedance', model: 'seedance', generationOptions: [], defaults: {} }] }
|
||||
vi.spyOn(generationConfigApi, 'catalog').mockResolvedValue(catalog)
|
||||
vi.spyOn(generationConfigApi, 'profile').mockResolvedValue(saved)
|
||||
const save = vi.spyOn(generationConfigApi, 'saveProfile').mockResolvedValue(saved)
|
||||
const messages = { success: vi.fn<MessageApi['success']>(), warning: vi.fn<MessageApi['warning']>(), error: vi.fn<MessageApi['error']>(), info: vi.fn<MessageApi['info']>() }
|
||||
const revision = ref(0)
|
||||
wrapper = mount(CreativeProfileSettings, {
|
||||
props: { projectId: saved.projectId },
|
||||
global: { provide: { [actionMessageKey as symbol]: messages as unknown as MessageApi, [projectGenerationRevisionKey as symbol]: revision } }
|
||||
})
|
||||
await flushPromises()
|
||||
return { saved, save, messages, revision }
|
||||
}
|
||||
|
||||
describe('项目配置的业务冲突反馈', () => {
|
||||
it.each([
|
||||
['CANVAS_CHANGE_REQUIRES_REVALIDATION', '画幅'],
|
||||
['CREATIVE_PROFILE_ACTIVE_WORKFLOW', '任务'],
|
||||
['GENERATION_CONFIG_CHANGE_REQUIRES_REVALIDATION', '模型']
|
||||
])('保存遇到 %s 时只提示业务原因、保留草稿且不重试', async (code, label) => {
|
||||
const { saved, save, messages, revision } = await settings()
|
||||
await wrapper!.findAllComponents(NSelect)[0]!.vm.$emit('update:value', '9:16')
|
||||
save.mockRejectedValue(new ApiError('请求失败(409)', 409, { code, keyframeCount: 1 }))
|
||||
await wrapper!.find('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(save).toHaveBeenCalledTimes(1)
|
||||
expect(messages.warning).toHaveBeenCalledWith(expect.stringContaining(label), expect.any(Object))
|
||||
expect(messages.error).not.toHaveBeenCalled()
|
||||
expect(messages.success).not.toHaveBeenCalled()
|
||||
expect(wrapper!.findAllComponents(NSelect)[0]!.props('value')).toBe('9:16')
|
||||
expect(wrapper!.emitted('saved')).toBeUndefined()
|
||||
expect(revision.value).toBe(0)
|
||||
expect(saved.aspectRatio).toBe('1:1')
|
||||
expect(wrapper!.text()).not.toContain('请求失败')
|
||||
})
|
||||
|
||||
it('保存成功使用统一消息,不遗留重复的常驻成功提示', async () => {
|
||||
const { save, messages, revision } = await settings()
|
||||
await wrapper!.find('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(save).toHaveBeenCalledTimes(1)
|
||||
expect(messages.success).toHaveBeenCalledTimes(1)
|
||||
expect(wrapper!.find('.context-notice-success').exists()).toBe(false)
|
||||
expect(revision.value).toBe(1)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user