Files
lpt-fe/src/__tests__/support/recall.ts
T
cat-shark 354aceb380 feat: 回忆打开即编辑,总览新增相关导图
- 打开历史回忆直接进入编辑,新建永远空白;去掉草稿/已结束状态展示
- 复习总览按所选标签列出保存导图,可翻页;最近回忆支持排除顶部那条
- 提示形式改为点击后先选形式再发请求;资料无内容时禁用提示与查漏
- 空范围记录不进入编辑器,页面路由补统一返回入口
2026-11-22 21:41:31 +08:00

30 lines
2.9 KiB
TypeScript

import type { Expression, RecallAiResult, RecallDetail, RecallRequest, ReferencePage, ReferenceContent, ScopeInput } from '@/api/recalls';
export const ok = <T>(data: T) => ({ code: 200, message: '请求成功', data });
export const copy = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
export const taskScope: ScopeInput = { type: 'TASK', taskNum: 'T001', tags: [], combineMode: null };
export const tagScope: ScopeInput = { type: 'TAG', taskNum: null, tags: ['中文'], combineMode: 'UNION' };
export const expressionFixture = (): Expression => ({ schemaVersion: 1, root: { id: 'root-a', title: '', notes: '', provenance: [], children: [] } });
export function recallFixture(): RecallDetail {
return {
recallNum: 'R001', scope: { ...tagScope, normalizedTags: ['中文'], scopeKey: 'TAG:中文', displayName: '学习Vue', selectedAt: '2026-11-14T01:00:00Z' },
scopeStatus: 'VALID', activeDurationMs: 0, actualDurationMs: 0, createdAt: '2026-11-14T01:00:00Z', updatedAt: '2026-11-14T01:00:00Z',
editorId: null, writeToken: 'write-a', expression: expressionFixture(), requests: [],
reference: { status: 'AVAILABLE', total: 1, limitations: ['相关学习报告只作补充上下文,需结合本次选中的知识碎片核对。', '资料可能有遗漏或相互冲突,不作为标准答案。'] },
};
}
export const referenceContentFixture = (): ReferenceContent => ({ sourceId: 'fragment:7', title: '原始笔记', content: '中文😀知识', role: 'PRIMARY', status: 'AVAILABLE' });
export const referencePageFixture = (): ReferencePage => ({ current: 1, size: 10, total: 1,
records: [{ sourceId: 'fragment:7', title: '原始笔记', preview: '中文😀', role: 'PRIMARY', status: 'AVAILABLE' }] });
export function resultFixture(kind: 'HINT' | 'CHECK' = 'CHECK'): RecallAiResult {
const citation = { unitId: 'fragment:7:0', start: 0, end: 4, quote: '中文😀' };
return { schemaVersion: 1, kind, model: 'controlled-stub', analysisStatus: 'PARTIAL',
assessments: [{ unitId: 'fragment:7:0', status: 'ANALYZED', reason: '本次核对', exclusion: null, citations: [citation] }],
hints: kind === 'HINT' ? [{ id: 'hint-1', form: 'KEYWORD', clue: '启动线索', anchorNodeId: null, nodes: [], citations: [citation] }] : [],
findings: kind === 'CHECK' ? [{ id: 'finding-1', category: 'POSSIBLY_MISSING', clue: '想想适用条件', explanation: '条件需要核对', citations: [citation], expressionEvidence: [] }] : [], limitations: ['本次仅分析部分资料'] };
}
export function requestFixture(kind: 'HINT' | 'CHECK' = 'CHECK'): RecallRequest {
return { requestId: 'req-1', taskNum: 'AI001', type: kind === 'HINT' ? 'RECALL_HINT' : 'RECALL_CHECK',
hintForm: kind === 'HINT' ? 'KEYWORD' : null, promptVersion: 'recall-v1', status: 'SUCCEEDED', errorCode: null, errorMessage: null,
submittedAt: '2026-11-14T01:00:00Z', finishedAt: '2026-11-14T01:00:01Z', result: resultFixture(kind) };
}