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
@@ -0,0 +1,66 @@
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { NCollapse } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import FormSourceDiagnostics from '@/features/subject-images/components/FormSourceDiagnostics.vue'
|
||||
import { formFixture } from '@/features/subject-images/testing/fixtures'
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('道具与场景来源诊断', () => {
|
||||
it.each([
|
||||
['missing', '尚未准备结构规格'],
|
||||
['stale', '结构来源已过期']
|
||||
])('道具 %s 只读取原文和历史,不调用生成', async (status, label) => {
|
||||
const form = formFixture('source-project')
|
||||
form.subject.module = 'prop'
|
||||
const fetcher = vi.fn<typeof fetch>(
|
||||
async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
subjectFormId: form.id,
|
||||
status,
|
||||
spec: null,
|
||||
sourceEpisodes: [
|
||||
{ episodeId: 'origin', episode: 1, title: '基础形态' },
|
||||
{ episodeId: 'change', episode: 2, title: '拆卸' }
|
||||
],
|
||||
ownershipEvidence: [
|
||||
{
|
||||
name: '搭扣',
|
||||
quantity: 2,
|
||||
episodeId: 'origin',
|
||||
sourceQuote: '工具箱有两个搭扣',
|
||||
relationEpisodeId: 'change',
|
||||
relationQuote: '搭扣从工具箱脱落'
|
||||
}
|
||||
],
|
||||
lastGenerationAttempt: {
|
||||
status: 'failed',
|
||||
sourceCurrent: false,
|
||||
error: '无法核对归属',
|
||||
evidence: { candidates: [{ semanticClass: '工具箱' }] },
|
||||
inputSnapshot: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(FormSourceDiagnostics, { props: { form, projectId: 'source-project' } })
|
||||
try {
|
||||
await flushPromises()
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
wrapper.getComponent(NCollapse).vm.$emit('update:expandedNames', ['source'])
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain(label)
|
||||
expect(wrapper.text()).toContain('数量来源 · 第 1 集')
|
||||
expect(wrapper.text()).toContain('拆装来源 · 第 2 集')
|
||||
expect(wrapper.text()).toContain('准备时的来源已过期')
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
expect(fetcher.mock.calls[0]?.[1]?.method).toBe('GET')
|
||||
} finally {
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user