feat(short-drama-agent-front): 完善分镜审核与制作准备流程
This commit is contained in:
1 parent
c4b43b9725
commit
1da56e0d46
72 files changed
+2801
-528
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { effectScope, ref } from 'vue'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import { useBreakdownStartPolicy } from '@/features/breakdown/useBreakdownStartPolicy'
|
||||
import { candidatePreviewReady } from '@/features/breakdown/candidate'
|
||||
import { policyReceipt } from '../../fixtures/quality-policy'
|
||||
import { commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
|
||||
/** 当前规则;格式版本不能代替服务修订版本。 */
|
||||
const policy = { version: 1 as const, physicsMode: 'realistic' as const, allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] }
|
||||
afterEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); localStorage.clear() })
|
||||
|
||||
describe('服务端规则确认契约', () => {
|
||||
it('保存发送规则和期望修订,明确确认使用独立接口', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: policyReceipt('p', policy) })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await projectsApi.saveQualityPolicy('p', policy, 2)
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toEqual({ policy, expectedRevision: 2 })
|
||||
await projectsApi.confirmQualityPolicy('p', 2)
|
||||
expect(fetcher.mock.calls[1]?.[0]).toBe('/api/projects/p/quality-policy/confirm')
|
||||
expect(JSON.parse(String(fetcher.mock.calls[1]?.[1]?.body))).toEqual({ expectedRevision: 2 })
|
||||
})
|
||||
it('服务已确认的规则跨浏览器直接进入费用确认,启动携带真实修订版本', async () => {
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('p', policy, { confirmed: true, confirmedRevision: 2, confirmedAt: '2026-10-17T15:00:00Z' }))
|
||||
const scope = effectScope()
|
||||
try {
|
||||
const flow = scope.run(() => useBreakdownStartPolicy(ref('p'), ref('scope'), ref(true)))!
|
||||
await flow.prepare()
|
||||
expect(flow.reviewOpen.value).toBe(false)
|
||||
expect(flow.startOpen.value).toBe(true)
|
||||
expect(await flow.verifyStart()).toBe(true)
|
||||
expect(flow.consumePermit()).toEqual({ expectedRevision: 2 })
|
||||
expect(flow.consumePermit()).toBeNull()
|
||||
} finally { scope.stop() }
|
||||
})
|
||||
it('候选安全检查必须包含规则匹配,缺失或 false 均不可提交', () => {
|
||||
const preview = commitPreview()
|
||||
expect(candidatePreviewReady({ ...preview, checks: { ...preview.checks, qualityPolicyMatches: false } }, preview.projectId, preview.checkpointId)).toBe(false)
|
||||
const missing = structuredClone(preview)
|
||||
delete (missing.checks as Partial<typeof missing.checks>).qualityPolicyMatches
|
||||
expect(candidatePreviewReady(missing, preview.projectId, preview.checkpointId)).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user