- git mv 保留历史:ui/(Vue3+Vite)、sdk/(BFF 中间层)
- 路径语义修正:db_path/figures_cache 改相对 sdk/(BFF cwd),
历史库 sdk/backend/data 迁移至 sdk/data/(会话/图片缓存无损)
- 引用修复 ~15 处:config.py、deploy/*.sh、vitest/playwright 配置、
单测导入路径、docs、README、gitignore、.env.example
- 骨架:agent/{qa,methodology,legacy-rag,vendor}、knowledge/manifest.yaml、
tooling/{compile,kb,crypto,assemble,audit,tools,scripts} + README
- 门禁验证:sdk pytest 125 通过、ui vitest 158 通过、
生产 BFF 脚本重启四上游全绿 + 静态托管 + 会话库无损
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
100 lines
3.7 KiB
JavaScript
100 lines
3.7 KiB
JavaScript
// retrieval.pane.test.js —— B3 单测:RetrievalPane(相位筛选、空态)
|
||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||
import { createPinia, setActivePinia, getActivePinia } from 'pinia';
|
||
import { useBenchStore, normalizeStageEvent } from '../../../../ui/src/stores/bench.js';
|
||
import { STAGE_PHASE } from '../../../../ui/src/i18n/labels.js';
|
||
|
||
vi.mock('../../../../ui/src/api/extraction.js', () => ({
|
||
listJobs: vi.fn(),
|
||
getJob: vi.fn(),
|
||
uploadPaper: vi.fn(),
|
||
getRunLog: vi.fn(),
|
||
getProcessingStatus: vi.fn(),
|
||
getSummary: vi.fn(),
|
||
}));
|
||
|
||
const frames = [
|
||
{ stage: 'understanding_started', label: '开始理解问题', details: {} },
|
||
{ stage: 'entities_identified', label: '已识别实体', details: { entities: ['SPL', 'OsSPL14'] } },
|
||
{ stage: 'concepts_found', label: '发现相关概念', details: { concept_count: 3 } },
|
||
{ stage: 'evidence_review_completed', label: '证据审核完成', details: { accepted_count: 4 } },
|
||
{ stage: 'completed', label: '检索完成', details: {} },
|
||
];
|
||
|
||
describe('RetrievalPane 相位筛选(FR-RETRIEVAL-002)', () => {
|
||
let store;
|
||
|
||
beforeEach(() => {
|
||
setActivePinia(createPinia());
|
||
store = useBenchStore();
|
||
for (const f of frames) {
|
||
const phase = STAGE_PHASE[f.stage] || 'retrieval';
|
||
store.recordStageEvent({ ...f, phase, at: '2026-08-25T09:41:00Z' });
|
||
}
|
||
});
|
||
|
||
it('阶段卡数量与 progress 事件数一致(FR-RETRIEVAL-001)', () => {
|
||
expect(store.stageEvents).toHaveLength(frames.length);
|
||
});
|
||
|
||
it('全部:显示全部卡片', () => {
|
||
expect(store.filteredStageEvents).toHaveLength(5);
|
||
});
|
||
|
||
it('筛选 planning:仅 2 张', () => {
|
||
store.setPhaseFilter('planning');
|
||
const out = store.filteredStageEvents;
|
||
expect(out).toHaveLength(2);
|
||
expect(out.every((e) => e.phase === 'planning')).toBe(true);
|
||
});
|
||
|
||
it('筛选 retrieval / evidence / generation:各归其位', () => {
|
||
store.setPhaseFilter('retrieval');
|
||
expect(store.filteredStageEvents).toHaveLength(1);
|
||
expect(store.filteredStageEvents[0].stage).toBe('concepts_found');
|
||
|
||
store.setPhaseFilter('evidence');
|
||
expect(store.filteredStageEvents).toHaveLength(1);
|
||
expect(store.filteredStageEvents[0].stage).toBe('evidence_review_completed');
|
||
});
|
||
|
||
it('筛选后无匹配 → 空列表(不渲染假卡片)', () => {
|
||
store.setPhaseFilter('generation');
|
||
expect(store.filteredStageEvents).toHaveLength(0);
|
||
});
|
||
|
||
it('未知 stage 兜底 phase=retrieval(API.md §4 规则)', () => {
|
||
const n = normalizeStageEvent({ stage: 'mystery_stage', label: 'mystery_stage' });
|
||
expect(n.phase).toBe('retrieval');
|
||
});
|
||
});
|
||
|
||
describe('RetrievalPane 空态(FR-RETRIEVAL-006)', () => {
|
||
it('未提问时无阶段卡(不显示假卡片)', () => {
|
||
setActivePinia(createPinia());
|
||
const store = useBenchStore();
|
||
expect(store.stageEvents).toHaveLength(0);
|
||
expect(store.filteredStageEvents).toHaveLength(0);
|
||
});
|
||
|
||
it('B2 chat store 暴露事件时优先采用其数据源', () => {
|
||
setActivePinia(createPinia());
|
||
const store = useBenchStore();
|
||
const chatStore = {
|
||
currentEvents: [
|
||
{ stage: 'entities_identified', phase: 'planning', label: '已识别实体', details: {}, at: '2026-08-25T09:41:01Z' },
|
||
],
|
||
};
|
||
getActivePinia()._s.set('chat', chatStore);
|
||
expect(store.stageEvents).toHaveLength(1);
|
||
expect(store.stageEvents[0].label).toBe('已识别实体');
|
||
});
|
||
|
||
it('B2 未就绪时回退本地队列', () => {
|
||
setActivePinia(createPinia());
|
||
const store = useBenchStore();
|
||
store.recordStageEvent({ stage: 'concepts_found', phase: 'retrieval', label: '发现相关概念', details: {}, at: '2026-08-25T09:41:02Z' });
|
||
expect(store.stageEvents).toHaveLength(1);
|
||
});
|
||
});
|