a9870beade
build / build (push) Successful in 1m10s
用户提供的历史百分比独立持久化,按ISO自然周和截止范围读取,不伪造分子分母、记录数或冻结时间。现有两张趋势图与PNG共用来源分色/分段及两位小数;缺失周留空,关键词筛选不借用无明细历史,当前指标与原冻结证据不变。 验证:完整make verify退出0;镜像全量隔离PG race退出0,新增来源/精度/关键词/租户/截止/不可变和安全down回归先失败后通过。前端输入/来源及缺失周回归先红后绿。治理库上线前原生备份与真实恢复已完成,71表行数和28张QA表内容哈希一致,独立主密钥同时受限备份。 当前仅完成开发验证,真实数据候选浏览器验收、正式25周导入与应用上线需继续完成。不修改源生产数据库、原问答、已有模型自动开关或隧道;用户原始报表和图像只保存于私有证据目录,不入Git。
56 lines
2.6 KiB
TypeScript
56 lines
2.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { parseQADashboard } from './qaDashboardData'
|
|
import { dashboardFixture } from './qaDashboard.fixture'
|
|
const reported = {
|
|
week: '2026WK40',
|
|
week_start: '2026-09-28T00:00:00+08:00',
|
|
week_end: '2026-10-05T00:00:00+08:00',
|
|
coverage_percent: 57.23,
|
|
correctness_percent: 92.34,
|
|
source: 'user_provided_history',
|
|
}
|
|
describe('reported historical rates', () => {
|
|
it('keeps supplied percentages without inventing denominator or freeze time', () => {
|
|
const result = parseQADashboard({ ...dashboardFixture, reported_weeks: [reported] })
|
|
expect(result.reported_weeks).toEqual([reported])
|
|
expect(result.frozen_weeks).toEqual(parseQADashboard(dashboardFixture).frozen_weeks)
|
|
expect(result.quality).toEqual(parseQADashboard(dashboardFixture).quality)
|
|
})
|
|
it('rejects invalid, duplicate, future, wrongly labelled and keyword-scoped supplied history', () => {
|
|
for (const input of [
|
|
{ ...dashboardFixture, reported_weeks: [reported, reported] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, denominator: 100 }] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, coverage_percent: 100.01 }] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, correctness_percent: null }] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, source: 'frozen' }] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, week: '2026WK41' }] },
|
|
{ ...dashboardFixture, reported_weeks: [{ ...reported, week_end: '2027-01-01T00:00:00+08:00' }] },
|
|
{ ...dashboardFixture, keyword: 'needle', reported_weeks: [reported] },
|
|
])
|
|
expect(() => parseQADashboard(input)).toThrow()
|
|
})
|
|
})
|
|
|
|
describe('complete dashboard data contract', () => {
|
|
it('keeps distinct cumulative, week, month and genuinely frozen periods', () => {
|
|
const data = parseQADashboard(dashboardFixture)
|
|
expect([data.total_issues, data.new_this_week, data.regions[0].questions]).toEqual([4, 2, 3])
|
|
expect(data.frozen_weeks[0].coverage.percent).toBeNull()
|
|
expect(data.frozen_weeks[1].coverage.percent).toBe(50)
|
|
})
|
|
it('rejects fabricated percentages, category omissions and historical backfill', () => {
|
|
for (const bad of [
|
|
{ ...dashboardFixture, new_this_week: 5 },
|
|
{ ...dashboardFixture, products: [] },
|
|
{ ...dashboardFixture, regions: [{ ...dashboardFixture.regions[0], frequency: 3 }] },
|
|
{
|
|
...dashboardFixture,
|
|
frozen_weeks: [
|
|
{ ...dashboardFixture.frozen_weeks[0], coverage: { numerator: 1, denominator: 2, percent: 50 } },
|
|
],
|
|
},
|
|
])
|
|
expect(() => parseQADashboard(bad)).toThrow()
|
|
})
|
|
})
|