From eeb121734b6a3ed395fcbf8069b9a06cc944cf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Tue, 27 Oct 2026 15:55:14 +0100 Subject: [PATCH] test: cover the join prompt's last-connection prefill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The changed-line mutation gate failed on #785: rewording the comment inside the join prompt's object initializer put the initializer's `{}` mutant on a changed line, and nothing in LageBuch.AppLogic.Tests noticed the prompt losing its prefilled Host and PIN. Only the Sync.Hosting and Acceptance suites covered it, and Stryker runs neither. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com> --- .../MainWindowViewModelTests.cs | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/LageBuch.AppLogic.Tests/MainWindowViewModelTests.cs b/tests/LageBuch.AppLogic.Tests/MainWindowViewModelTests.cs index e61b5202..3bc885f0 100644 --- a/tests/LageBuch.AppLogic.Tests/MainWindowViewModelTests.cs +++ b/tests/LageBuch.AppLogic.Tests/MainWindowViewModelTests.cs @@ -19,10 +19,10 @@ public class MainWindowViewModelTests // ConnectAsync has no accept-any fallback -- it needs a real ITrustStore to even attempt the TLS // handshake it's cancelling. A fresh temp-backed JsonTrustStore per HomeViewModel keeps every // test's TOFU state isolated from the others. - private static MainWindowViewModel New(IFileDialogService? dialogs = null) + private static MainWindowViewModel New(IFileDialogService? dialogs = null, ILastConnectionStore? lastConnection = null) { var trustStore = new JsonTrustStore(Path.Join(Path.GetTempPath(), $"trust-{Guid.NewGuid():N}.json")); - var home = new HomeViewModel(new FakeStore(), new MvFakeMasterData(), new FakeRecent(), new FakeDialogs(), new FixedClock(T0), new FakeTicker(), new FakeAlarmService(), new NoopIncidentHostController(), "1.0.0", trustStore: trustStore); + var home = new HomeViewModel(new FakeStore(), new MvFakeMasterData(), new FakeRecent(), new FakeDialogs(), new FixedClock(T0), new FakeTicker(), new FakeAlarmService(), new NoopIncidentHostController(), "1.0.0", trustStore: trustStore, lastConnection: lastConnection); return new MainWindowViewModel(home, new MasterDataEditorViewModel(new MvFakeMasterData(), new FakeDialogs(), new NoFiles()), dialogs ?? new FakeDialogs(), "0.1.0"); } @@ -151,6 +151,28 @@ public async Task CancelJoin_aborts_a_stuck_connection_attempt_without_closing_t Assert.IsType(vm.CurrentView); } + [Fact] + public void Join_prompt_prefills_the_host_and_pin_of_the_last_connection() + { + var vm = New(lastConnection: new FakeLastConnectionStore { Saved = new LastConnection("elw-1", null, T0, "5393") }); + + vm.RequestJoinDeviceCommand.Execute(null); + + Assert.Equal("elw-1", vm.PendingPrompt?.Host); + Assert.Equal("5393", vm.PendingPrompt?.Pin); + } + + [Fact] + public void Join_prompt_starts_empty_without_a_last_connection() + { + var vm = New(lastConnection: new FakeLastConnectionStore()); + + vm.RequestJoinDeviceCommand.Execute(null); + + Assert.Equal(string.Empty, vm.PendingPrompt?.Host); + Assert.Equal(string.Empty, vm.PendingPrompt?.Pin); + } + [Fact] public void RequestOpenFile_opens_readonly_without_prompt() {