feat(short-drama-agent-front): 完善质量规则确认与中文交互

This commit is contained in:
GJ committed 2026-10-17 22:09:28 +08:00
1 parent 190333d4f9
commit c4b43b9725
85 files changed
+2059 -480

No files matched your search

+18 -4
View File
@@ -1,8 +1,9 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createMemoryHistory, createRouter } from 'vue-router'
import { NTooltip } from 'naive-ui'
import { NSelect, NTooltip } from 'naive-ui'
import AssetLibraryPage from '@/features/project-assets/AssetLibraryPage.vue'
import AssetCategorySelect from '@/features/project-assets/components/AssetCategorySelect.vue'
let wrapper: VueWrapper | undefined
afterEach(() => {
@@ -52,8 +53,9 @@ describe('全局资产库', () => {
createdAt: '',
updatedAt: ''
}))
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (input, init) => {
const url = String(input)
if (init?.method === 'PUT') return new Response(JSON.stringify({ data: { ...assets[0], ...JSON.parse(String(init.body)) } }))
return new Response(JSON.stringify({ data: url.endsWith('/projects') ? projects : assets }))
})
vi.stubGlobal('fetch', fetcher)
@@ -93,10 +95,22 @@ describe('全局资产库', () => {
await flushPromises()
const dialog = document.querySelector('[role="dialog"][aria-label="素材详情与管理"]')!
expect(dialog).not.toBeNull()
expect([...dialog.querySelectorAll('.n-card__footer button')].map(button => button.textContent?.trim())).toEqual(['删除素材', '取消', '保存修改'])
expect(dialog.querySelector('.asset-management-layout button[type="submit"]')).toBeNull()
expect(dialog.textContent).toContain('rain-street-original.png')
expect(dialog.textContent).toContain('image/png')
expect(dialog.textContent).toContain('PNG 图片')
expect(dialog.textContent).toContain('4.0 KB')
expect(router.currentRoute.value.path).toBe('/assets')
expect(wrapper.getComponent(AssetCategorySelect).getComponent(NSelect).props('options')).toContainEqual({ label: '视觉风格', value: 'visual-style' })
await new DOMWrapper(dialog).get('#library-asset-name').setValue('雨夜街道新版')
wrapper.getComponent(AssetCategorySelect).vm.$emit('update:value', 'visual-style')
await flushPromises()
const save = [...dialog.querySelectorAll<HTMLButtonElement>('.n-card__footer button')].find(button => button.textContent?.trim() === '保存修改')!
save.click()
await flushPromises()
const update = fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')!
expect(update[0]).toBe('/api/projects/project-one/assets/asset-scene')
expect(JSON.parse(String(update[1]?.body))).toEqual({ name: '雨夜街道新版', category: 'visual-style' })
await wrapper.get('input[aria-label="搜索资产图片"]').setValue('天降甘霖')
expect(wrapper.findAll('.asset-library-card')).toHaveLength(1)