feat: 优化生成配置布局与选项控件
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { NInputNumber, NSelect } from 'naive-ui'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import GenerationOptionFields from '../../../src/features/generation-config/components/GenerationOptionFields.vue'
|
||||
import type { GenerationOptionSchema } from '../../../src/features/generation-config/types'
|
||||
|
||||
function mountFields(schemas: GenerationOptionSchema[]) {
|
||||
return mount(GenerationOptionFields, {
|
||||
props: { schemas, modelValue: { size: '2K', durationSeconds: 4, seed: 1 } }
|
||||
})
|
||||
}
|
||||
|
||||
describe('生成模型参数字段', () => {
|
||||
it('图片尺寸使用下拉框并保留标准尺寸与当前值', () => {
|
||||
const wrapper = mountFields([
|
||||
{ key: 'size', label: '图片尺寸', type: 'size', required: true, providerDefault: 'auto' }
|
||||
])
|
||||
const select = wrapper.getComponent(NSelect)
|
||||
expect(select.props('clearable')).toBe(false)
|
||||
expect(select.props('options')).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ value: '1K' }),
|
||||
expect.objectContaining({ value: '1.5K' }),
|
||||
expect.objectContaining({ value: '2K' }),
|
||||
expect.objectContaining({ value: 'auto' })
|
||||
])
|
||||
)
|
||||
expect(wrapper.findComponent(NInputNumber).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('视频时长按后端范围生成秒数选项,其他数值仍可输入', () => {
|
||||
const wrapper = mountFields([
|
||||
{
|
||||
key: 'durationSeconds',
|
||||
label: '生成时长',
|
||||
type: 'integer',
|
||||
required: true,
|
||||
min: 4,
|
||||
max: 6,
|
||||
specialValues: [{ label: '自动', value: -1 }]
|
||||
},
|
||||
{ key: 'seed', label: '随机种子', type: 'integer', required: false }
|
||||
])
|
||||
const select = wrapper.getComponent(NSelect)
|
||||
expect(select.props('options')).toEqual([
|
||||
{ label: '自动', value: -1 },
|
||||
{ label: '4 秒', value: 4 },
|
||||
{ label: '5 秒', value: 5 },
|
||||
{ label: '6 秒', value: 6 }
|
||||
])
|
||||
expect(wrapper.findAllComponents(NInputNumber)).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user