Files
knowledge-governance/web/src/qaHistoricalTrend.test.ts
T
姚章浩 a9870beade
build / build (push) Successful in 1m10s
feat(qaops): 补充独立历史覆盖率与正确率趋势
用户提供的历史百分比独立持久化,按ISO自然周和截止范围读取,不伪造分子分母、记录数或冻结时间。现有两张趋势图与PNG共用来源分色/分段及两位小数;缺失周留空,关键词筛选不借用无明细历史,当前指标与原冻结证据不变。

验证:完整make verify退出0;镜像全量隔离PG race退出0,新增来源/精度/关键词/租户/截止/不可变和安全down回归先失败后通过。前端输入/来源及缺失周回归先红后绿。治理库上线前原生备份与真实恢复已完成,71表行数和28张QA表内容哈希一致,独立主密钥同时受限备份。

当前仅完成开发验证,真实数据候选浏览器验收、正式25周导入与应用上线需继续完成。不修改源生产数据库、原问答、已有模型自动开关或隧道;用户原始报表和图像只保存于私有证据目录,不入Git。
2026-10-19 17:55:15 +08:00

28 lines
1.1 KiB
TypeScript

import { it, expect } from 'vitest'
import { parseQADashboard } from './qaDashboardData'
import { dashboardFixture } from './qaDashboard.fixture'
import { historicalTrend } from './qaHistoricalTrend'
it('keeps absent weeks null, preserves supplied precision and never mutates real frozen evidence', () => {
const input = parseQADashboard({
...dashboardFixture,
reported_weeks: [
{
week: '2026WK38',
week_start: '2026-09-14T00:00:00+08:00',
week_end: '2026-09-21T00:00:00+08:00',
coverage_percent: 57.23,
correctness_percent: 92.34,
source: 'user_provided_history',
},
],
})
const before = JSON.stringify(input)
const points = historicalTrend(input, false)
expect(points.map((p) => p.week)).toEqual(['2026WK38', '2026WK39', '2026WK40', '2026WK41'])
expect(points.map((p) => p.value)).toEqual([57.23, null, null, 50])
expect(points[0].source).toBe('user_provided_history')
expect(points[3].source).toBe('system_frozen')
expect(historicalTrend(input, true)[0].value).toBe(92.34)
expect(JSON.stringify(input)).toBe(before)
})