feat(short-drama-agent-front): 完善镜头定位与项目配置
This commit is contained in:
1 parent
470b52e26d
commit
5b134207b8
66 files changed
+2042
-984
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import { generationProfile, imageCatalog } from '../../fixtures/generation'
|
||||
import { computed, ref } from 'vue'
|
||||
import { NImage, NRadioGroup, NScrollbar } from 'naive-ui'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi, type Mock } from 'vitest'
|
||||
import CreateProjectDialog from '@/features/projects/components/CreateProjectDialog.vue'
|
||||
import BreakdownPage from '@/features/breakdown/BreakdownPage.vue'
|
||||
import CreateDramaPage from '@/features/create-drama/CreateDramaPage.vue'
|
||||
@@ -15,7 +16,6 @@ import ShotTools from '@/features/storyboard/components/ShotTools.vue'
|
||||
import {
|
||||
designedShot,
|
||||
directionsResult,
|
||||
episodeShots,
|
||||
storyboardCheckpoint,
|
||||
visualStatesResult
|
||||
} from '@/features/storyboard/testing/fixtures'
|
||||
@@ -53,6 +53,58 @@ function jsonResponse(data: unknown) {
|
||||
return new Response(JSON.stringify({ data }))
|
||||
}
|
||||
|
||||
/**
|
||||
* 为页面模拟请求补齐正式模型目录和配置,后台启动返回 202 句柄,结果只从任务 GET 读取;响应逐次复制避免消费同一正文。
|
||||
* @param fetcher 业务 API 模拟请求
|
||||
*/
|
||||
function stubFetch(fetcher: Mock<typeof fetch>) {
|
||||
const implementation = fetcher.getMockImplementation()!
|
||||
const executions = new Map<string, object>()
|
||||
let executionCount = 0
|
||||
fetcher.mockImplementation(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/generation-models')) return jsonResponse(imageCatalog)
|
||||
if (path.endsWith('/creative-profile')) return jsonResponse(generationProfile(fixture.id))
|
||||
if (path.includes('/workflow-executions/')) return jsonResponse(executions.get(path.split('/').at(-1)!))
|
||||
const response = await implementation(url, init)
|
||||
const workflowName = path.endsWith('/storyboard-directions/generate')
|
||||
? 'storyboard-direction'
|
||||
: path.endsWith('/storyboard-visual-states/generate')
|
||||
? 'storyboard-visual-state'
|
||||
: path.endsWith('/storyboard-shots/regenerate')
|
||||
? 'breakdown'
|
||||
: ''
|
||||
if (init?.method === 'POST' && workflowName && response.ok) {
|
||||
const result = (await response.clone().json()).data
|
||||
const executionId = `page-execution-${++executionCount}`
|
||||
const body = JSON.parse(String(init.body))
|
||||
executions.set(executionId, {
|
||||
id: executionId,
|
||||
projectId: fixture.id,
|
||||
workflowName,
|
||||
status: 'completed',
|
||||
stage: 'finalize',
|
||||
current: 1,
|
||||
total: 1,
|
||||
currentResourceId: null,
|
||||
metadata:
|
||||
workflowName === 'breakdown'
|
||||
? { action: 'regenerate-storyboard-episode', episodeNo: body.episodeNo }
|
||||
: null,
|
||||
result,
|
||||
error: null,
|
||||
startedAt: '2026-10-08T00:00:00Z',
|
||||
completedAt: '2026-10-08T00:00:01Z',
|
||||
createdAt: '2026-10-08T00:00:00Z',
|
||||
updatedAt: '2026-10-08T00:00:01Z'
|
||||
})
|
||||
return new Response(JSON.stringify({ data: { executionId, status: 'pending' } }), { status: 202 })
|
||||
}
|
||||
return response.clone()
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
}
|
||||
|
||||
/** 模拟 API 响应仅用于测试,不会打包进生产页面。 */
|
||||
const fixture: ProjectDetail = {
|
||||
id: 'page-test-project',
|
||||
@@ -109,7 +161,9 @@ function button(label: string): HTMLButtonElement {
|
||||
async function confirmGeneration(label: string) {
|
||||
button(label).click()
|
||||
await flushPromises()
|
||||
const acknowledgement = document.querySelector<HTMLElement>('.app-dialog [role="checkbox"]')
|
||||
const acknowledgement = button('确认' + label)
|
||||
.closest('.app-dialog')!
|
||||
.querySelector<HTMLElement>('[role="checkbox"]')
|
||||
expect(button('确认' + label).disabled).toBe(true)
|
||||
acknowledgement!.click()
|
||||
await flushPromises()
|
||||
@@ -153,6 +207,7 @@ afterEach(() => {
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
vi.unstubAllGlobals()
|
||||
localStorage.clear()
|
||||
Object.assign(getStoryboardSession(fixture.id), { receipt: null, prompts: {}, regeneratedEpisodes: {} })
|
||||
getImageSession(fixture.id).receipt = null
|
||||
getImageSession(fixture.id).promptReceipt = null
|
||||
@@ -181,7 +236,7 @@ describe('内容级滚动下的生产反馈', () => {
|
||||
})
|
||||
return jsonResponse([])
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(ProductionPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
@@ -207,7 +262,7 @@ describe('内容级滚动下的生产反馈', () => {
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('默认折叠总览时查询错误仍显示在内容区外层', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockRejectedValue(new Error('生产连接中断')))
|
||||
stubFetch(vi.fn<typeof fetch>().mockRejectedValue(new Error('生产连接中断')))
|
||||
wrapper = mount(ProductionPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
@@ -221,7 +276,7 @@ describe('内容级滚动下的生产反馈', () => {
|
||||
})
|
||||
|
||||
it('回执返回时自动展开总览,部分失败诊断不会留在折叠区内', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockRejectedValue(new Error('离线测试')))
|
||||
stubFetch(vi.fn<typeof fetch>().mockRejectedValue(new Error('离线测试')))
|
||||
wrapper = mount(ProductionPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
@@ -255,17 +310,16 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => jsonResponse(locked === null ? null : styleFixture({ isLocked: locked })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('style')
|
||||
const status = wrapper!.get('.visual-style-status')
|
||||
expect(status.attributes('role')).toBe('status')
|
||||
expect(status.get('strong').text()).toBe(label)
|
||||
expect(status.find('button').exists()).toBe(false)
|
||||
expect(wrapper!.find('.visual-style-toolbar .n-tag').exists()).toBe(false)
|
||||
expect(wrapper!.get('.visual-style-actions').findAll('button')).toHaveLength(2)
|
||||
expect(wrapper!.get('.visual-style-actions').findAll('button')).toHaveLength(1)
|
||||
expect(button(action).disabled).toBe(disabled)
|
||||
expect(button(action).style.getPropertyValue('--n-height')).toBe('34px')
|
||||
expect(button('刷新风格').style.getPropertyValue('--n-height')).toBe('34px')
|
||||
expect(fetcher.mock.calls.every(([, options]) => !options?.method || options.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
@@ -320,9 +374,9 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
await drawerPanel().get('[aria-label="关闭操作面板"]').trigger('click')
|
||||
await drawerPanel().get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
const items = wrapper!.findAll('.identity-subject-item')
|
||||
expect(items).toHaveLength(3)
|
||||
@@ -337,7 +391,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
it('从形态深链接进入后,手动切换主体不会被目录刷新切回', async () => {
|
||||
it('从形态深链接进入后,手动选择其它主体保持当前选择', async () => {
|
||||
const form = formFixture()
|
||||
const second = {
|
||||
...form,
|
||||
@@ -346,8 +400,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
images: [],
|
||||
subject: { ...form.subject, id: 'subject-2', name: '陆川', ref: '@CH0002' }
|
||||
}
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
stubFetch(
|
||||
vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
if (String(url).endsWith('/subject-forms')) return jsonResponse([form, second])
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
|
||||
@@ -360,8 +413,6 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(sidebar.get('.identity-subject-list').findAll('.directory-item')).toHaveLength(2)
|
||||
await wrapper!.findAll('.identity-subject-item')[1]!.trigger('click')
|
||||
await flushPromises()
|
||||
await wrapper!.get('[aria-label="刷新主体目录"]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.findAll('.identity-subject-item')[1]!.attributes('aria-pressed')).toBe('true')
|
||||
})
|
||||
|
||||
@@ -383,23 +434,27 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (init?.method === 'PUT') identity = { ...identity, ...JSON.parse(init.body as string) }
|
||||
return jsonResponse(identity)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
await wrapper!.get('#identity-description').setValue('人工稳定身份')
|
||||
await wrapper!.get('#identity-lock').trigger('click')
|
||||
await new DOMWrapper(document.body).get('#identity-description').setValue('人工稳定身份')
|
||||
await new DOMWrapper(document.body).get('#identity-lock').trigger('click')
|
||||
button('保存主体身份').click()
|
||||
await flushPromises()
|
||||
const put = fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')!
|
||||
expect(put[0]).toBe('/api/subjects/subject-db-1/identity')
|
||||
expect(JSON.parse(put[1]!.body as string)).toMatchObject({ description: '人工稳定身份', isLocked: true })
|
||||
expect(button('生成选角候选').disabled).toBe(false)
|
||||
await wrapper!.get('#identity-description').setValue('新的未保存草稿')
|
||||
await new DOMWrapper(document.body).get('#identity-description').setValue('新的未保存草稿')
|
||||
await wrapper!.findAll('.identity-subject-item')[1]!.trigger('click')
|
||||
expect(wrapper!.text()).toContain('切换会丢弃草稿')
|
||||
expect((wrapper!.get('#identity-description').element as HTMLTextAreaElement).value).toBe('新的未保存草稿')
|
||||
expect(document.body.textContent).toContain('切换会丢弃草稿')
|
||||
expect((new DOMWrapper(document.body).get('#identity-description').element as HTMLTextAreaElement).value).toBe(
|
||||
'新的未保存草稿'
|
||||
)
|
||||
button('放弃草稿并切换').click()
|
||||
await flushPromises()
|
||||
expect((wrapper!.get('#identity-description').element as HTMLTextAreaElement).value).toBe('')
|
||||
expect((new DOMWrapper(document.body).get('#identity-description').element as HTMLTextAreaElement).value).toBe(
|
||||
''
|
||||
)
|
||||
})
|
||||
|
||||
it('风格图拒绝危险 URL,登记只传已有地址及分类排序', async () => {
|
||||
@@ -407,7 +462,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async (_url, init) => jsonResponse(init?.method === 'POST' ? image : styleFixture()))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('style')
|
||||
await wrapper!.get('[aria-label="风格图片地址"]').setValue('javascript:alert(1)')
|
||||
button('登记参考图').click()
|
||||
@@ -431,7 +486,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
|
||||
it('AI 确认取消后重新打开必须再次确认,不能复用上次勾选', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => jsonResponse(styleFixture()))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('style')
|
||||
button('AI 重新生成风格').click()
|
||||
await flushPromises()
|
||||
@@ -451,7 +506,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (init?.method === 'PUT') style = styleFixture(JSON.parse(init.body as string))
|
||||
return jsonResponse(style)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('style')
|
||||
expect(wrapper!.text()).toContain('尚未创建')
|
||||
await expandSections()
|
||||
@@ -479,26 +534,19 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
|
||||
})
|
||||
|
||||
it('刷新风格不覆盖未保存草稿,草稿存在时禁止 AI 重生成', async () => {
|
||||
it('未保存风格草稿保持人工输入并禁止 AI 重生成', async () => {
|
||||
let style = styleFixture()
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async () => jsonResponse(style))
|
||||
)
|
||||
stubFetch(vi.fn<typeof fetch>().mockImplementation(async () => jsonResponse(style)))
|
||||
await mountAssets('style')
|
||||
await wrapper!.get('#style-prompt').setValue('人工草稿')
|
||||
style = styleFixture({ prompt: '后台新内容' })
|
||||
button('刷新风格').click()
|
||||
await flushPromises()
|
||||
expect((wrapper!.get('#style-prompt').element as HTMLTextAreaElement).value).toBe('人工草稿')
|
||||
expect(button('AI 重新生成风格').disabled).toBe(true)
|
||||
})
|
||||
|
||||
it('风格接口 404 显示错误而不是当作空风格,禁止写入', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockResolvedValue(new Response('{"message":"路由不存在"}', { status: 404 }))
|
||||
)
|
||||
stubFetch(vi.fn<typeof fetch>().mockResolvedValue(new Response('{"message":"路由不存在"}', { status: 404 })))
|
||||
await mountAssets('style')
|
||||
expect(wrapper!.text()).toContain('路由不存在')
|
||||
expect(button('AI 生成风格').disabled).toBe(true)
|
||||
@@ -520,7 +568,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(String(url)).toContain('/visual-style')
|
||||
return jsonResponse(styleFixture({ images: removed ? [] : [image] }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('style')
|
||||
button('停用').click()
|
||||
await flushPromises()
|
||||
@@ -546,13 +594,13 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
|
||||
return jsonResponse(null)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(wrapper!.findAll('.identity-subject-item')).toHaveLength(1)
|
||||
expect(wrapper!.text()).toContain('2 个形态')
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/subjects/subject-db-1/identity'))).toBe(true)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/identity/images'))).toBe(false)
|
||||
expect(button('配置生成模型').disabled).toBe(false)
|
||||
expect(button('生成身份文本').disabled).toBe(false)
|
||||
})
|
||||
|
||||
it('锁定阻止身份 AI 覆盖但不阻止人工编辑,并按步骤进入后续操作', async () => {
|
||||
@@ -563,16 +611,16 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (String(url).endsWith('/identity/images')) return jsonResponse([identityImageFixture()])
|
||||
return jsonResponse(identityFixture({ isLocked: true }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(wrapper!.text()).toContain('主体身份已完成')
|
||||
await new DOMWrapper(document.body).get('#identity-description').setValue('人工稳定身份草稿')
|
||||
expect(button('保存主体身份').disabled).toBe(false)
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
|
||||
})
|
||||
|
||||
it('无项目风格时禁止生成身份和图片,但仍可人工保存身份', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
stubFetch(
|
||||
vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
if (String(url).endsWith('/subject-forms')) return jsonResponse([formFixture()])
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(null)
|
||||
@@ -582,6 +630,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
)
|
||||
await mountAssets('identity')
|
||||
expect(button('设置视觉风格').disabled).toBe(false)
|
||||
await new DOMWrapper(document.body).get('#identity-description').setValue('人工稳定身份草稿')
|
||||
expect(button('保存主体身份').disabled).toBe(false)
|
||||
})
|
||||
|
||||
@@ -601,7 +650,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
|
||||
return jsonResponse(null)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
await confirmGeneration('补齐全部主体身份文本')
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
@@ -621,13 +670,18 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
|
||||
if (init?.method === 'PUT') {
|
||||
selected = true
|
||||
return jsonResponse(identityImageFixture({ id: 'candidate' }))
|
||||
return jsonResponse({
|
||||
identityId: 'identity-db-1',
|
||||
subjectId: 'subject-db-1',
|
||||
isLocked: true,
|
||||
anchor: identityImageFixture({ id: 'candidate', isAnchor: true })
|
||||
})
|
||||
}
|
||||
if (String(url).endsWith('/identity/images'))
|
||||
return jsonResponse([identityImageFixture({ id: 'candidate', isAnchor: selected })])
|
||||
return jsonResponse(identityFixture())
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
button('设为身份母版').click()
|
||||
await flushPromises()
|
||||
@@ -635,7 +689,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
button('确认切换身份母版').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
|
||||
'/api/subjects/subject-db-1/identity/images/candidate/anchor'
|
||||
'/api/subjects/subject-db-1/identity/images/candidate/stable-anchor'
|
||||
)
|
||||
expect(wrapper!.text()).toContain('当前身份母版')
|
||||
const anchorImage = wrapper!
|
||||
@@ -686,7 +740,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(drawerPanel().get('.identity-tools-intro').text()).toContain('为同一个人物、场景或道具固定稳定特征')
|
||||
const cards = drawerPanel().get('[aria-label="角色选角进度"]').findAll('.casting-item')
|
||||
@@ -702,7 +756,9 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(cards[0]!.attributes('aria-pressed')).toBe('false')
|
||||
expect(cards[1]!.attributes('aria-pressed')).toBe('true')
|
||||
expect(cards[1]!.classes()).toContain('selected')
|
||||
expect(wrapper!.get<HTMLTextAreaElement>('#identity-description').element.value).toBe('老周的稳定身份')
|
||||
expect(new DOMWrapper(document.body).get<HTMLTextAreaElement>('#identity-description').element.value).toBe(
|
||||
'老周的稳定身份'
|
||||
)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/subjects/subject-db-2/identity'))).toBe(true)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
@@ -751,7 +807,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
}
|
||||
return jsonResponse(identityFixture({ isLocked: locked }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(wrapper!.text()).toContain('等待确认演员')
|
||||
button('确认选角并锁定').click()
|
||||
@@ -788,7 +844,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
identityFixture({ id: 'identity-2', subjectId: 'subject-2', description: '陆川的稳定身份' })
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
await wrapper!.findAll('.identity-subject-item')[1]!.trigger('click')
|
||||
await flushPromises()
|
||||
@@ -797,7 +853,9 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
).toBe(true)
|
||||
finish(jsonResponse(identityFixture()))
|
||||
await flushPromises()
|
||||
expect((wrapper!.get('#identity-description').element as HTMLTextAreaElement).value).toBe('陆川的稳定身份')
|
||||
expect((new DOMWrapper(document.body).get('#identity-description').element as HTMLTextAreaElement).value).toBe(
|
||||
'陆川的稳定身份'
|
||||
)
|
||||
})
|
||||
|
||||
it('生成失败不自动重发,后端正在拆解时禁止身份写操作', async () => {
|
||||
@@ -809,7 +867,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
if (String(url).endsWith('/identity')) return jsonResponse(null)
|
||||
return jsonResponse(identityFixture())
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
const provided = await mountAssets('identity')
|
||||
button('生成身份文本').click()
|
||||
await flushPromises()
|
||||
@@ -817,7 +875,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(getOperation(fixture.id).error).toContain('无法连接后端')
|
||||
provided.data.value!.project = { ...fixture, status: 'generating' }
|
||||
await flushPromises()
|
||||
expect(button('保存主体身份').disabled).toBe(true)
|
||||
expect(new DOMWrapper(document.body).get('#identity-description').attributes('disabled')).toBeDefined()
|
||||
expect(button('生成身份文本').disabled).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -832,7 +890,7 @@ describe('工作台页面交互', () => {
|
||||
subject: { ...person.subject, id: 'scene-subject', ref: '@SC0001', name: '旧书店', module: 'scene' }
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => jsonResponse([person, scene]))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
const filters = wrapper!.get('.form-image-filters')
|
||||
expect(wrapper!.get('.form-image-toolbar').classes()).not.toContain('has-impact-picker')
|
||||
@@ -879,18 +937,23 @@ describe('工作台页面交互', () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: [formFixture()] })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
expect(wrapper!.get('.form-image-card img').attributes('src')).toContain(
|
||||
'/storage/subjects/project/form/image.png'
|
||||
)
|
||||
expect(wrapper!.text()).toContain('林知夏')
|
||||
expect(wrapper!.text()).toContain('主参考图')
|
||||
expect(fetcher.mock.calls.map(([url, init]) => [url, init?.method])).toEqual([
|
||||
['/api/projects/page-test-project/subject-forms', 'GET'],
|
||||
['/api/projects/page-test-project/keyframes/readiness?force=false', 'GET'],
|
||||
['/api/projects/page-test-project/videos/readiness?force=false', 'GET']
|
||||
])
|
||||
expect(fetcher.mock.calls.map(([url, init]) => [url, init?.method])).toEqual(
|
||||
expect.arrayContaining([
|
||||
['/api/projects/page-test-project/subject-forms', 'GET'],
|
||||
['/api/generation-models', 'GET'],
|
||||
['/api/projects/page-test-project/creative-profile', 'GET'],
|
||||
['/api/projects/page-test-project/keyframes/readiness?force=false', 'GET'],
|
||||
['/api/projects/page-test-project/videos/readiness?force=false', 'GET']
|
||||
])
|
||||
)
|
||||
expect(fetcher).toHaveBeenCalledTimes(5)
|
||||
await wrapper!.get('[aria-label="搜索形态图片"]').setValue('不存在的形态')
|
||||
expect(wrapper!.text()).toContain('没有匹配的形态')
|
||||
button('清除筛选').click()
|
||||
@@ -905,9 +968,9 @@ describe('工作台页面交互', () => {
|
||||
.mockImplementation(async url =>
|
||||
jsonResponse(String(url).endsWith('/subject-forms') ? [form] : form.images)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
await drawerPanel().get('[aria-label="关闭操作面板"]').trigger('click')
|
||||
await drawerPanel().get('.n-card-header__close').trigger('click')
|
||||
const card = wrapper!.get('.form-image-card')
|
||||
expect(card.getComponent(NImage).props()).toMatchObject({ objectFit: 'contain', previewDisabled: false })
|
||||
await card.get('img').trigger('click')
|
||||
@@ -916,7 +979,7 @@ describe('工作台页面交互', () => {
|
||||
'/storage/subjects/project/form/image.png'
|
||||
)
|
||||
expect(document.querySelector('.image-history')).toBeNull()
|
||||
expect(fetcher).toHaveBeenCalledTimes(3)
|
||||
expect(fetcher).toHaveBeenCalledTimes(5)
|
||||
document.querySelector<HTMLElement>('.n-image-preview-overlay')!.click()
|
||||
await flushPromises()
|
||||
button('查看图片与记录').click()
|
||||
@@ -930,25 +993,32 @@ describe('工作台页面交互', () => {
|
||||
const form = formFixture()
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) => {
|
||||
if (init?.method === 'POST') {
|
||||
const candidate = imageFixture({ id: 'new-candidate', isPrimary: false, imageUrl: '/storage/new.png' })
|
||||
const candidate = imageFixture({
|
||||
id: 'new-candidate',
|
||||
isPrimary: false,
|
||||
status: 'pending',
|
||||
imageUrl: null
|
||||
})
|
||||
form.images.unshift(candidate)
|
||||
return new Response(JSON.stringify({ data: candidate }))
|
||||
}
|
||||
return new Response(JSON.stringify({ data: [form] }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
button('再生成一张').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
document
|
||||
.querySelector('.app-dialog form')!
|
||||
.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
|
||||
button('确认生成图片').click()
|
||||
await flushPromises()
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(post[0]).toBe('/api/subject-forms/form-db-1/images')
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({ setPrimary: false })
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({
|
||||
setPrimary: false,
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' }
|
||||
})
|
||||
expect(wrapper!.text()).toContain('2 条记录')
|
||||
expect(wrapper!.get('.form-image-card img').attributes('src')).not.toContain('/storage/new.png')
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).includes('production/start'))).toBe(false)
|
||||
@@ -973,7 +1043,7 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
await wrapper!.get('[aria-label="搜索形态图片"]').setValue('@CH0001')
|
||||
await confirmGeneration('补齐项目主参考图')
|
||||
@@ -981,7 +1051,10 @@ describe('工作台页面交互', () => {
|
||||
expect(drawerPanel().text()).toContain('服务暂不可用')
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({ concurrency: 2, force: false })
|
||||
await drawerPanel().get('.n-collapse [role="checkbox"]').trigger('click')
|
||||
await drawerPanel()
|
||||
.findAll('[role="checkbox"]')
|
||||
.find(item => item.text().includes('已有主图也新增候选图'))!
|
||||
.trigger('click')
|
||||
await confirmGeneration('为全项目新增候选图')
|
||||
const lastPost = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST').at(-1)!
|
||||
expect(JSON.parse(lastPost[1]!.body as string).force).toBe(true)
|
||||
@@ -998,15 +1071,17 @@ describe('工作台页面交互', () => {
|
||||
? new Response('{"message":"数据库异常"}', { status: 500 })
|
||||
: new Response(JSON.stringify({ data: [form] }))
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountSubjectImages()
|
||||
expect(button('再生成一张').disabled).toBe(true)
|
||||
expect(wrapper!.text()).toContain('数据库中仍有排队或生成中的图片')
|
||||
expect(wrapper!.text()).toContain('数据库中有形态图片正在后台生成')
|
||||
fail = true
|
||||
button('刷新图库').click()
|
||||
button('查看图片与记录').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('数据库异常')
|
||||
expect(document.body.textContent).toContain('数据库异常')
|
||||
expect(wrapper!.find('.form-image-card img').exists()).toBe(true)
|
||||
await new DOMWrapper(button('刷新图片').closest('.app-dialog')!).get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
expect(button('补齐项目主参考图').disabled).toBe(true)
|
||||
})
|
||||
it('分镜参考图使用 cover 和原生预览,查看图片不触发生成功能', async () => {
|
||||
@@ -1030,9 +1105,8 @@ describe('工作台页面交互', () => {
|
||||
missing: []
|
||||
})
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(ShotTools, { attachTo: document.body, props: { projectId: fixture.id, shot, disabled: false } })
|
||||
button('读取参考图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NImage).props()).toMatchObject({ objectFit: 'cover', previewDisabled: false })
|
||||
const image = wrapper.get('.reference-card img')
|
||||
@@ -1097,9 +1171,8 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(ShotTools, { attachTo: document.body, props: { projectId: fixture.id, shot, disabled: false } })
|
||||
button('读取参考图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('图片不可用')
|
||||
expect(wrapper.find('.reference-card a').exists()).toBe(false)
|
||||
@@ -1130,12 +1203,12 @@ describe('工作台页面交互', () => {
|
||||
)
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
await drawerPanel().get('[aria-label="关闭操作面板"]').trigger('click')
|
||||
await drawerPanel().get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('[data-workspace-tools]').attributes('aria-expanded')).toBe('false')
|
||||
expect(getOperation(fixture.id).pending).toBe(true)
|
||||
@@ -1149,6 +1222,12 @@ describe('工作台页面交互', () => {
|
||||
)
|
||||
)
|
||||
await flushPromises()
|
||||
expect(getStoryboardSession(fixture.id).receipt).toBeNull()
|
||||
expect(localStorage.getItem('short-drama:workflow-execution:page-test-project:storyboard-direction')).toBe(
|
||||
'page-execution-1'
|
||||
)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
expect(getStoryboardSession(fixture.id).receipt).toMatchObject({
|
||||
kind: 'batch',
|
||||
title: '项目导演设计'
|
||||
@@ -1191,7 +1270,7 @@ describe('工作台页面交互', () => {
|
||||
: visualStatesResult(fixture.id)
|
||||
return new Response(JSON.stringify({ data: result }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).not.toContain('生成本集导演设计')
|
||||
@@ -1211,16 +1290,12 @@ describe('工作台页面交互', () => {
|
||||
expect(drawerPanel().text()).toContain('缺少主体状态')
|
||||
})
|
||||
|
||||
it('重生成当前集镜头后刷新正式设计,并用接口回执替换过期 Breakdown 文本', async () => {
|
||||
const regenerated = episodeShots()
|
||||
regenerated.beatShots[0]!.shots[0]!.title = '重生成后的开场镜头'
|
||||
regenerated.beatShots[0]!.shots[0]!.description = '新的镜头正文'
|
||||
it('重生成当前集镜头后读取后台终态,并废弃过期 Breakdown 文本', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (init?.method === 'POST')
|
||||
return jsonResponse({
|
||||
projectId: fixture.id,
|
||||
episodeNo: 1,
|
||||
episodeShot: regenerated,
|
||||
storyboardShotSummary: {
|
||||
episodeCount: 1,
|
||||
beatCount: 2,
|
||||
@@ -1238,20 +1313,25 @@ describe('工作台页面交互', () => {
|
||||
: visualStatesResult(fixture.id)
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await confirmGeneration('重生成第 1 集镜头')
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(post[0]).toBe('/api/projects/page-test-project/storyboard-shots/regenerate')
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({ episodeNo: 1 })
|
||||
expect(wrapper!.text()).toContain('重生成后的开场镜头')
|
||||
expect(wrapper!.text()).toContain('新的镜头正文')
|
||||
expect(wrapper!.text()).not.toContain('第1集镜头1')
|
||||
expect(wrapper!.text()).not.toContain('门口收到一封信')
|
||||
expect(getStoryboardSession(fixture.id).invalidatedEpisodeSources[1]).toBe(true)
|
||||
expect(wrapper!.text()).toContain('新标题和剧情详情尚未提供')
|
||||
expect(drawerPanel().text()).toContain('本集新镜头已保存')
|
||||
expect(drawerPanel().text()).toContain('2 个镜头')
|
||||
expect(fetcher.mock.calls.filter(([, init]) => !init?.method || init.method === 'GET')).toHaveLength(4)
|
||||
expect(fetcher.mock.calls.filter(([, init]) => !init?.method || init.method === 'GET')).toHaveLength(8)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url) === '/api/workflow-executions/page-execution-1')).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
it('批量 200 部分失败不显示全成功,默认补齐与显式覆盖参数独立', async () => {
|
||||
it('后台终态部分失败不显示全成功,默认补齐与显式覆盖参数独立', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (init?.method === 'POST')
|
||||
return new Response(
|
||||
@@ -1286,7 +1366,7 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
@@ -1319,7 +1399,7 @@ describe('工作台页面交互', () => {
|
||||
)
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
selectControl(wrapper!, 'aria-label', '选择分镜剧集').vm.$emit('update:value', 2)
|
||||
@@ -1341,8 +1421,8 @@ describe('工作台页面交互', () => {
|
||||
expect(fetcher.mock.calls).toHaveLength(4)
|
||||
})
|
||||
|
||||
it('查询失败保留已读取镜头并禁用生成,刷新恢复后才允许操作', async () => {
|
||||
let fail = false
|
||||
it('首次分镜读取失败时禁用生成,重试恢复后才允许操作', async () => {
|
||||
let fail = true
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
if (fail) return new Response('{"message":"数据库暂不可用"}', { status: 503 })
|
||||
return new Response(
|
||||
@@ -1353,19 +1433,16 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
fail = true
|
||||
button('刷新分镜').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('shot-db-1-1')
|
||||
expect(wrapper!.text()).toContain('数据库暂不可用')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
fail = false
|
||||
button('重试查询').click()
|
||||
await flushPromises()
|
||||
expect(button('补齐项目导演设计').disabled).toBe(false)
|
||||
expect(wrapper!.text()).toContain('shot-db-1-1')
|
||||
})
|
||||
|
||||
it('镜头工具按需 GET,切换镜头会废弃旧参考图,未完成设计不能编译规格', async () => {
|
||||
@@ -1376,13 +1453,12 @@ describe('工作台页面交互', () => {
|
||||
finish = resolve
|
||||
})
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(ShotTools, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: fixture.id, shot: designedShot(), disabled: false }
|
||||
})
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
button('读取参考图').click()
|
||||
expect(fetcher).toHaveBeenCalledTimes(1)
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/storyboard-shots/shot-db-1-1/references')
|
||||
await wrapper.setProps({ shot: { ...designedShot('shot-db-1-2'), visualState: null } })
|
||||
@@ -1398,40 +1474,41 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
|
||||
it('提示词必须确认才 POST,使用正式 Shot ID,返回内容以纯文本显示', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 'shot-db-1-1',
|
||||
updatedAt: '2026-09-10T00:00:00Z',
|
||||
videoPrompt: '<script>模型内容</script>',
|
||||
negativePrompt: '模糊',
|
||||
status: 'prompt_ready'
|
||||
}
|
||||
})
|
||||
)
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) =>
|
||||
init?.method !== 'POST'
|
||||
? jsonResponse({ shotId: 'shot-db-1-1', references: [], missing: [] })
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 'shot-db-1-1',
|
||||
updatedAt: '2026-09-10T00:00:00Z',
|
||||
videoPrompt: '<script>模型内容</script>',
|
||||
negativePrompt: '模糊',
|
||||
status: 'prompt_ready'
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(ShotTools, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: fixture.id, shot: designedShot(), disabled: false }
|
||||
})
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
await confirmGeneration('读取/生成提示词')
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/storyboard-shots/shot-db-1-1/video-prompt')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string)).toEqual({ force: false })
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(post[0]).toBe('/api/storyboard-shots/shot-db-1-1/video-prompt')
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({ force: false })
|
||||
expect(wrapper.text()).toContain('<script>模型内容</script>')
|
||||
expect(wrapper.find('script').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('提示词生成缺少主首帧时保存当前剧集和镜头作为恢复位置', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
stubFetch(
|
||||
vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
message:
|
||||
'服务器内部错误 Shot 缺少可用于视频 0 秒起点校验的 Primary Keyframe: shot-db-1-1'
|
||||
message: '服务器内部错误 Shot 缺少可用于视频 0 秒起点校验的 Primary Keyframe: shot-db-1-1'
|
||||
}),
|
||||
{ status: 500 }
|
||||
)
|
||||
@@ -1451,8 +1528,7 @@ describe('工作台页面交互', () => {
|
||||
})
|
||||
})
|
||||
it('项目筛选无结果时可清除条件并返回真实列表', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
stubFetch(
|
||||
vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: [fixture] })))
|
||||
)
|
||||
const router = createRouter({
|
||||
@@ -1463,10 +1539,6 @@ describe('工作台页面交互', () => {
|
||||
wrapper = mount(ProjectsPage, { attachTo: document.body, global: { plugins: [router] } })
|
||||
await flushPromises()
|
||||
expect(wrapper.getComponent(NRadioGroup).props('size')).toBe('medium')
|
||||
const refresh = wrapper.get('[aria-label="刷新项目"]')
|
||||
expect(refresh.classes()).toContain('icon-button')
|
||||
expect(refresh.find('.n-button__icon svg').exists()).toBe(true)
|
||||
expect(refresh.text()).toBe('')
|
||||
expect(wrapper.text()).toContain('雨夜来信')
|
||||
await wrapper.get('input[aria-label="搜索项目"]').setValue('不存在的关键词')
|
||||
expect(wrapper.text()).toContain('没有匹配的剧本')
|
||||
@@ -1478,11 +1550,16 @@ describe('工作台页面交互', () => {
|
||||
it('新建弹窗提交真实参数并返回 202 的项目 ID', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValue(new Response('{"projectId":"created","status":"generating"}', { status: 202 }))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
.mockResolvedValue(
|
||||
new Response('{"projectId":"created","executionId":"create-1","status":"pending"}', { status: 202 })
|
||||
)
|
||||
stubFetch(fetcher)
|
||||
wrapper = mount(CreateProjectDialog, { attachTo: document.body })
|
||||
button('新建剧本').click()
|
||||
await flushPromises()
|
||||
const title = document.querySelector<HTMLInputElement>('#title')!
|
||||
title.value = ' 雨夜来信标题 '
|
||||
title.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
const topic = document.querySelector<HTMLTextAreaElement>('#topic')!
|
||||
topic.value = ' 雨夜来信 '
|
||||
topic.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
@@ -1491,8 +1568,9 @@ describe('工作台页面交互', () => {
|
||||
count.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
document.querySelector('form')!.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('created')).toEqual([['created']])
|
||||
expect(wrapper.emitted('created')).toEqual([['created', 'create-1']])
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string)).toEqual({
|
||||
title: '雨夜来信标题',
|
||||
topic: '雨夜来信',
|
||||
style: '',
|
||||
episodeCount: 6
|
||||
@@ -1507,7 +1585,7 @@ describe('工作台页面交互', () => {
|
||||
)
|
||||
return new Response('{"data":{"workflowExecution":{"status":"completed"}}}')
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
stubFetch(fetcher)
|
||||
const provided = context()
|
||||
wrapper = mount(BreakdownPage, {
|
||||
attachTo: document.body,
|
||||
|
||||
Reference in new issue
Block a user