feat(qaops): 接入独立只读问答查询与治理覆盖复检
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { QAOperationsView } from './QAOperations'
|
||||
import type { QARecord, QARecordPage } from './qaOps'
|
||||
import { restoreWorkspace } from './workspace'
|
||||
|
||||
const item: QARecord = {
|
||||
id: 'fixture',
|
||||
status: 'succeeded',
|
||||
question: '<script>not executable</script>',
|
||||
answer: '当前暂无已发布的权威知识。',
|
||||
asked_at: '2026-10-14T03:00:00Z',
|
||||
time_source: 'request_message.created_at',
|
||||
asker: '测试人员',
|
||||
trigger_person: '测试昵称',
|
||||
department: '',
|
||||
region: '',
|
||||
references: [{ title: '测试引用' }],
|
||||
media: [],
|
||||
feedback: { asker_value: 'down', up: 0, down: 1 },
|
||||
source_coverage: { verdict: 'covered', reason_code: 'covered_has_references', evaluator_version: 'v5' },
|
||||
coverage: {
|
||||
verdict: 'uncovered',
|
||||
state: 'checked',
|
||||
rule_version: 'governance-answer-substring-v1',
|
||||
matched_text: '暂无已发布',
|
||||
},
|
||||
is_correct: false,
|
||||
}
|
||||
const page: QARecordPage = {
|
||||
items: [item],
|
||||
columns: ['answer', 'coverage', 'is_correct', 'asked_at', 'asker', 'question', 'feedback'],
|
||||
total: 1,
|
||||
has_more: false,
|
||||
next_cursor: '',
|
||||
as_of: '2026-10-14T04:00:00Z',
|
||||
}
|
||||
const props = {
|
||||
page,
|
||||
status: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
detail: null,
|
||||
detailLoading: false,
|
||||
detailError: null,
|
||||
onSelect: vi.fn(),
|
||||
onCloseDetail: vi.fn(),
|
||||
onLoadMore: vi.fn(),
|
||||
onRetry: vi.fn(),
|
||||
}
|
||||
|
||||
describe('QA operations workbench', () => {
|
||||
it('shows populated columns in required order and keeps false/downvotes visible', () => {
|
||||
const html = renderToStaticMarkup(<QAOperationsView {...props} />)
|
||||
expect(html).toContain('原始问题')
|
||||
expect(html.indexOf('AI答案')).toBeLessThan(html.indexOf('是否覆盖'))
|
||||
expect(html.indexOf('是否正确')).toBeLessThan(html.indexOf('提问时间'))
|
||||
expect(html).toContain('否(点踩)')
|
||||
expect(html).toContain('是否正确')
|
||||
expect(html).not.toContain('<th>部门</th>')
|
||||
expect(html).not.toContain('<th>产品分类</th>')
|
||||
expect(html).not.toContain('<script>not executable</script>')
|
||||
})
|
||||
it('distinguishes an unavailable source from a successful empty query', () => {
|
||||
const html = renderToStaticMarkup(<QAOperationsView {...props} page={null} error="只读源不可用" />)
|
||||
expect(html).toContain('role="alert"')
|
||||
expect(html).toContain('只读源不可用')
|
||||
expect(html).not.toContain('没有符合条件的问答')
|
||||
})
|
||||
it('shows complete source and governance evidence separately in the detail drawer', () => {
|
||||
const html = renderToStaticMarkup(<QAOperationsView {...props} detail={item} />)
|
||||
expect(html).toContain('role="dialog"')
|
||||
expect(html).toContain('暂无已发布')
|
||||
expect(html).toContain('源端覆盖(仅对照)')
|
||||
expect(html).toContain('covered_has_references')
|
||||
expect(html).toContain('测试引用')
|
||||
})
|
||||
it('restores the existing singleton workspace tab without creating another application', () => {
|
||||
const restored = restoreWorkspace(JSON.stringify({ openTabs: ['dashboard', 'qaops'], activeTab: 'qaops' }))
|
||||
expect(restored.openTabs).toEqual(['dashboard', 'qaops'])
|
||||
expect(restored.activeTab).toBe('qaops')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user