using System.IO; using ClaudeDo.Localization; using ClaudeDo.Ui.Localization; using ClaudeDo.Ui.Services; using ClaudeDo.Ui.ViewModels.Modals.Settings; namespace ClaudeDo.Ui.Tests.ViewModels; public class FilesSettingsTabViewModelTests { public FilesSettingsTabViewModelTests() { var dir = AppContext.BaseDirectory; while (dir is not null && !Directory.Exists(Path.Combine(dir, "src", "ClaudeDo.Localization", "locales"))) dir = Path.GetDirectoryName(dir); Loc.Current = new Localizer( LocaleStore.Load(Path.Combine(dir!, "src", "ClaudeDo.Localization", "locales")), "en"); } private sealed class ThrowingWorker : StubWorkerClient { public string ExceptionMessage { get; init; } = "permission denied copying agent files"; public override Task RestoreDefaultAgentsAsync() => throw new Exception(ExceptionMessage); } [Fact] public async Task RestoreDefaultAgents_WhenWorkerThrows_ShowsExceptionMessage_NotGenericOffline() { var worker = new ThrowingWorker(); var vm = new FilesSettingsTabViewModel(worker); await vm.RestoreDefaultAgentsCommand.ExecuteAsync(null); Assert.Contains(worker.ExceptionMessage, vm.StatusMessage); Assert.False(vm.IsBusy); } }