feat(short-drama-agent-front): 接入关系修复并优化配置与弹窗

This commit is contained in:
GJ committed 2026-10-31 22:37:22 +08:00
1 parent 2db8549818
commit 41d1cfe3ed
15 files changed
+1134 -323

No files matched your search

+65 -2
View File
@@ -40,6 +40,9 @@ import { drawerPanel, expandSections, selectControl } from '@/testing/naive'
import ProductionPage from '@/features/production/ProductionPage.vue'
import RawDataDetails from '@/components/ui/RawDataDetails.vue'
import { getProductionSession } from '@/features/production/model'
import { generationConfigApi } from '@/features/generation-config/api'
import { AppDialog } from '@/components/ui'
import { projectSettingsOpenKey } from '@/features/generation-config/context'
/**
* 为内存路由补齐页面链接使用的正式项目工作区,避免链接解析时缺少目标路由。
@@ -69,16 +72,23 @@ function createPageRouter(routes: RouteRecordRaw[]) {
* 新资产页面复用已有项目上下文和内存路由,不接入真实模型。
* @param page 要挂载的风格或主体身份页面
* @param query 初始地址的查询参数
* @param openSettings 可选的项目顶栏配置入口
* @returns 当前页面注入的项目上下文
*/
async function mountAssets(page: 'style' | 'identity', query = '') {
async function mountAssets(page: 'style' | 'identity', query = '', openSettings?: () => void) {
const component = page === 'style' ? VisualStylePage : SubjectIdentityPage
const router = createPageRouter([{ path: '/assets', component }])
await router.push('/assets' + query)
const provided = context()
wrapper = mount(component, {
attachTo: document.body,
global: { plugins: [router], provide: { [projectContextKey as symbol]: provided } }
global: {
plugins: [router],
provide: {
[projectContextKey as symbol]: provided,
...(openSettings ? { [projectSettingsOpenKey as symbol]: openSettings } : {})
}
}
})
await flushPromises()
if (page === 'identity') await expandSections()
@@ -389,6 +399,59 @@ describe('内容级滚动下的生产反馈', () => {
})
describe('视觉风格与主体身份工作区', () => {
it.each(['AI 生成角色候选图', '生成辅助参考图', '批量生成角色候选图', '生成场景母版', '生成道具母版'])(
'缺少模型时点击%s先提示配置,不出现费用确认也不发送生成请求',
async label => {
vi.spyOn(generationConfigApi, 'profile').mockResolvedValue(null)
vi.spyOn(subjectIdentityApi, 'castingReadiness').mockResolvedValue({
total: 1,
ready: 0,
missingIdentity: 0,
missingAnchor: 1,
candidatePending: 0,
unlocked: 1,
locked: 0,
items: []
})
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
if (String(url).endsWith('/subject-forms')) return jsonResponse([formFixture()])
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
if (String(url).endsWith('/identity/images')) return jsonResponse([])
return jsonResponse(identityFixture())
})
stubFetch(fetcher)
const openSettings = vi.fn<() => void>()
await mountAssets('identity', '', openSettings)
const batch = label.startsWith('批量') || label.includes('母版')
if (!batch) {
const tools = wrapper!.findComponent({ name: 'WorkspaceTools' })
tools.vm.$emit('update:open', false)
tools.vm.$emit('closed')
await flushPromises()
}
expect(document.body.textContent).not.toContain('立即配置')
expect(button(label).disabled).toBe(false)
button(label).click()
await flushPromises()
if (batch) {
wrapper!.findComponent({ name: 'WorkspaceTools' }).vm.$emit('closed')
await flushPromises()
}
const dialog = document.querySelector('.app-dialog')
expect(dialog?.textContent).toContain('需要配置生成模型')
expect(dialog?.textContent).toContain('项目配置')
expect(dialog?.textContent).not.toContain('我已确认后台任务停止')
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
button('前往项目配置').click()
await flushPromises()
expect(openSettings).not.toHaveBeenCalled()
wrapper!
.findAllComponents(AppDialog)
.find(item => item.props('title') === '需要配置生成模型')!
.vm.$emit('closed')
expect(openSettings).toHaveBeenCalledExactlyOnceWith('generation')
}
)
it('当前主体已确认但其它角色未完成时,隐藏形态入口;保存后按新阶段状态开放', async () => {
/** 当前主体已锁定,其它角色仍未确认,用真实项目准入规则约束页面入口。 */
const saved = identityFixture({ isLocked: true })