Files
knowledge-governance/web/src/qaDownvote.test.ts
T
姚章浩 09b2c1dce5
build / build (push) Successful in 1m17s
fix(qa): 表头筛选并统一未覆盖正确性待确认
修正筛选入口位置:五项条件在表头就地选择,保持完整集筛选与无感续载。
统一固定规则:未覆盖一律待确认,原问答/人工模型证据不改写,已覆盖仍保留点踩优先。
验证:行为红绿、前端/Go全套及隔离PostgreSQL全mirror竞态通过;完整本地门禁与原生备份真实恢复通过。
2026-10-25 13:58:08 +08:00

65 lines
2.8 KiB
TypeScript

import { expect, it } from 'vitest'
import { createElement } from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { parseQARecord, qaCellValue } from './qaOps'
import { fixtureRecord } from './qaOps.test'
import { fields, qualityFixture } from './qaQuality.fixture'
import { QAInlineFields } from './QAInlineFields'
const downvoted = {
...fixtureRecord,
record_origin: 'dobotai_2_0',
master_fields: { is_correct: '否' },
quality: {
...qualityFixture,
effective_source: 'master-effective-fields-v1',
feedback_rule: 'downvote-is-incorrect-v1',
effective: { ...fields, correctness: 'incorrect' },
},
}
it('accepts the explicit downvote rule while retaining the original positive human evidence', () => {
const row = parseQARecord(downvoted)
expect(qaCellValue(row, 'is_correct')).toBe('否')
expect(row.quality?.latest_review?.fields.correctness).toBe('correct')
})
it('does not accept a fabricated downvote rule or use it to change unrelated human fields', () => {
expect(() => parseQARecord({ ...downvoted, feedback: { asker_value: '', up: 0, down: 0 } })).toThrow()
expect(() => parseQARecord({ ...downvoted, record_origin: undefined })).toThrow()
expect(() => parseQARecord({ ...downvoted, quality: { ...downvoted.quality, feedback_rule: 'unknown' } })).toThrow()
expect(() =>
parseQARecord({
...downvoted,
quality: { ...downvoted.quality, effective: { ...fields, correctness: 'incorrect', coverage: 'uncovered' } },
})
).toThrow()
})
it('accepts only the explicit uncovered-pending rule while preserving older human correctness', () => {
const original = { ...fields, coverage: 'uncovered', correctness: 'incorrect' }
const wire = {
...downvoted,
master_fields: { coverage: '否', is_correct: '待确认' },
quality: {
...qualityFixture,
effective_source: 'master-effective-fields-v1',
correctness_rule: 'coverage-correctness-v1',
latest_review: { ...qualityFixture.latest_review, fields: original },
effective: { ...original, correctness: 'pending' },
},
}
const row = parseQARecord(wire)
expect(qaCellValue(row, 'is_correct')).toBe('待确认')
expect(row.quality?.latest_review?.fields.correctness).toBe('incorrect')
expect(() => parseQARecord({ ...wire, quality: { ...wire.quality, correctness_rule: 'unknown' } })).toThrow()
expect(() =>
parseQARecord({ ...wire, quality: { ...wire.quality, effective: { ...original, correctness: 'correct' } } })
).toThrow()
})
it('explains the fixed negative correctness without restoring the removed review form', () => {
const row = parseQARecord(downvoted)
const html = renderToStaticMarkup(
createElement(QAInlineFields, { record: row, onSaved: () => {}, onReload: () => {} })
)
expect(html).toContain('已点踩,是否正确固定为否')
expect(html).not.toContain('人工复核反馈')
})