feat(short-drama-agent-front): 补齐首帧审核与视线修订
This commit is contained in:
1 parent
c7a6b12261
commit
0d58dd8c53
25 files changed
+1140
-30
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>首帧增量能力隔离验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./b04-review.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,126 @@
|
||||
import { createApp, defineComponent, h, ref } from 'vue'
|
||||
import { NButton, NConfigProvider, NMessageProvider } from 'naive-ui'
|
||||
import QualityDialog from '../../src/features/production/components/QualityDialog.vue'
|
||||
import SourceReviewDrawer from '../../src/features/production/components/SourceReviewDrawer.vue'
|
||||
import { validationPreview } from '../fixtures/validation-preview'
|
||||
import '../../src/styles/styles.css'
|
||||
import '../../src/styles/admin.css'
|
||||
/** 仅本隔离页的当前计划状态。 */
|
||||
const status = ref<'ready' | 'blocked' | 'reusable'>('ready')
|
||||
/** 重新打开不同隔离状态。 */
|
||||
const revision = ref(0)
|
||||
/** 仅允许加载本地静态测试图片。 */
|
||||
const nativeFetch = window.fetch.bind(window)
|
||||
/**
|
||||
* 隔离所有 API;全部写入返回拒绝,不能连接真实 Provider。
|
||||
* @param input 请求路径
|
||||
* @param init 请求选项
|
||||
* @returns 隔离回执
|
||||
*/
|
||||
window.fetch = async (input, init) => {
|
||||
if (init?.method && init.method !== 'GET')
|
||||
return new Response(JSON.stringify({ message: '隔离验收禁止写入' }), { status: 403 })
|
||||
const path = String(input)
|
||||
if (path.includes('/tests/browser/')) return nativeFetch(input, init)
|
||||
const data = path.includes('/validate/preview')
|
||||
? {
|
||||
...validationPreview,
|
||||
status: status.value,
|
||||
activeTasks: status.value === 'blocked' ? [{ status: 'running' }] : [],
|
||||
reusableResult:
|
||||
status.value === 'reusable' ? { passed: false, summary: '历史审核未通过,复用不重复计费' } : null
|
||||
}
|
||||
: path.includes('/quality-review')
|
||||
? {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
qualityDecision: 'failed',
|
||||
effectiveQualityStatus: 'stale',
|
||||
manualReviewAvailable: false,
|
||||
validationTaskId: 't',
|
||||
historicalGazePreview: [],
|
||||
manualReview: null
|
||||
}
|
||||
: path.includes('/source-review/preview')
|
||||
? {
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
imageUrl: 'http://localhost:4312/tests/browser/candidate.svg',
|
||||
fingerprint: 'a'.repeat(64),
|
||||
originalPixels: { sha256: 'b'.repeat(64) },
|
||||
originalInputFingerprint: 'c'.repeat(64),
|
||||
originalProviderInput: {},
|
||||
sourceChanges: {},
|
||||
historicalVision: [],
|
||||
references: [
|
||||
{ imageNumber: 1, imageUrl: 'http://localhost:4312/tests/browser/candidate.svg', imageId: 'i' }
|
||||
],
|
||||
currentReferenceInput: {
|
||||
references: [{ imageNumber: 1, bindings: [{ subjectRef: '@CH1', role: 'identity-anchor' }] }]
|
||||
},
|
||||
applicabilityBasis: {
|
||||
fingerprint: 'd'.repeat(64),
|
||||
actionIds: ['A1', 'A2'],
|
||||
cameraMovement: 'static',
|
||||
references: [{ imageNumber: 1, subjectRefs: ['@CH1'] }],
|
||||
facts: {
|
||||
rawJson: JSON.stringify({
|
||||
requiredActions: [
|
||||
{ id: 'A1', description: '静立' },
|
||||
{ id: 'A2', description: '观察' }
|
||||
]
|
||||
}),
|
||||
direction: { cameraMovement: 'static' },
|
||||
visualState: { gaze: '朝向画面左侧' }
|
||||
}
|
||||
}
|
||||
}
|
||||
: []
|
||||
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } })
|
||||
}
|
||||
/** 真实组件的只读隔离验收入口。 */
|
||||
const Preview = defineComponent({
|
||||
setup() {
|
||||
/** 质量面板可见性。 */ const open = ref(false)
|
||||
/** 来源面板可见性。 */ const source = ref(false)
|
||||
return () =>
|
||||
h('main', { style: 'padding:24px;height:100dvh;overflow:auto' }, [
|
||||
h('h1', { style: 'margin-bottom:20px' }, 'B04 首帧审核隔离验收(全部写请求禁止)'),
|
||||
h('div', { style: 'display:flex;flex-wrap:wrap;gap:12px' }, [
|
||||
...(['ready', 'blocked', 'reusable'] as const).map(value =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
status.value = value
|
||||
revision.value++
|
||||
open.value = true
|
||||
}
|
||||
},
|
||||
() => value
|
||||
)
|
||||
),
|
||||
h(NButton, { onClick: () => (source.value = true) }, () => '来源证据范围')
|
||||
]),
|
||||
h(QualityDialog, {
|
||||
key: revision.value,
|
||||
open: open.value,
|
||||
'onUpdate:open': (v: boolean) => (open.value = v),
|
||||
projectId: 'p',
|
||||
target: { kind: 'keyframe', shotId: 's', assetId: 'k', title: '隔离候选' },
|
||||
disabled: true
|
||||
}),
|
||||
h(SourceReviewDrawer, {
|
||||
open: source.value,
|
||||
'onUpdate:open': (v: boolean) => (source.value = v),
|
||||
projectId: 'p',
|
||||
shotId: 's',
|
||||
keyframeId: 'k'
|
||||
})
|
||||
])
|
||||
}
|
||||
})
|
||||
createApp({
|
||||
render: () => h(NConfigProvider, null, { default: () => h(NMessageProvider, null, { default: () => h(Preview) }) })
|
||||
}).mount('#app')
|
||||
@@ -0,0 +1,77 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
validAssessment,
|
||||
type ApplicabilityBasis,
|
||||
type EvidenceAssessment
|
||||
} from '@/features/production/source-applicability'
|
||||
/** 正式完整依据,不按物件名称推断。 */
|
||||
const basis: ApplicabilityBasis = {
|
||||
fingerprint: 'a'.repeat(64),
|
||||
actionIds: ['a1', 'a2'],
|
||||
cameraMovement: 'static',
|
||||
references: [{ imageNumber: 1, subjectRefs: ['@SC1'] }],
|
||||
facts: {}
|
||||
}
|
||||
/**
|
||||
* 构建已经逐项核对的人工范围。
|
||||
* @returns 完整声明
|
||||
*/
|
||||
function assessment(): EvidenceAssessment {
|
||||
return {
|
||||
imageNumber: 1,
|
||||
dimension: 'structure',
|
||||
featureKey: '局部结构',
|
||||
subjectRef: '@SC1',
|
||||
requirement: 'non_blocking_unknown',
|
||||
evidence: '当前镜头不可见,其它证据已核对',
|
||||
actions: ['a1', 'a2'].map(actionId => ({ actionId, requiresEvidence: false, reason: '当前动作不依赖此结构' })),
|
||||
stateRequiresEvidence: false,
|
||||
framingRequiresEvidence: false,
|
||||
noVisibleContradiction: true,
|
||||
remainingEvidenceVerified: true
|
||||
}
|
||||
}
|
||||
describe('有界证据适用性', () => {
|
||||
it('仅完整正式依据与人工声明可准备非阻断范围', () => {
|
||||
expect(validAssessment(assessment(), basis)).toBe(true)
|
||||
})
|
||||
it.each(['pan', null])('非固定或缺失机位 %s 拒绝豁免', cameraMovement => {
|
||||
expect(validAssessment(assessment(), { ...basis, cameraMovement })).toBe(false)
|
||||
})
|
||||
it('动作缺失、遗漏、重复均不可豁免', () => {
|
||||
expect(validAssessment(assessment(), { ...basis, actionIds: null })).toBe(false)
|
||||
const item = assessment()
|
||||
item.actions.pop()
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
item.actions.push(item.actions[0]!)
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
})
|
||||
it('外来主体和未确认反证不可豁免', () => {
|
||||
const item = assessment()
|
||||
item.subjectRef = '@SC2'
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
item.subjectRef = '@SC1'
|
||||
item.noVisibleContradiction = null
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
})
|
||||
it('任何必要依赖或反证均拒绝非阻断', () => {
|
||||
for (const field of ['stateRequiresEvidence', 'framingRequiresEvidence'] as const) {
|
||||
const item = assessment()
|
||||
item[field] = true
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
}
|
||||
const item = assessment()
|
||||
item.actions[0]!.requiresEvidence = true
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
item.actions[0]!.requiresEvidence = false
|
||||
item.noVisibleContradiction = false
|
||||
expect(validAssessment(item, basis)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
it('正式审核原件读取路径可以进入公共图片组件,任意路径不扩展权限', async () => {
|
||||
const { validationImageUrl } = await import('@/features/production/validation-preview')
|
||||
const path = '/api/storyboard-shots/s/keyframes/k/generation-input/references/1?projectId=p'
|
||||
expect(validationImageUrl(path)).toBe(new URL(path, window.location.origin).href)
|
||||
expect(validationImageUrl('/api/private')).toBe('/api/private')
|
||||
})
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationPreview } from '../../fixtures/validation-preview'
|
||||
import { ApiError } from '@/lib/http'
|
||||
import { defineComponent, reactive, ref } from 'vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
@@ -37,6 +38,7 @@ afterEach(() => {
|
||||
|
||||
/** 模拟统一配置后的真实契约,测试绝不调用真实图片或视觉模型。 */
|
||||
function server() {
|
||||
const plan = structuredClone(validationPreview)
|
||||
const projectId = `quality-test-${sequence++}`
|
||||
const project = testProjectContext(projectId).project.value!
|
||||
const validation = {
|
||||
@@ -164,6 +166,7 @@ function server() {
|
||||
}
|
||||
else if (String(url).endsWith('/checkpoints?view=summary')) data = []
|
||||
else if (path.endsWith('/production/entry-readiness')) data = { ready: true }
|
||||
else if (path.endsWith('/validate/preview')) data = plan
|
||||
else if (path.endsWith('/validations')) data = []
|
||||
else if (path.endsWith('/quality-review'))
|
||||
data = {
|
||||
@@ -191,6 +194,7 @@ function server() {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
return {
|
||||
projectId,
|
||||
plan,
|
||||
project,
|
||||
validation,
|
||||
keyframe,
|
||||
@@ -461,8 +465,9 @@ describe('质量面板渐进展示', () => {
|
||||
})
|
||||
await flushPromises()
|
||||
expect(validationButton().disabled).toBe(true)
|
||||
expect(document.body.textContent).toContain('更多参数与模型限制')
|
||||
expect(document.querySelector('[aria-label="额外允许的画面文字"]')).not.toBeNull()
|
||||
expect(document.body.textContent).toContain('免费审核预检')
|
||||
expect(document.body.textContent).toContain('未知,需先核对费用范围')
|
||||
expect(document.querySelector('[aria-label="额外允许的画面文字"]')).toBeNull()
|
||||
expect(data.posts()).toHaveLength(0)
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
@@ -639,3 +644,47 @@ describe('视频修复候选与复检晋升', () => {
|
||||
expect(data.posts()).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('普通审核计划保护', () => {
|
||||
it.each(['blocked', 'reusable'] as const)('%s 不允许新审核且不自动收费', async status => {
|
||||
const data = server()
|
||||
data.plan.status = status
|
||||
if (status === 'reusable') data.plan.reusableResult = { passed: false, summary: '旧失败结论' }
|
||||
else data.plan.activeTasks = [{ status: 'running' }]
|
||||
wrapper = mount(QualityDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
projectId: data.projectId,
|
||||
target: { kind: 'keyframe', shotId: 'shot-1', assetId: 'keyframe-1', title: '计划保护' },
|
||||
open: true,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
expect(validationButton().disabled).toBe(true)
|
||||
expect(data.posts()).toHaveLength(0)
|
||||
expect(document.body.textContent).toContain(status === 'reusable' ? '历史审核:未通过' : '正在执行')
|
||||
})
|
||||
it('批准后计划变化撤销提交,刷新后等待重新确认', async () => {
|
||||
const data = server()
|
||||
wrapper = mount(QualityDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
projectId: data.projectId,
|
||||
target: { kind: 'keyframe', shotId: 'shot-1', assetId: 'keyframe-1', title: '计划保护' },
|
||||
open: true,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
data.plan.validationFingerprint = 'b'.repeat(64)
|
||||
validationButton().click()
|
||||
await flushPromises()
|
||||
expect(data.posts()).toHaveLength(0)
|
||||
expect(validationButton().disabled).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -276,3 +276,25 @@ it('抽屉使用真实表单,打开只读历史,免费预检逐项展示全
|
||||
wrapper.unmount()
|
||||
}
|
||||
})
|
||||
|
||||
/** 非阻断只依据服务端资格开放免费计划,未知观察和机器质量保持独立。 */
|
||||
it('当前非阻断来源可查看独立计划,服务端明确拒绝时关闭入口', async () => {
|
||||
const mock = sourceMock('non_blocking_unknown')
|
||||
Object.assign(mock.record, { validationEligible: true })
|
||||
mock.record.review.observations[0]!.finding.structure = 'unknown'
|
||||
vi.stubGlobal('fetch', mock.fetcher)
|
||||
const form = scope.run(() => useSourceReview(ref(JSON.stringify(['s', 'k', 'p']))))!
|
||||
await flushPromises()
|
||||
form.reviewId.value = 'r'
|
||||
await form.readRecord()
|
||||
await form.loadPlan()
|
||||
expect(form.plan.value?.reviewId).toBe('r')
|
||||
expect(form.record.value?.review.observations[0]!.finding.structure).toBe('unknown')
|
||||
expect(mock.calls.every(call => call.body === null)).toBe(true)
|
||||
form.plan.value = null
|
||||
Object.assign(form.record.value!, { validationEligible: false, reviewStatus: 'passed' })
|
||||
const before = mock.calls.length
|
||||
await form.loadPlan()
|
||||
expect(mock.calls.length).toBe(before)
|
||||
expect(form.plan.value).toBeNull()
|
||||
})
|
||||
@@ -194,3 +194,18 @@ describe('待审摄影草案的保存与回读', () => {
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it('视线修订只更新选中 gaze,原正式事实与机位不变', async () => {
|
||||
const { reviseSubjectGaze } = await import('@/features/storyboard/derived-review')
|
||||
const formal = draftFromFormal(shot, keyframe, 'a'.repeat(64))
|
||||
const revised = reviseSubjectGaze(formal, '@SC0001', '画面左侧', '人工确认视线意图')
|
||||
expect(revised.subjectStateRevision?.changes).toEqual([
|
||||
{ subjectRef: '@SC0001', field: 'gaze', before: '', after: '画面左侧' }
|
||||
])
|
||||
expect(formal.visualState.subjects[0]!.gaze).toBe('')
|
||||
expect(revised.direction).toEqual(formal.direction)
|
||||
expect({ ...revised.visualState.subjects[0], gaze: '' }).toEqual(formal.visualState.subjects[0])
|
||||
expect(() => reviseSubjectGaze(formal, '@CH9999', '左侧', '理由')).toThrow('请选择正式主体')
|
||||
expect(() => reviseSubjectGaze(formal, '@SC0001', '', '理由')).toThrow('请选择正式主体')
|
||||
expect(() => reviseSubjectGaze(revised, '@SC0001', '右侧', '理由')).toThrow('请从当前正式状态')
|
||||
})
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
import type { ValidationPreview } from '../../src/features/production/validation-preview'
|
||||
/** 普通免费审核计划的隔离样本,无真实 Provider。 */
|
||||
export const validationPreview: ValidationPreview = {
|
||||
status: 'ready',
|
||||
validationFingerprint: 'a'.repeat(64),
|
||||
model: '隔离审核模型',
|
||||
steps: ['general', 'physical'],
|
||||
actualImagesPerStep: 2,
|
||||
maximumProviderRequests: 2,
|
||||
historyCount: 0,
|
||||
activeTasks: [],
|
||||
unresolvedTasks: [],
|
||||
planConflict: false,
|
||||
image: {
|
||||
imageUrl: 'http://localhost:4312/tests/browser/candidate.svg',
|
||||
sha256: 'b'.repeat(64),
|
||||
width: 1024,
|
||||
height: 1024
|
||||
},
|
||||
references: [
|
||||
{
|
||||
imageNumber: 2,
|
||||
generationImageNumber: 1,
|
||||
imageUrl: 'http://localhost:4312/tests/browser/candidate.svg',
|
||||
sha256: 'c'.repeat(64),
|
||||
bindings: [{ subjectRef: '@CH1', role: 'identity-anchor' }]
|
||||
}
|
||||
],
|
||||
feeEstimate: { amount: null, currency: 'CNY', reason: '部署用量待估算' },
|
||||
reusableResult: null
|
||||
}
|
||||
Reference in new issue
Block a user