- BFF 薄适配层(FastAPI,8090):QA 代理/SSE 中继/Neo4j 直连/抽取代理/会话持久化 - Vue3 前端:五相位检索流水线、文献来源与证据链、知识图谱、提取任务四 tab - 四档响应式(桌面/笔记本/平板/手机)、深浅主题 - 81 个 FR 全部实现,测试追溯矩阵 81/81,后端 121 测/前端 156 测 - 真实凭据已脱敏,运行时配置在 backend/.env(不入 git) 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 '../../../../frontend/src/stores/bench.js';
|
||
import BenchPanel from '../../../../frontend/src/components/bench/BenchPanel.vue';
|
||
|
||
vi.mock('../../../../frontend/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('../../../../frontend/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');
|
||
});
|
||
});
|