app: render the panel with an injected clock
The headless forecast check failed after 2026-10-16 08:33 UTC because the fixture fixes now while PanelWindow read DateTimeOffset.UtcNow. PanelWindow now takes an optional TimeProvider (system by default) and hands it to the pace bar, burn-up, peak and usage charts and every forecast label. The tests pin it to fixture time and check the "Forecast from" note before, at and after the forecast start. App test fixtures now use fixed dates and pin HistoryStore's clock, so the 60-day Claude retention cannot drop their samples later. Refs #11
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