feat(short-drama-agent-front): 完善镜头定位与项目配置

This commit is contained in:
GJ committed 2026-10-08 19:45:26 +08:00
1 parent 470b52e26d
commit 5b134207b8
66 files changed
+2042 -984

No files matched your search

+27 -27
View File
@@ -1,3 +1,4 @@
import { imageCatalog, generationProfile } from '../../fixtures/generation'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { AssetImage } from '@/components/ui'
@@ -8,22 +9,8 @@ import { coverImage, hasRunningImages, primaryImage, validImageSize } from '@/fe
import { formFixture, imageFixture } from '@/features/subject-images/testing/fixtures'
import { expandSections } from '@/testing/naive'
const imageCatalog = {
defaults: { imageProvider: 'qwen-image', videoProvider: 'seedance' },
images: [{
type: 'image' as const, provider: 'qwen-image', providerLabel: 'Qwen', model: 'qwen-image-3.0-pro',
modelLabel: 'Qwen Image', supported: true as const, enabled: true, isDefault: true, capabilities: {},
generationOptions: [{ key: 'size', label: '图片尺寸', type: 'size' as const, required: true,
options: [{ label: '1:1 · 2048×2048', value: '2048*2048' }] }],
defaults: { size: '2048*2048' }, projectConstraints: []
}],
videos: []
}
const creativeProfile = {
projectId: 'gallery-test', aspectRatio: '1:1' as const, imageProvider: 'qwen-image',
imageModel: 'qwen-image-3.0-pro', imageOptions: { size: '2048*2048' },
videoProvider: 'seedance', videoModel: 'seedance', videoOptions: {}
}
/** 当前测试使用真实目录契约构造项目模型配置。 */
const creativeProfile = generationProfile('gallery-test')
let wrapper: VueWrapper | undefined
/** Naive 将弹窗挂载到 body,需要从实际弹窗找到按钮。 */
function button(label: string): HTMLButtonElement {
@@ -81,7 +68,10 @@ describe('形态图片选择与操作', () => {
it.each(['character', 'scene', 'prop'])('按后端最新 %s 模块展示母版继承范围', async module => {
const form = formFixture()
form.subject.module = module
wrapper = mount(GenerateImageDialog, { attachTo: document.body, props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile } })
wrapper = mount(GenerateImageDialog, {
attachTo: document.body,
props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile }
})
await flushPromises()
expect(document.body.textContent).toContain('母版')
expect(document.body.textContent).not.toContain('道具形态生图暂不自动引用')
@@ -149,7 +139,7 @@ describe('形态图片选择与操作', () => {
expect(validImageSize(width, height)).toBe(false)
})
it('生图确认发送正式形态 ID,不覆盖后端模型,默认不替换已有主图', async () => {
it('生图确认发送正式形态 ID 和项目模型参数,默认不替换已有主图', async () => {
wrapper = mount(GenerateImageDialog, {
attachTo: document.body,
props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile }
@@ -160,29 +150,39 @@ describe('形态图片选择与操作', () => {
await flushPromises()
button('确认生成图片').click()
await flushPromises()
expect(wrapper.emitted('generate')).toEqual([['form-db-1', { setPrimary: false }]])
expect(wrapper.emitted('generate')).toEqual([
['form-db-1', { setPrimary: false, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }]
])
})
it('新形态默认设主图,填写一侧尺寸时不能提交,切换形态清空自定义提示词', async () => {
it('新形态默认设主图并继承目录尺寸,切换形态清空提示词和费用确认', async () => {
const form = formFixture()
form.images = []
wrapper = mount(GenerateImageDialog, { attachTo: document.body, props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile } })
wrapper = mount(GenerateImageDialog, {
attachTo: document.body,
props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile }
})
await flushPromises()
const width = document.querySelector<HTMLInputElement>('#image-width')!
width.value = '2048'
width.dispatchEvent(new Event('input', { bubbles: true }))
const prompt = document.querySelector<HTMLTextAreaElement>('#image-prompt')!
prompt.value = '上一形态自定义提示词'
prompt.dispatchEvent(new Event('input', { bubbles: true }))
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
await flushPromises()
expect(button('确认生成图片').disabled).toBe(true)
expect(button('确认生成图片').disabled).toBe(false)
expect(wrapper.emitted('generate')).toBeUndefined()
await wrapper.setProps({ form: { ...form, id: 'form-db-2' } })
await flushPromises()
expect(width.value).toBe('')
expect(prompt.value).toBe('')
expect(document.querySelector('#image-width')).toBeNull()
expect(document.querySelector('#image-height')).toBeNull()
expect(document.querySelector('#confirm-image-cost')!.getAttribute('aria-checked')).toBe('false')
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
await flushPromises()
button('确认生成图片').click()
await flushPromises()
expect(wrapper.emitted('generate')).toEqual([['form-db-2', { setPrimary: true }]])
expect(wrapper.emitted('generate')).toEqual([
['form-db-2', { setPrimary: true, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }]
])
})
it('图库不自动生图,主图切换经确认后 PUT,失败图片不能设主图', async () => {