feat(short-drama-agent-front): 新增视觉风格骨架屏并优化参考图添加
This commit is contained in:
1 parent
3cc65aa056
commit
519b956808
11 files changed
+621
-242
No files matched your search
@@ -127,18 +127,18 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
expect(wrapper.emitted('generate')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('折叠后的非法 JSON 仍拦截保存并展开错误,修正后保留草稿正常提交', async () => {
|
||||
it('分类风格始终显示,非法 JSON 拦截保存,修正后保留草稿正常提交', async () => {
|
||||
wrapper = mount(StyleEditor, { attachTo: document.body, props: { visualStyle: null, disabled: false } })
|
||||
await flushPromises()
|
||||
expect(button('分类风格与硬约束').getAttribute('aria-expanded')).toBe('true')
|
||||
expect(wrapper.find('button[aria-expanded]').exists()).toBe(false)
|
||||
expect(wrapper.get('.style-category-section h3').text()).toBe('分类风格与硬约束')
|
||||
expect(wrapper.findAll('.style-category-fields .n-form-item')).toHaveLength(3)
|
||||
await input('#style-name', '手工风格')
|
||||
await input('#style-constraints', '{"invalid":true}')
|
||||
button('分类风格与硬约束').click()
|
||||
await flushPromises()
|
||||
await submit()
|
||||
expect(wrapper.emitted('save')).toBeUndefined()
|
||||
expect(feedback()).toContain('请输入 JSON 字符串数组')
|
||||
expect(button('分类风格与硬约束').getAttribute('aria-expanded')).toBe('true')
|
||||
expect(wrapper.get('#style-constraints').isVisible()).toBe(true)
|
||||
await input('#style-constraints', '["真人写实"]')
|
||||
await submit()
|
||||
expect(wrapper.emitted('save')?.[0]?.[0]).toMatchObject({ name: '手工风格', hardConstraints: ['真人写实'] })
|
||||
@@ -149,6 +149,10 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'form-test-project', images: [], disabled: false }
|
||||
})
|
||||
expect(document.querySelector('[aria-label="风格图片地址"]')).toBeNull()
|
||||
expect(wrapper.text()).not.toContain('先保存视觉风格')
|
||||
button('通过链接添加').click()
|
||||
await flushPromises()
|
||||
await input('[aria-label="风格图片地址"]', 'javascript:alert(1)')
|
||||
await input('[aria-label="风格图片排序"]', '1.5')
|
||||
await submit()
|
||||
@@ -191,7 +195,7 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
})
|
||||
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
button('从资产库选择').click()
|
||||
button('从资产库添加').click()
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledWith(
|
||||
'/api/projects/form-test-project/assets',
|
||||
@@ -201,8 +205,13 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
expect(option.textContent).toContain('人物质感参考')
|
||||
option.click()
|
||||
await flushPromises()
|
||||
button('登记为整体参考图').click()
|
||||
await flushPromises()
|
||||
await input('[aria-label="风格图片排序"]', '1.5')
|
||||
await submit()
|
||||
expect(feedback()).toContain('排序须为整数')
|
||||
expect(wrapper.emitted('add')).toBeUndefined()
|
||||
await input('[aria-label="风格图片排序"]', '-1')
|
||||
await submit()
|
||||
expect(document.querySelector('[aria-label="风格图片地址"]')).toBeNull()
|
||||
expect(wrapper.emitted('add')?.[0]?.[0]).toMatchObject({
|
||||
projectAssetId: 'asset-db-1',
|
||||
category: 'overall',
|
||||
@@ -210,6 +219,30 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('未保存风格时禁用两个入口,资产读取失败可在弹窗重试', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response('{"message":"素材读取失败"}', { status: 500 }))
|
||||
.mockResolvedValue(new Response('{"data":[]}'))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(StyleImages, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'form-test-project', images: [], disabled: true, hasStyle: false }
|
||||
})
|
||||
expect(wrapper.text()).toContain('先保存视觉风格')
|
||||
expect(button('从资产库添加').disabled).toBe(true)
|
||||
expect(button('通过链接添加').disabled).toBe(true)
|
||||
await wrapper.setProps({ disabled: false, hasStyle: true })
|
||||
button('从资产库添加').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.app-dialog')?.textContent).toContain('素材读取失败')
|
||||
expect(button('添加参考图').disabled).toBe(true)
|
||||
button('重试读取素材').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.app-dialog')?.textContent).toContain('资产库暂无图片')
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('异步验证期间切换对象或重复提交不会执行旧动作', async () => {
|
||||
let finish: (() => void) | undefined
|
||||
const model = reactive({ text: '有效输入' })
|
||||
|
||||
Reference in new issue
Block a user