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) })