From 5a2f1b8563d46f9672bee490430e7fd08047a330 Mon Sep 17 00:00:00 2001 From: James Maes Date: Tue, 10 Nov 2026 20:02:50 -0600 Subject: [PATCH] fix(wizard): an empty token box asks for a token instead of showing the engine's argument error Step 2 of Add account sent an empty token to the lister, whose argument check answered with "The value cannot be an empty string...", and the log said the token was rejected although none was sent. The wizard now says "Enter a token to continue." and asks nothing of the server. Closes #172 Co-Authored-By: Claude Fable 5.2 Signed-off-by: James Maes --- .../AccountWizardViewModelTests.cs | 20 +++++++++++++++++++ gclo.ViewModels/AccountWizardViewModel.cs | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/gclo.Engine.Tests/AccountWizardViewModelTests.cs b/gclo.Engine.Tests/AccountWizardViewModelTests.cs index 1578b6e..b455336 100644 --- a/gclo.Engine.Tests/AccountWizardViewModelTests.cs +++ b/gclo.Engine.Tests/AccountWizardViewModelTests.cs @@ -280,6 +280,26 @@ public sealed class AccountWizardViewModelTests : IDisposable + [Theory] + [InlineData("")] + [InlineData(" ")] + public async Task TryAdvance_WithNoTokenTyped_AsksForOne_AndAsksNothingOfTheServer(string typed) + { + AccountWizardViewModel wizard = NewWizard(); + wizard.Name = "Work"; + await AdvanceToStepAsync(wizard, 2); + wizard.Token = typed; + + Assert.False(await wizard.TryAdvanceAsync()); + + Assert.Equal(2, wizard.Step); + Assert.Equal("Enter a token to continue.", wizard.TokenError); + Assert.False(wizard.IsValidatingToken); + Assert.Equal(0, _orgs.Calls); + } + + + [Fact] public async Task TryAdvance_RejectedToken_SetsTokenErrorAndStays() { diff --git a/gclo.ViewModels/AccountWizardViewModel.cs b/gclo.ViewModels/AccountWizardViewModel.cs index 719802d..cf7db61 100644 --- a/gclo.ViewModels/AccountWizardViewModel.cs +++ b/gclo.ViewModels/AccountWizardViewModel.cs @@ -368,6 +368,13 @@ public sealed partial class AccountWizardViewModel : ObservableObject return false; } } + else if(candidate.Length == 0) + { + // Nothing to check: say so here, instead of asking the server + // and showing its argument error (#172). + TokenError = "Enter a token to continue."; + return false; + } } IsValidatingToken = true; -- 2.54.0