feat(short-drama-agent-front): 完善视觉资产审核流程
This commit is contained in:
1 parent
dc8bb17a23
commit
b88ad8770f
45 files changed
+2258
-352
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { validationPreviewResponse } from '../../fixtures/image-preview'
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
@@ -48,7 +49,13 @@ describe('形态图片选择与操作', () => {
|
||||
imageFixture({ id: 'candidate', isPrimary: false, imageUrl: '/storage/candidate.png' }),
|
||||
imageFixture({ id: 'failed', isPrimary: false, status: 'failed', imageUrl: null, error: '生成失败详情' })
|
||||
]
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(new Response(JSON.stringify({ data: rows })))
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async url =>
|
||||
String(url).endsWith('/validate/preview')
|
||||
? validationPreviewResponse(String(url))
|
||||
: new Response(JSON.stringify({ data: rows }))
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
@@ -74,8 +81,8 @@ describe('形态图片选择与操作', () => {
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.asset-image-preview')?.textContent).toContain('本次生成失败')
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
expect(fetcher).toHaveBeenCalledOnce()
|
||||
expect(fetcher.mock.calls[0]![1]?.method).toBe('GET')
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/images'))).toHaveLength(1)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
expect(wrapper.emitted('changed')).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -253,7 +260,8 @@ describe('形态图片选择与操作', () => {
|
||||
it('图库不自动生图,主图切换经确认后 PUT,失败图片不能设主图', async () => {
|
||||
vi.useFakeTimers()
|
||||
let primary = false
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (String(url).endsWith('/validate/preview')) return validationPreviewResponse(String(url))
|
||||
if (init?.method === 'PUT') {
|
||||
primary = true
|
||||
return new Response(JSON.stringify({ data: imageFixture() }))
|
||||
@@ -261,7 +269,7 @@ describe('形态图片选择与操作', () => {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: [
|
||||
imageFixture({ isPrimary: primary }),
|
||||
imageFixture({ isPrimary: primary, qualityPassed: true }),
|
||||
imageFixture({
|
||||
id: 'failed',
|
||||
isPrimary: false,
|
||||
@@ -279,15 +287,15 @@ describe('形态图片选择与操作', () => {
|
||||
props: { projectId: 'gallery-test', form: formFixture('gallery-test'), open: true, disabled: false }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
expect(fetcher.mock.calls).toHaveLength(2)
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
expect(fetcher.mock.calls).toHaveLength(2)
|
||||
await expandSections()
|
||||
expect(document.body.textContent).not.toContain('本次实际提示词')
|
||||
expect(document.querySelector('[role="dialog"] script')).toBeNull()
|
||||
button('设为主参考图').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
expect(fetcher.mock.calls).toHaveLength(2)
|
||||
button('确认费用并设为主图').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
|
||||
|
||||
Reference in new issue
Block a user