fix(centralui): Topology live tick behind PollGate, refresh no longer unmounts tree (review 2026-10-21 07/P-2)

This commit is contained in:
Joseph Doherty
2026-10-22 08:41:47 -04:00
parent c429fb374b
commit 6644cf917d
2 changed files with 57 additions and 20 deletions
@@ -199,4 +199,35 @@ public class TopologyLiveUpdatesTimerDisposeRaceTests : BunitContext
Assert.Null(ex);
Assert.Null(GetField<Timer?>(cut.Instance, "_liveUpdatesTimer"));
}
private static void InvokeTick(object page) =>
page.GetType().GetMethod("OnLiveUpdatesTick", BindingFlags.Instance | BindingFlags.NonPublic)!
.Invoke(page, new object?[] { null });
/// <summary>
/// Review 2026-10-21 07/P-2: a tick arriving while the previous refresh is still in
/// flight is skipped (PollGate), and a refresh never flips the page back to the spinner.
/// </summary>
[Fact]
public async Task LiveTick_WhilePreviousRefreshInFlight_IsSkipped_AndDoesNotUnmountTree()
{
var cut = Render<TopologyPage>();
_siteRepo.ClearReceivedCalls();
var release = new TaskCompletionSource<IReadOnlyList<Site>>();
_siteRepo.GetAllSitesAsync(Arg.Any<CancellationToken>()).Returns(release.Task);
InvokeTick(cut.Instance);
InvokeTick(cut.Instance);
InvokeTick(cut.Instance);
await Task.Delay(100);
// Three ticks, one query: the gate dropped the overlapping two.
await _siteRepo.Received(1).GetAllSitesAsync(Arg.Any<CancellationToken>());
// The in-flight refresh must not have swapped the tree for the spinner.
Assert.False(GetField<bool>(cut.Instance, "_loading"));
release.SetResult(new List<Site>());
await Task.Delay(100);
cut.Instance.Dispose();
}
}