From 280c428b0e90782830ebb9224fb552e0fc061d14 Mon Sep 17 00:00:00 2001 From: Resham Joshi Date: Sat, 12 Sep 2026 12:08:53 -0700 Subject: [PATCH] test(menubar): pin the pace caption's two thresholds Widening the on-pace band from 2 to 20 points, or flipping the six-hour ETA suppression from <= to <, left all 528 tests green. Both are the thresholds the caption is about. --- .../CapacityDockPacePresentationTests.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mac/Tests/CodeBurnMenubarTests/CapacityDockPacePresentationTests.swift b/mac/Tests/CodeBurnMenubarTests/CapacityDockPacePresentationTests.swift index 5963d368..83f4bdce 100644 --- a/mac/Tests/CodeBurnMenubarTests/CapacityDockPacePresentationTests.swift +++ b/mac/Tests/CodeBurnMenubarTests/CapacityDockPacePresentationTests.swift @@ -131,6 +131,24 @@ struct CapacityDockPacePresentationTests { #expect(!(line?.text.contains("until reset") ?? false)) } + @Test("The on-pace band is two points wide in each direction") + func onPaceBandEdges() { + // Nothing else pins this width, so widening it would silently turn a + // real deficit into "On pace" on every short window. + #expect(f.line(percent: 0.515, elapsedFraction: 0.5, windowSeconds: f.fiveHours)?.text == "On pace") + #expect(f.line(percent: 0.485, elapsedFraction: 0.5, windowSeconds: f.fiveHours)?.text == "On pace") + #expect(f.line(percent: 0.53, elapsedFraction: 0.5, windowSeconds: f.fiveHours)?.text == "3% in deficit") + #expect(f.line(percent: 0.47, elapsedFraction: 0.5, windowSeconds: f.fiveHours)?.text == "3% in reserve") + } + + @Test("Six hours exactly is still a short window; one second more is not") + func etaSuppressionBoundary() { + let sixHours = 6 * 3600 + #expect(f.line(percent: 0.9, elapsedFraction: 0.5, windowSeconds: sixHours)?.text == "40% in deficit") + let justOver = f.line(percent: 0.9, elapsedFraction: 0.5, windowSeconds: sixHours + 1) + #expect(justOver?.text.hasPrefix("Runs out in") == true) + } + @Test("Stale, failed and disconnected data get nothing") func nonConnectedDataIsSilent() { for connection: QuotaSummary.Connection in [.stale, .loading, .transientFailure, .disconnected] {