fix(ui): UsagePillViewModel loads snapshot on connection restore

The ctor-time LoadAsync races WorkerClient.StartAsync, so the SignalR
call fails silently and the pill only fills on the next worker poll
(up to 900s). Subscribe to ConnectionRestoredEvent, which also fires
on the first successful connect, to retry the cached snapshot.
This commit is contained in:
mika kuns
2026-08-21 17:47:49 +02:00
parent 93be76a144
commit 7f94bf4aed
2 changed files with 19 additions and 0 deletions
@@ -144,4 +144,20 @@ public class UsagePillViewModelTests
Assert.Contains("12", vm.Text);
}
// ── ConnectionRestored event ─────────────────────────────────────────────
[Fact]
public void ConnectionRestored_Event_LoadsSnapshot()
{
var worker = new FakeWorker();
var vm = new UsagePillViewModel(worker);
Assert.Null(vm.Snapshot);
worker.InitialSnapshot = Snapshot(fiveHourPercent: 25);
worker.RaiseConnectionRestored();
Assert.NotNull(vm.Snapshot);
Assert.Contains("25", vm.Text);
}
}