feat(short-drama-agent-front): 接入首帧授权与连续性审核
This commit is contained in:
1 parent
dbf97e6f98
commit
518b630a46
35 files changed
+3070
-97
No files matched your search
@@ -0,0 +1,113 @@
|
||||
import { defineComponent, ref } from 'vue'
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { NInput, NCheckbox } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import KeyframeValidationHistory from '@/features/production/components/KeyframeValidationHistory.vue'
|
||||
import KeyframeExecutionStatus from '@/features/production/components/KeyframeExecutionStatus.vue'
|
||||
import type { WorkflowExecution } from '@/features/workflows/execution.types'
|
||||
|
||||
/** 隔离当前弹窗与会话,所有 HTTP 均由 Mock 接收。 */
|
||||
let wrapper: VueWrapper
|
||||
/** 复用实际历史组件公开的底栏操作,不绕过提交守卫。 */
|
||||
const HistoryHarness = defineComponent({
|
||||
components: { KeyframeValidationHistory, NCheckbox },
|
||||
setup() {
|
||||
const history = ref<InstanceType<typeof KeyframeValidationHistory> | null>(null)
|
||||
return { history }
|
||||
},
|
||||
template:
|
||||
'<KeyframeValidationHistory ref="history" project-id="auth-ui" shot-id="s" keyframe-id="k" initial-open/><NCheckbox v-if="history?.authorizationAvailable" :checked="history.authorizationAcknowledged" @update:checked="history.setAuthorizationAcknowledged($event)"/><button v-if="history?.authorizationAvailable" :disabled="!history.authorizationReady" @click="history.submitAuthorization()">授权提交</button>'
|
||||
})
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('独立授权底栏与当前审核结论', () => {
|
||||
it('人工终止保留原状态和费用,显式填写、勾选后仅提交一个授权字段,409 刷新历史', async () => {
|
||||
let reads = 0
|
||||
const fetcher = vi.fn<typeof fetch>(async (input, init) => {
|
||||
const path = String(input)
|
||||
if (init?.method === 'POST')
|
||||
return new Response(
|
||||
JSON.stringify({ message: '授权无效', code: 'KEYFRAME_VALIDATION_AUTHORIZATION_INVALID' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
if (path.includes('/validations')) {
|
||||
reads++
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: [
|
||||
{
|
||||
id: 'terminated-task',
|
||||
status: 'running',
|
||||
output: null,
|
||||
error: null,
|
||||
createdAt: '2026-11-07',
|
||||
legacyTermination: {
|
||||
auditId: 'audit',
|
||||
terminatedAt: '2026-11-07',
|
||||
billingFinding: 'unresolved',
|
||||
requiresNewAuthorization: true
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
validationTaskId: 'terminated-task',
|
||||
qualityDecision: 'passed',
|
||||
effectiveQualityStatus: 'passed',
|
||||
manualReviewAvailable: true,
|
||||
historicalGazePreview: []
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(HistoryHarness)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('原任务状态:执行中')
|
||||
expect(wrapper.text()).toContain('费用结论:待核查')
|
||||
expect(wrapper.text()).toContain('已终止,无有效结论')
|
||||
expect(wrapper.text()).not.toContain('人工接受')
|
||||
expect(wrapper.find('button:last-child').attributes('disabled')).toBeDefined()
|
||||
wrapper.findComponent(NInput).vm.$emit('update:value', 'independent-grant')
|
||||
await flushPromises()
|
||||
wrapper.findComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await wrapper.find('button:last-child').trigger('click')
|
||||
await flushPromises()
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts).toHaveLength(1)
|
||||
expect(JSON.parse(String(posts[0]![1]?.body))).toEqual({ legacyVisionAuthorizationId: 'independent-grant' })
|
||||
expect(reads).toBeGreaterThan(1)
|
||||
expect(wrapper.find('button:last-child').attributes('disabled')).toBeDefined()
|
||||
})
|
||||
it('执行完成但质量未通过使用中性状态,缺少质量结论不报通过', () => {
|
||||
const record = {
|
||||
id: 'run',
|
||||
projectId: 'p',
|
||||
workflowName: 'shot-keyframe-validation',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
current: 2,
|
||||
total: 2,
|
||||
updatedAt: '2026-11-07',
|
||||
currentResourceId: null,
|
||||
metadata: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: '2026-11-07',
|
||||
createdAt: '2026-11-07',
|
||||
result: { passed: false, qualityDecision: 'failed' }
|
||||
} as WorkflowExecution
|
||||
wrapper = mount(KeyframeExecutionStatus, { props: { execution: record, loading: false } })
|
||||
expect(wrapper.text()).toContain('执行完成,质量未通过')
|
||||
expect(wrapper.classes().join(' ')).not.toContain('success')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user