feat(short-drama-agent-front): 接入关系修复并优化配置与弹窗
This commit is contained in:
1 parent
2db8549818
commit
41d1cfe3ed
15 files changed
+1134
-323
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi, afterEach } from 'vitest'
|
||||
import { candidateCommitIssue } from '@/features/breakdown/candidate'
|
||||
import { candidateCommitIssue, candidatePreviewReady } from '@/features/breakdown/candidate'
|
||||
import { commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
import type { BreakdownState } from '@/features/breakdown/types'
|
||||
|
||||
@@ -50,6 +51,37 @@ function readyCandidate(): BreakdownState {
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('候选提交资格', () => {
|
||||
it('关系来源检查缺失或失败时,即使 ready=true 也不能确认提交', () => {
|
||||
const preview = commitPreview()
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(true)
|
||||
delete (preview.checks as Partial<typeof preview.checks>).relationEvidenceValid
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
|
||||
preview.checks.relationEvidenceValid = false
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
|
||||
})
|
||||
|
||||
it('关系修复只发送最新版本和所选关系原始定位,不扩展成主体删除', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: {} })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await breakdownApi.repairCandidateRelation('p/id', {
|
||||
confirmed: true,
|
||||
expectedCheckpointId: 'cp-latest',
|
||||
subjectRef: '@SC0002',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据,保留空格 '
|
||||
})
|
||||
expect(fetcher.mock.calls[0]![0]).toBe('/api/projects/p%2Fid/breakdown/candidate-relation-repair')
|
||||
expect(fetcher.mock.calls[0]![1]?.method).toBe('POST')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]?.body as string)).toEqual({
|
||||
confirmed: true,
|
||||
expectedCheckpointId: 'cp-latest',
|
||||
subjectRef: '@SC0002',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据,保留空格 '
|
||||
})
|
||||
})
|
||||
it('只允许完整、未提交、审核通过的候选快照进入确认', () => {
|
||||
expect(candidateCommitIssue(readyCandidate())).toBe('')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), candidateOnly: false })).toContain('候选')
|
||||
|
||||
Reference in new issue
Block a user