The footer pill fired OpenWorkerConnectionHelpCommand unconditionally, so clicking it on a connected worker showed the "WORKER NOT REACHABLE" dialog. Gate the command on !IsConnected (not IsOffline — the retry loop stays in "connecting" forever while the worker is down, which is exactly when the dialog's "Start Worker" is needed) and re-evaluate CanExecute on connection state changes.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using ClaudeDo.Ui.ViewModels;
|
|
using Xunit;
|
|
|
|
namespace ClaudeDo.Ui.Tests;
|
|
|
|
public class ConnectionPromptGateTests
|
|
{
|
|
[Fact]
|
|
public void Shows_once_when_offline()
|
|
{
|
|
var vm = new IslandsShellViewModel();
|
|
Assert.True(vm.DecideShowConnectionPrompt(isOffline: true));
|
|
Assert.False(vm.DecideShowConnectionPrompt(isOffline: true)); // not a second time
|
|
}
|
|
|
|
[Fact]
|
|
public void Does_not_show_when_connected_before_grace()
|
|
{
|
|
var vm = new IslandsShellViewModel();
|
|
Assert.False(vm.DecideShowConnectionPrompt(isOffline: false));
|
|
}
|
|
|
|
// The footer pill binds OpenWorkerConnectionHelpCommand, and the dialog says "WORKER NOT
|
|
// REACHABLE" — so it must stay closed while the worker is connected, and stay reachable
|
|
// while it is not (including the endless "connecting" retry state).
|
|
[Theory]
|
|
[InlineData(true, false)]
|
|
[InlineData(false, true)]
|
|
public void Connection_help_is_gated_on_connected(bool isConnected, bool canOpen)
|
|
=> Assert.Equal(canOpen, IslandsShellViewModel.DecideCanOpenConnectionHelp(isConnected));
|
|
|
|
[Fact]
|
|
public void Connection_help_command_enabled_without_worker()
|
|
{
|
|
var vm = new IslandsShellViewModel();
|
|
Assert.True(vm.OpenWorkerConnectionHelpCommand.CanExecute(null));
|
|
}
|
|
}
|