style: 优化单次生成设置布局
This commit is contained in:
1 parent
7691346132
commit
90c67e1aa8
5 files changed
+244
-95
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import GenerationModelControls from '../../../src/features/generation-config/components/GenerationModelControls.vue'
|
||||
import type { GenerationModelCatalog } from '../../../src/features/generation-config/types'
|
||||
@@ -40,6 +41,14 @@ const catalog: GenerationModelCatalog = {
|
||||
}
|
||||
|
||||
describe('单次生成模型控件', () => {
|
||||
it('字段采用双列栅格,控件与说明文字纵向排列并在移动端回落单列', () => {
|
||||
const source = readFileSync('src/features/generation-config/components/GenerationModelControls.vue', 'utf8')
|
||||
expect(source).toContain('class="generation-model-field-control"')
|
||||
expect(source).toMatch(/\.generation-model-controls\s*\{[^}]*grid-cols-\[repeat\(2,_minmax\(0,_1fr\)\)\]/)
|
||||
expect(source).toMatch(/\.generation-model-field-control\s*\{[^}]*flex-col[^}]*gap-1\.5/)
|
||||
expect(source).toMatch(/@media \(max-width: 760px\)[\s\S]*?grid-cols-\[minmax\(0,_1fr\)\]/)
|
||||
})
|
||||
|
||||
it('切换图片模型时只使用目标模型 defaults,不保留上一个模型参数', async () => {
|
||||
const wrapper = mount(GenerationModelControls, {
|
||||
props: {
|
||||
|
||||
@@ -33,17 +33,29 @@ describe('镜头生产数据契约', () => {
|
||||
it('三个生产阶段使用统一的块级操作区,保证卡片、按钮和下一阶段之间有稳定间距', () => {
|
||||
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
||||
expect(source.match(/class="production-stage-actions"/g)).toHaveLength(3)
|
||||
expect(source).toMatch(
|
||||
/\.production-stage-actions\s*\{[^}]*mt-4[^}]*min-h-\[34px\][^}]*items-center[^}]*gap-3/
|
||||
)
|
||||
expect(source).toMatch(/\.production-stage-actions\s*\{[^}]*mt-4[^}]*min-h-\[34px\][^}]*items-center[^}]*gap-3/)
|
||||
})
|
||||
|
||||
it('本次视频生成设置限制内容宽度,并统一标题、字段和说明文字间距', () => {
|
||||
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
||||
expect(source).toContain('class="generation-settings-panel surface-inset mt-4"')
|
||||
expect(source).toContain('class="generation-settings-content"')
|
||||
expect(source).toContain('class="generation-input-mode"')
|
||||
expect(source).toMatch(/\.generation-settings-panel\s*\{[^}]*p-5/)
|
||||
expect(source).toMatch(/\.generation-settings-content\s*\{[^}]*max-w-\[1120px\]/)
|
||||
expect(source).toMatch(/\.generation-input-mode-label\s*\{[^}]*mb-\[7px\][^}]*text-xs/)
|
||||
})
|
||||
|
||||
it('首帧、素材引用和视频使用固定上限的正方形网格,不随少量记录撑满整行', () => {
|
||||
const source = readFileSync('src/features/production/components/ShotProductionAssets.vue', 'utf8')
|
||||
expect(source).toContain('v-if="keyframeCandidates.length" class="keyframe-grid mt-4"')
|
||||
expect(source).toContain('v-if="videos.length" class="video-grid mt-4"')
|
||||
expect(source).toMatch(/\.keyframe-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/)
|
||||
expect(source).toMatch(/\.video-input-grid,[\s\S]*?\.video-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/)
|
||||
expect(source).toMatch(
|
||||
/\.keyframe-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
|
||||
)
|
||||
expect(source).toMatch(
|
||||
/\.video-input-grid,[\s\S]*?\.video-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
|
||||
)
|
||||
expect(source).toMatch(/\.keyframe-card \.asset-image\s*\{[^}]*aspect-square/)
|
||||
expect(source).toMatch(/\.production-video\s*\{[^}]*aspect-square/)
|
||||
expect(source).toMatch(/\.video-input-card\s*\{[^}]*bg-\(--app-control\)/)
|
||||
@@ -199,7 +211,9 @@ describe('镜头生产数据契约', () => {
|
||||
await flushPromises()
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: false }]])
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
[{ provider: undefined, generationOptions: {}, setPrimary: false }]
|
||||
])
|
||||
|
||||
await wrapper.setProps({ open: false })
|
||||
await flushPromises()
|
||||
@@ -210,12 +224,41 @@ describe('镜头生产数据契约', () => {
|
||||
await flushPromises()
|
||||
button('确认生成首帧').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')?.at(-1)).toEqual([{ setPrimary: false }])
|
||||
expect(wrapper.emitted('generate')?.at(-1)).toEqual([
|
||||
{ provider: undefined, generationOptions: {}, setPrimary: false }
|
||||
])
|
||||
})
|
||||
|
||||
it('首帧生成前可预览后端最终选图规划和 Prompt', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/generation-models'))
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
defaults: { imageProvider: 'seedream', videoProvider: 'seedance' },
|
||||
images: [
|
||||
{
|
||||
type: 'image',
|
||||
provider: 'seedream',
|
||||
providerLabel: 'Seedream',
|
||||
model: 'image-model',
|
||||
modelLabel: 'Image Model',
|
||||
supported: true,
|
||||
enabled: true,
|
||||
isDefault: true,
|
||||
capabilities: {},
|
||||
generationOptions: [],
|
||||
defaults: {},
|
||||
projectConstraints: []
|
||||
}
|
||||
],
|
||||
videos: []
|
||||
}
|
||||
})
|
||||
)
|
||||
if (path.includes('/creative-profile')) return new Response(JSON.stringify({ data: null }))
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 'shot-1',
|
||||
@@ -252,7 +295,7 @@ describe('镜头生产数据契约', () => {
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(KeyframeDialog, {
|
||||
attachTo: document.body,
|
||||
@@ -261,8 +304,9 @@ describe('镜头生产数据契约', () => {
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toMatchObject({
|
||||
const previewCall = fetcher.mock.calls.find(([url]) => String(url).includes('/keyframe/preview'))
|
||||
expect(previewCall?.[0]).toBe('/api/storyboard-shots/shot-1/keyframe/preview')
|
||||
expect(JSON.parse(String(previewCall?.[1]?.body))).toMatchObject({
|
||||
provider: 'seedream',
|
||||
generationOptions: {}
|
||||
})
|
||||
|
||||
@@ -135,12 +135,11 @@ describe('后端 API 契约', () => {
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
expect(await projectsApi.list()).toEqual([{ id: 'p1' }])
|
||||
expect(await projectsApi.create({ title: '测试项目', topic: '故事', style: '悬疑', episodeCount: 3 })).toEqual({
|
||||
expect(await projectsApi.create({ topic: '故事', style: '悬疑', episodeCount: 3 })).toEqual({
|
||||
projectId: 'p2',
|
||||
status: 'generating'
|
||||
})
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1].body as string)).toEqual({
|
||||
title: '测试项目',
|
||||
topic: '故事',
|
||||
style: '悬疑',
|
||||
episodeCount: 3
|
||||
|
||||
Reference in new issue
Block a user