From ad279f5556e7266b71efb0ec0c7cdf3fde1f7079 Mon Sep 17 00:00:00 2001 From: GouJ Date: Fri, 25 Sep 2026 00:34:58 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=E5=BD=A2=E6=80=81?= =?UTF-8?q?=E7=94=9F=E5=9B=BE=E6=A8=A1=E5=9E=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/features/subject-images/images.test.ts | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/features/subject-images/images.test.ts b/tests/features/subject-images/images.test.ts index 413e988..4acb32c 100644 --- a/tests/features/subject-images/images.test.ts +++ b/tests/features/subject-images/images.test.ts @@ -8,6 +8,22 @@ 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: {} +} let wrapper: VueWrapper | undefined /** Naive 将弹窗挂载到 body,需要从实际弹窗找到按钮。 */ function button(label: string): HTMLButtonElement { @@ -65,7 +81,7 @@ 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 } }) + 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('道具形态生图暂不自动引用') @@ -95,7 +111,7 @@ describe('形态图片选择与操作', () => { vi.stubGlobal('fetch', fetcher) wrapper = mount(GenerateImageDialog, { attachTo: document.body, - props: { open: true, form: formFixture(), disabled: false } + props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile } }) await flushPromises() button('预览实际生成输入').click() @@ -136,7 +152,7 @@ describe('形态图片选择与操作', () => { it('生图确认发送正式形态 ID,不覆盖后端模型,默认不替换已有主图', async () => { wrapper = mount(GenerateImageDialog, { attachTo: document.body, - props: { open: true, form: formFixture(), disabled: false } + props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile } }) await flushPromises() expect(button('确认生成图片').disabled).toBe(true) @@ -150,7 +166,7 @@ describe('形态图片选择与操作', () => { it('新形态默认设主图,填写一侧尺寸时不能提交,切换形态清空自定义提示词', async () => { const form = formFixture() form.images = [] - wrapper = mount(GenerateImageDialog, { attachTo: document.body, props: { open: true, form, disabled: false } }) + wrapper = mount(GenerateImageDialog, { attachTo: document.body, props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile } }) await flushPromises() const width = document.querySelector('#image-width')! width.value = '2048'