9470a127f7
build / build (push) Successful in 1m11s
统一AI分析入口及双任务安全确认,采用全量载入的可见行渲染,保留完整原文。 右侧非模态详情固定五项质量字段,清理冗余展示并对齐查询和同步按钮。 默认4并发由数据库准入与逐任务租约保护,保留共享限流冷却、截断归因和有界重试。 兼容真实引用标题字段,不伪造证据或准确率,不修改源生产问答与公司区域规则。 验证:完整make verify退出0,710项Go通过、124项已声明可选跳过且必需0跳过; 另全量mirror隔离PostgreSQL race退出0,AI单元race退出0。 真实本地浏览器通过六项交互、390px内滚动及显式AI部分失败/零缺口故障夹具。 治理原生备份已真实恢复,schema57、72表计数与29张QA内容哈希一致。 候选镜像、精确提交CI与正式上线验收待本次提交后执行,不宣称已部署。
124 lines
3.8 KiB
TypeScript
124 lines
3.8 KiB
TypeScript
import { it, expect } from 'vitest'
|
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
import { QAAIWorkbench, QAAIEvidenceView } from './QAAI'
|
|
import type { AIStatus, AIEvidence } from './qaAITypes'
|
|
const status: AIStatus = {
|
|
settings: {
|
|
revision: 1,
|
|
base_url: 'https://model.example.invalid/v1',
|
|
model: 'fixture',
|
|
key_configured: true,
|
|
verification: 'verified',
|
|
checked_at: null,
|
|
automatic_evaluation: true,
|
|
automatic_translation: false,
|
|
storage_ready: true,
|
|
},
|
|
worker_ready: true,
|
|
queues: [{ kind: 'evaluation', queued: 2, running: 1, retry: 0, failed: 1, paused: 0, succeeded: 2, skipped: 0 }],
|
|
batches: [],
|
|
recent_tasks: [],
|
|
recent_tasks_limited: false,
|
|
}
|
|
it('shows open-ended automatic queue counts without fabricating a percentage', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QAAIWorkbench
|
|
initial={status}
|
|
query={{ start: '2026-10-05T00:00:00Z', end: '2026-10-12T00:00:00Z', keyword: 'executed-query', cursor: '' }}
|
|
/>
|
|
)
|
|
for (const value of ['AI分析', '当前已执行筛选', '后台任务', '排队 2', '执行 1', '失败 1'])
|
|
expect(html).toContain(value)
|
|
expect(html).not.toContain('100%')
|
|
})
|
|
it('exposes persistent pause, resume and failed-only retry without claiming completion is success', () => {
|
|
const batches: AIStatus['batches'] = [
|
|
{
|
|
id: 'active-batch',
|
|
kind: 'evaluation',
|
|
state: 'active',
|
|
total: 2,
|
|
succeeded: 0,
|
|
failed: 1,
|
|
skipped: 0,
|
|
running: 0,
|
|
queued: 1,
|
|
retry: 0,
|
|
paused: 0,
|
|
created_at: '2026-10-19T00:00:00Z',
|
|
},
|
|
{
|
|
id: 'paused-batch',
|
|
kind: 'translation',
|
|
state: 'paused',
|
|
total: 1,
|
|
succeeded: 0,
|
|
failed: 0,
|
|
skipped: 0,
|
|
running: 0,
|
|
queued: 0,
|
|
retry: 0,
|
|
paused: 1,
|
|
created_at: '2026-10-19T00:00:00Z',
|
|
},
|
|
]
|
|
const html = renderToStaticMarkup(<QAAIWorkbench initial={{ ...status, batches }} query={null} />)
|
|
for (const value of ['暂停批次', '恢复批次', '重试失败项', '已结束不代表全部成功', '已发出的请求完成后暂停后续请求'])
|
|
expect(html).toContain(value)
|
|
})
|
|
it('renders original evidence quotes, actual model/version and applied-versus-skipped provenance', () => {
|
|
const evidence: AIEvidence = {
|
|
id: 'w',
|
|
record_id: 'r',
|
|
kind: 'evaluation',
|
|
state: 'succeeded',
|
|
stage: 'completed',
|
|
attempt: 1,
|
|
error_code: '',
|
|
skip_reason: '',
|
|
started_at: '2026-10-19T00:00:00Z',
|
|
updated_at: '2026-10-19T00:00:01Z',
|
|
input_hash: 'a'.repeat(64),
|
|
config_revision: 1,
|
|
prompt_version: 'prompt-fixture-v1',
|
|
dictionary_version: 'dict-fixture-v1',
|
|
actual_model: 'actual-fixture-model',
|
|
result: {
|
|
fields: {
|
|
product_category: {
|
|
value: 'MG400',
|
|
basis: 'semantic_only',
|
|
reason: '原问题明确包含型号',
|
|
quotes: [{ source: 'question', text: 'MG400 怎么连接?', reference_index: 0 }],
|
|
},
|
|
},
|
|
},
|
|
applied_fields: { product_category: 'MG400' },
|
|
skipped_fields: {},
|
|
}
|
|
const html = renderToStaticMarkup(<QAAIEvidenceView evidence={[evidence]} />)
|
|
for (const value of [
|
|
'字段结论与依据',
|
|
'原问题明确包含型号',
|
|
'MG400 怎么连接?',
|
|
'仅语义判断',
|
|
'actual-fixture-model',
|
|
'prompt-fixture-v1',
|
|
'dict-fixture-v1',
|
|
'已回填',
|
|
])
|
|
expect(html).toContain(value)
|
|
})
|
|
|
|
it('uses one AI分析 entry for combined evaluation and Chinese translation', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QAAIWorkbench
|
|
initial={status}
|
|
query={{ start: '2026-10-05T00:00:00Z', end: '2026-10-12T00:00:00Z', keyword: '', cursor: '' }}
|
|
/>
|
|
)
|
|
expect([...html.matchAll(/>AI分析<\/button>/g)]).toHaveLength(1)
|
|
expect(html).not.toContain('补缺评估')
|
|
expect(html).not.toContain('补缺中文翻译')
|
|
})
|