- 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>
75 lines
2.9 KiB
JavaScript
75 lines
2.9 KiB
JavaScript
// benchpanel.test.js —— B3 单测:BenchPanel 四 tab 切换与 ExtractionPane 轮询联动
|
||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||
import { mount } from '@vue/test-utils';
|
||
import { createPinia, setActivePinia } from 'pinia';
|
||
import { useBenchStore } from '../../../../ui/src/stores/bench.js';
|
||
import BenchPanel from '../../../../ui/src/components/bench/BenchPanel.vue';
|
||
|
||
vi.mock('../../../../ui/src/api/extraction.js', () => ({
|
||
listJobs: vi.fn().mockResolvedValue({ jobs: [], count: 0 }),
|
||
getJob: vi.fn(),
|
||
uploadPaper: vi.fn(),
|
||
getRunLog: vi.fn().mockResolvedValue({ text: '' }),
|
||
getProcessingStatus: vi.fn(),
|
||
getSummary: vi.fn(),
|
||
}));
|
||
vi.mock('../../../../ui/src/api/kg.js', () => ({
|
||
kgStatus: vi.fn().mockResolvedValue({ ok: true }),
|
||
kgOverview: vi.fn(),
|
||
searchEntities: vi.fn(),
|
||
getEntity: vi.fn(),
|
||
getNeighborhood: vi.fn(),
|
||
}));
|
||
|
||
describe('BenchPanel(FR-RETRIEVAL/SOURCE/EXTRACT/KG 入口)', () => {
|
||
let store;
|
||
let pinia;
|
||
|
||
beforeEach(() => {
|
||
pinia = createPinia();
|
||
setActivePinia(pinia);
|
||
store = useBenchStore();
|
||
});
|
||
|
||
it('四 tab 来自 labels.BENCH_TABS,默认激活检索过程', () => {
|
||
const wrapper = mount(BenchPanel, { global: { plugins: [pinia] } });
|
||
const tabs = wrapper.findAll('.bench-tab');
|
||
expect(tabs).toHaveLength(4);
|
||
expect(tabs.map((t) => t.text())).toEqual(['检索过程', '文献来源', '提取任务', '知识图谱']);
|
||
expect(wrapper.find('.bench-tab.on').text()).toBe('检索过程');
|
||
});
|
||
|
||
it('点击 tab 切换 pane,激活 tab 有渐变下划线(on 类)', async () => {
|
||
const wrapper = mount(BenchPanel, { global: { plugins: [pinia] } });
|
||
const tabs = wrapper.findAll('.bench-tab');
|
||
await tabs[2].trigger('click');
|
||
expect(wrapper.find('.bench-tab.on').text()).toBe('提取任务');
|
||
expect(wrapper.findComponent({ name: 'ExtractionPane' }).exists()).toBe(true);
|
||
await tabs[3].trigger('click');
|
||
expect(wrapper.findComponent({ name: 'KgPane' }).exists()).toBe(true);
|
||
});
|
||
|
||
it('Tab 切走 extract 时暂停轮询(FR-EXTRACT-005)', async () => {
|
||
const wrapper = mount(BenchPanel, { global: { plugins: [pinia] } });
|
||
const tabs = wrapper.findAll('.bench-tab');
|
||
await tabs[2].trigger('click'); // extract
|
||
store.pollPaused = false;
|
||
await tabs[0].trigger('click'); // retrieval
|
||
expect(store.pollPaused).toBe(true);
|
||
expect(store.isPolling()).toBe(false);
|
||
});
|
||
|
||
it('折叠状态经 props/emit 同步(FR-SHELL-005 手柄由 B1 对接)', async () => {
|
||
const wrapper = mount(BenchPanel, {
|
||
props: { collapsed: false },
|
||
global: { plugins: [pinia] },
|
||
});
|
||
const handle = wrapper.find('.bench-handle-btn');
|
||
expect(handle.exists()).toBe(true);
|
||
await handle.trigger('click');
|
||
expect(wrapper.emitted('collapse')).toBeTruthy();
|
||
expect(wrapper.emitted('collapse')[0]).toEqual([true]);
|
||
expect(wrapper.classes()).toContain('collapsed-local');
|
||
});
|
||
});
|