app: render the panel with an injected clock so tests do not depend on the date (#12)
The headless forecast test failed from 2026-10-16 on because the panel read the real clock while its fixture fixes the time. - App: PanelWindow takes an optional TimeProvider (the system clock by default) and passes it to the pace bar, burn-up, peak and usage charts and every forecast label. The burn-up chart uses the panel's render time as now. - Tests: headless panels run on a fixed clock at fixture time, with a check before, at and after the forecast start. App and Core tests with fixed-date Claude events pin HistoryStore's clock, so the 60-day retention cannot drop them later. Closes #11
This commit was merged in pull request #12.
This commit is contained in:
@@ -96,9 +96,9 @@ public partial class PanelViewModel : ObservableObject
|
||||
|
||||
public static class Display
|
||||
{
|
||||
public static string? ForecastWaiting(WindowSnapshot window, DateTimeOffset now) =>
|
||||
public static string? ForecastWaiting(WindowSnapshot window, DateTimeOffset now, TimeProvider? clock = null) =>
|
||||
window.Pace.State != PaceState.Unknown && !Pace.CanForecast(window.Window, now, window.Pace) &&
|
||||
Pace.ForecastStartsAt(window.Window) is { } start && start > now ? "Forecast from " + Projection(start) : null;
|
||||
Pace.ForecastStartsAt(window.Window) is { } start && start > now ? "Forecast from " + Projection(start, clock) : null;
|
||||
public static string ChartDateLabel(DateTimeOffset time, TimeSpan interval)
|
||||
=> ChartTime(time, interval).ToString(interval >= TimeSpan.FromDays(1) ? "MM-dd" : "MM-dd HH:mm");
|
||||
public static string ChartTimestamp(DateTimeOffset time, TimeSpan interval)
|
||||
@@ -132,7 +132,7 @@ public static class Display
|
||||
var format = trimTrailingZeros ? decimals == 0 ? "0" : "0." + new string('#', decimals) : "F" + decimals;
|
||||
return value.ToString(format) + new[] { "", " K", " M", " B" }[unit];
|
||||
}
|
||||
public static string Forecast(DateTimeOffset date, PaceState state) =>
|
||||
(state == PaceState.Ahead ? "⚠ " : "At this pace ") + "100 % on " + Projection(date);
|
||||
public static string Forecast(DateTimeOffset date, PaceState state, TimeProvider? clock = null) =>
|
||||
(state == PaceState.Ahead ? "⚠ " : "At this pace ") + "100 % on " + Projection(date, clock);
|
||||
public static string State(PaceState state) => state switch { PaceState.OnTrack => "✓ On track", PaceState.Ahead => "▲ Ahead", PaceState.Behind => "▼ Behind", _ => "? Pace unknown" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user