





















@@ -227,10 +227,9 @@ describe("buildPeakErrorHours", () => {
227227228228it("falls back to proportional allocation when utcQuarterHourMessageCounts is absent", () => {
229229// Session without utcQuarterHourMessageCounts should use forEachSessionHourSlice
230-const now = Date.now();
231230const session: UsageSessionEntry = {
232231key: "fallback-session",
233-updatedAt: now,
232+updatedAt: Date.parse("2026-03-15T10:30:00.000Z"),
234233usage: {
235234totalTokens: 100,
236235totalCost: 0.01,
@@ -243,8 +242,8 @@ describe("buildPeakErrorHours", () => {
243242cacheReadCost: 0,
244243cacheWriteCost: 0,
245244missingCostEntries: 0,
246-firstActivity: now - 3600_000,
247-lastActivity: now,
245+firstActivity: Date.parse("2026-03-15T10:00:00.000Z"),
246+lastActivity: Date.parse("2026-03-15T10:30:00.000Z"),
248247messageCounts: {
249248total: 10,
250249user: 5,
@@ -258,14 +257,9 @@ describe("buildPeakErrorHours", () => {
258257} as unknown as UsageSessionEntry;
259258260259const result = buildPeakErrorHours([session], "utc");
261-// Should still produce results via the proportional allocation fallback
262-expect(result.length).toBeGreaterThan(0);
263-// All errors (3) should be distributed proportionally
264-const totalErrors = result.reduce((sum, r) => {
265-const match = r.sub.match(/(\d+) errors/);
266-return sum + (match ? Number.parseInt(match[1], 10) : 0);
267-}, 0);
268-expect(totalErrors).toBe(3);
260+expect(result.map(({ value, sub }) => ({ value, sub }))).toStrictEqual([
261+{ value: "30.00%", sub: "3 errors · 10 msgs" },
262+]);
269263});
270264});
271265此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。