Desktop: rebuild the hosts board once the typing in the find box pauses, not once a letter

This commit is contained in:
jaap-jan committed 2026-10-02 15:23:58 +02:00
1 parent 8759b12d47
commit 24c18205c3
3 files changed
+94 -1

No files matched your search

@@ -520,6 +520,53 @@ public sealed class HostGridTests : IAsyncLifetime
});
}
/// <remarks>
/// Every change to the filter rebuilds the board's sections and every card in them, and a name typed at
/// speed used to do that once a letter. The box now tells the vault once the typing pauses — and then
/// exactly once, with the whole of what was typed.
/// </remarks>
[Fact]
public async Task TypingIntoTheFindBox_RebuildsTheBoardOnceThePauseComes_NotOnceALetter()
{
await OnTheBoardAsync((screen, _) =>
{
// Each letter's wait, ended by hand: the pause is real time in the application, and this says
// when it is over instead of sleeping through it.
var pauses = new List<TaskCompletionSource>();
screen.Pause = _ =>
{
var pause = new TaskCompletionSource();
pauses.Add(pause);
return pause.Task;
};
var rebuilds = 0;
vault.HostSections.CollectionChanged += (_, _) => rebuilds++;
var box = screen.FindControl<TextBox>("HostFilter").ShouldNotBeNull();
box.Text = "p";
box.Text = "pr";
box.Text = "pro";
Dispatcher.UIThread.RunJobs();
vault.HostFilter.ShouldBeNullOrEmpty("nothing has reached the vault while the typing goes on");
rebuilds.ShouldBe(0);
foreach (var pause in pauses)
{
pause.SetResult();
}
Dispatcher.UIThread.RunJobs();
vault.HostFilter.ShouldBe("pro");
rebuilds.ShouldBe(1, "only the last letter's wait passes the text on");
vault.VisibleHosts.ShouldHaveSingleItem().Label.ShouldBe("prod-db");
});
}
// ---- Helpers ----
private static void RightClick(Visual card, Visual window)