87f97a2f9b
build / build (push) Successful in 1m7s
详情使用共享主表字典,稀疏修改所选字段并保留原始问答及旧复核审计。 月周统计提供文本和下拉双入口;每租户每周一份持久草稿,按技能六节双语模板真实预填。 加入幂等自动保存、冲突保留、未知响应重试、切周及离开保护和schema58非破坏降级保护。 验证:完整make verify、隔离PostgreSQL全mirror竞态回归、真实恢复库浏览器验收通过。 浏览器实测字段精确读回、月周双输入、模板预填、MD/CSV、自动保存、冲突、失败重试与API重启恢复。 未连接或改写DobotAI生产源库,未运行付费模型;提交时尚未部署。
232 lines
9.6 KiB
TypeScript
232 lines
9.6 KiB
TypeScript
// @ts-expect-error The test runner provides Node; the browser bundle intentionally omits @types/node.
|
|
import { readFileSync } from 'node:fs'
|
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { QAOperationsTabs, 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('edits five fields directly in the first row without a separate review or feedback form', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QAOperationsView {...props} detail={{ ...item, record_origin: 'historical_excel' }} />
|
|
)
|
|
const drawer = html.slice(html.indexOf('<aside'))
|
|
expect((drawer.match(/<select/g) ?? []).length).toBe(5)
|
|
for (const copy of ['人工复核与留档', '保存复核', '复核理由', '用户反馈', '质量留档/人工复核未配置'])
|
|
expect(drawer).not.toContain(copy)
|
|
})
|
|
it('shows each persisted AI task in the existing operation cell and explains positive master coverage', () => {
|
|
const withTasks = {
|
|
...item,
|
|
background_tasks: [
|
|
{
|
|
id: 'w',
|
|
record_id: item.id,
|
|
kind: 'evaluation' as const,
|
|
state: 'running' as const,
|
|
stage: 'request',
|
|
attempt: 1,
|
|
error_code: '',
|
|
skip_reason: '',
|
|
started_at: '2026-10-19T00:00:00Z',
|
|
updated_at: '2026-10-19T00:00:01Z',
|
|
},
|
|
],
|
|
}
|
|
const detail = {
|
|
...item,
|
|
record_origin: 'dobotai_2_0' as const,
|
|
coverage: { state: 'checked' as const, verdict: 'covered' as const, rule_version: 'master-answer-substring-v2' },
|
|
}
|
|
const html = renderToStaticMarkup(
|
|
<QAOperationsView {...props} page={{ ...page, items: [withTasks] }} detail={detail} />
|
|
)
|
|
expect(html).toContain('字段分析:执行中')
|
|
expect(html).toContain('已覆盖:成功读取且非空答案未包含')
|
|
expect(html).toContain('字段结论与依据')
|
|
})
|
|
|
|
it('hides only the two requested advisory warnings, not real errors', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QAOperationsView
|
|
{...props}
|
|
status={{
|
|
state: 'connected',
|
|
code: '',
|
|
warnings: ['database_temp_enabled', 'database_transport_unencrypted', 'fixture_other_warning'],
|
|
read_only: true,
|
|
source_version: '2.0',
|
|
channel: 'dingtalk',
|
|
}}
|
|
error="fixture real read failure"
|
|
/>
|
|
)
|
|
expect(html).not.toContain('数据库仍允许临时对象')
|
|
expect(html).not.toContain('数据库连接未启用 TLS')
|
|
expect(html).toContain('数据源有待审核的安全告警')
|
|
expect(html).toContain('fixture real read failure')
|
|
})
|
|
it('removes workflow personnel from details while preserving the record data', () => {
|
|
const detail = { ...item, trigger_person: JSON.stringify({ name: '示例姓名', unionId: 'fixture-union' }) }
|
|
const html = renderToStaticMarkup(<QAOperationsView {...props} detail={detail} />)
|
|
const drawer = html.slice(html.indexOf('<aside'))
|
|
expect(drawer).not.toContain('示例姓名')
|
|
expect(drawer).not.toContain('原始人员信息')
|
|
expect(drawer).not.toContain('fixture-union')
|
|
})
|
|
it('provides a row-level detail target and categorical color tags without adding business columns', () => {
|
|
const html = renderToStaticMarkup(<QAOperationsView {...props} />)
|
|
expect(html).toContain('data-qa-row="fixture"')
|
|
expect(html).toContain('双击行查看详情')
|
|
expect(html).toContain('qa-field-tag')
|
|
})
|
|
|
|
it('uses the four requested destinations in their fixed order', () => {
|
|
const html = renderToStaticMarkup(<QAOperationsTabs view="records" onChange={vi.fn()} />)
|
|
const labels = ['问题流水', '问题统计看板', '区域统计', '周报生成']
|
|
for (const label of labels) expect(html).toContain(label)
|
|
for (let i = 1; i < labels.length; i++) expect(html.indexOf(labels[i - 1])).toBeLessThan(html.indexOf(labels[i]))
|
|
expect(html).not.toContain('部门/区域保留源快照')
|
|
})
|
|
it('removes explanatory banners without hiding errors or any required column', () => {
|
|
const html = renderToStaticMarkup(<QAOperationsView {...props} />)
|
|
expect(html).not.toContain('本次读取')
|
|
expect(html).not.toContain('固定显示完整字段')
|
|
expect(html).not.toContain('DobotAI 2.0 / 钉钉')
|
|
})
|
|
it('shows all required columns even when empty 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).toContain('<th>部门</th>')
|
|
expect([...html.matchAll(/<th>(.*?)<\/th>/g)].slice(0, 14).map((match) => match[1])).toEqual([
|
|
'中文问题',
|
|
'AI答案',
|
|
'是否覆盖',
|
|
'是否正确',
|
|
'产品分类',
|
|
'问题类型',
|
|
'根因分析',
|
|
'提问时间',
|
|
'提问人',
|
|
'原始问题',
|
|
'语言',
|
|
'流程触发人员信息',
|
|
'部门',
|
|
'区域',
|
|
])
|
|
expect(html).toContain('<th>产品分类</th>')
|
|
expect(html).not.toContain('<script>not executable</script>')
|
|
})
|
|
it('never shows a load-more control for the all-records table', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QAOperationsView {...props} page={{ ...page, total: 2, has_more: true, next_cursor: 'next' }} />
|
|
)
|
|
expect(html).not.toContain('加载更多')
|
|
expect(html).not.toContain('空列按整个筛选结果隐藏')
|
|
})
|
|
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')
|
|
})
|
|
})
|
|
|
|
it('opens a modeless right drawer with fixed leading quality fields and no redundant organization/personnel details', () => {
|
|
const html = renderToStaticMarkup(<QAOperationsView {...props} detail={{ ...item, record_origin: 'dobotai_2_0' }} />)
|
|
const drawer = html.slice(html.indexOf('<aside'))
|
|
expect(html).not.toContain('qa-ops-backdrop')
|
|
expect(drawer).toContain('aria-modal="false"')
|
|
expect(drawer).toContain('qa-detail-quality')
|
|
const labels = ['是否覆盖', '是否正确', '产品分类', '问题类型', '根因分析']
|
|
for (const label of labels) expect(drawer).toContain(label)
|
|
expect(drawer.indexOf('根因分析')).toBeLessThan(drawer.indexOf('原始问题'))
|
|
for (const label of [
|
|
'<dt>区域</dt>',
|
|
'当前组织关联',
|
|
'当前通讯录部门/区域',
|
|
'组织版本',
|
|
'源端组织快照',
|
|
'记录来源',
|
|
'问答状态',
|
|
'流程触发人员信息',
|
|
'原始人员信息',
|
|
])
|
|
expect(drawer).not.toContain(label)
|
|
})
|
|
|
|
it('names the ledger explicitly as 问题流水表', () => {
|
|
const html = renderToStaticMarkup(<QAOperationsTabs view="records" onChange={vi.fn()} />)
|
|
expect(html).toContain('>问题流水表</button>')
|
|
})
|
|
|
|
it('uses matching query/sync action sizing and keeps synchronization status outside the button baseline', () => {
|
|
const css = readFileSync(new URL('./qaOps.css', import.meta.url), 'utf8')
|
|
expect(css).toContain('.qa-ops-query .qa-query-action')
|
|
expect(css).toMatch(/\.qa-ops-query \.qa-query-action\s*\{[^}]*width:\s*96px/)
|
|
expect(css).toMatch(/\.qa-ops-query \.qa-mirror-sync-line\s*\{[^}]*margin-bottom:\s*0/)
|
|
})
|