feat(short-drama-agent-front): 接入人工动作修订与视频版本权限

This commit is contained in:
GJ committed 2026-10-14 13:44:02 +08:00
1 parent 7a60db3ced
commit fa76165960
38 files changed
+2003 -158

No files matched your search

@@ -62,7 +62,7 @@ const record = (workflowName: string, day: number, status: 'running' | 'complete
})
describe('精简公开资产回归', () => {
it('无内部字段的视频可播放,未知质量不得直接晋升;真实校验结果按项目隔离', async () => {
it('无内部字段的视频可播放,晋升使用后端权限,会话通过不能授权', async () => {
const projectId = 'public-video-contract'
const video = videoFixture({ isPrimary: false })
expect(video).not.toHaveProperty('rawJson')
@@ -104,7 +104,7 @@ describe('精简公开资产回归', () => {
await flushPromises()
expect(
[...document.querySelectorAll('button')].some(button => button.textContent?.trim() === '设为主视频')
).toBe(true)
).toBe(false)
expect(sessionVideoValidation('other-project', shot.shotId, video.id)).toBeNull()
session.videoValidation = { ...validation, passed: false }
await flushPromises()
+19 -1
View File
@@ -1,3 +1,4 @@
import { ApiError } from '@/lib/http'
import { defineComponent, reactive, ref } from 'vue'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
@@ -542,11 +543,27 @@ describe('质量面板渐进展示', () => {
})
describe('视频修复候选与复检晋升', () => {
it('只允许校验未通过的视频创建一个候选,不自动再次校验', async () => {
it('视频修复遇到同步版本冲突后撤销本会话旧资格并刷新', async () => {
const data = setup({ kind: 'video', shotId: 'shot-1', assetId: 'video-1', title: '视频' })
data.video.canRepair = true
data.validation.passed = false
await data.service.run('validate', input())
expect(sessionVideoValidation(data.projectId, 'shot-1', 'video-1')?.passed).toBe(false)
vi.spyOn(qualityApi, 'repairVideo').mockRejectedValueOnce(
new ApiError('动作版本已过期', 409, { currentMotionPlanRevisionId: 'r2' }, 'MOTION_PLAN_STALE')
)
await data.service.run('repair', input({ maxRepairAttempts: 2 }))
expect(sessionVideoValidation(data.projectId, 'shot-1', 'video-1')).toBeNull()
expect(data.service.session.value.error).toContain('动作版本已过期')
expect(qualityApi.repairVideo).toHaveBeenCalledTimes(1)
})
it('只允许后端授予修复权限的视频创建候选,不自动再次校验', async () => {
const data = setup({ kind: 'video', shotId: 'shot-1', assetId: 'video-1', title: '视频' })
await data.service.run('repair', input({ maxRepairAttempts: 2 }))
expect(data.posts()).toHaveLength(0)
data.validation.passed = false
data.video.canRepair = true
await data.service.run('validate', input())
data.fetcher.mockClear()
await data.service.run('repair', input({ maxRepairAttempts: 2 }))
@@ -562,6 +579,7 @@ describe('视频修复候选与复检晋升', () => {
it('修复不接受零次上限,后端次数限制错误原样保留且不重试', async () => {
const data = setup({ kind: 'video', shotId: 'shot-1', assetId: 'video-1', title: '视频' })
data.validation.passed = false
data.video.canRepair = true
await data.service.run('validate', input())
data.fetcher.mockClear()
await data.service.run('repair', input({ maxRepairAttempts: 0 }))
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest'
import { videoOperationAllowed } from '@/features/production/video-permissions'
import { videoFixture } from '@/features/production/testing/fixtures'
describe('视频候选操作权限', () => {
it('每个候选独立使用后端权限,两个空版本不自行视为过期', () => {
const first = videoFixture({ canValidate: false, canRepair: true, canSetPrimary: false })
const second = videoFixture({ canValidate: true, canRepair: false, canSetPrimary: true })
expect(videoOperationAllowed(first, 'validate')).toBe(false)
expect(videoOperationAllowed(first, 'repair')).toBe(true)
expect(videoOperationAllowed(second, 'repair')).toBe(false)
expect(videoOperationAllowed(second, 'primary')).toBe(true)
})
it.each(['validate', 'repair', 'primary'] as const)('过期或已终止候选不能执行 %s,即使曾经通过', action => {
const permissions = { canValidate: true, canRepair: true, canSetPrimary: true }
expect(videoOperationAllowed(videoFixture({ ...permissions, motionPlanStale: true }), action)).toBe(false)
expect(
videoOperationAllowed(videoFixture({ ...permissions, qualityTerminalStatus: 'stale_motion_plan' }), action)
).toBe(false)
})
it('缺失权限不能当作允许操作', () => expect(videoOperationAllowed({}, 'validate')).toBe(false))
})
@@ -15,6 +15,14 @@ const qualityStatus: ShotVideoQualityStatus = {
chain: [
{
videoId: 'video-failed',
motionPlanRevisionId: null,
currentMotionPlanRevisionId: null,
motionPlanStale: false,
qualityTerminalStatus: null,
staleReason: null,
canValidate: true,
canRepair: false,
canSetPrimary: false,
providerStatus: 'completed',
isPrimary: false,
repairAttempt: 0,
@@ -25,6 +33,14 @@ const qualityStatus: ShotVideoQualityStatus = {
},
{
videoId: 'video-passed',
motionPlanRevisionId: null,
currentMotionPlanRevisionId: null,
motionPlanStale: false,
qualityTerminalStatus: null,
staleReason: null,
canValidate: true,
canRepair: false,
canSetPrimary: false,
providerStatus: 'completed',
isPrimary: true,
repairAttempt: 1,