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:
@@ -43,7 +43,7 @@ public sealed class FormattingTests
|
||||
[InlineData(FinalToken.Core.PaceState.Unknown, false)]
|
||||
public void ForecastWarningFollowsState(FinalToken.Core.PaceState state, bool warning)
|
||||
{
|
||||
var text = Display.Forecast(new(2026, 10, 18, 14, 43, 0, TimeSpan.Zero), state);
|
||||
var text = Display.Forecast(new(2026, 10, 18, 14, 43, 0, TimeSpan.Zero), state, new FixedClock());
|
||||
Assert.Equal(warning, text.Contains('⚠'));
|
||||
Assert.StartsWith(warning ? "⚠ 100 % on " : "At this pace 100 % on ", text);
|
||||
}
|
||||
@@ -117,9 +117,11 @@ public sealed class FormattingTests
|
||||
Assert.Equal([0d], UsageChart.AxisTicks(0, true));
|
||||
}
|
||||
|
||||
private sealed class FixedClock : TimeProvider
|
||||
{
|
||||
public override DateTimeOffset GetUtcNow() => new(2026, 10, 14, 18, 0, 0, TimeSpan.Zero);
|
||||
public override TimeZoneInfo LocalTimeZone { get; } = TimeZoneInfo.CreateCustomTimeZone("Fixture+02", TimeSpan.FromHours(2), "Fixture", "Fixture");
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class FixedClock(DateTimeOffset? now = null) : TimeProvider
|
||||
{
|
||||
public DateTimeOffset UtcNow { get; set; } = now ?? new(2026, 10, 14, 18, 0, 0, TimeSpan.Zero);
|
||||
public override DateTimeOffset GetUtcNow() => UtcNow;
|
||||
public override TimeZoneInfo LocalTimeZone { get; } = TimeZoneInfo.CreateCustomTimeZone("Fixture+02", TimeSpan.FromHours(2), "Fixture", "Fixture");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user