F4: DetailsIslandView/TasksIslandView hatten je eine view-lokale Confirm/Error-Dialog-Kopie, teils mit hartkodiertem "Delete"-Knopf fuer jede Aktion (inkl. der Stash+Merge-Bestaetigung, die nichts loescht). Beide Kopien entfernt; DetailsIslandViewModel/TasksIslandViewModel routen Confirm/Error jetzt durch den geteilten Dialogs-Seam (IDialogService, propagiert vom Shell wie schon bei Lists/Tasks) statt ueber eine vom Code-behind gesetzte Func-Property. IDialogService.ConfirmAsync bekommt einen optionalen confirmLabel-Parameter (Default: lokalisiertes "Confirm"); nur die echten Delete-Aktionen (Task loeschen, abgeschlossene Tasks leeren) uebergeben das lokalisierte "Delete"-Label. F5: "Cancel"/"Confirm"/"Delete"/"OK" und die Titel "Confirm"/"Error" durch Loc.T mit neuen Keys unter "dialog.*" ersetzt (en.json + de.json). Mission Controls eigene Dialog-Kopie bleibt bestehen (eigenes Fenster, WindowDialogService ist an den Haupt-Owner gebunden) — nur ihre Labels wurden lokalisiert. Out of scope (siehe Task-Beschreibung): die Nachrichtentexte der Dialoge bleiben unlokalisiert.
77 lines
3.8 KiB
C#
77 lines
3.8 KiB
C#
using ClaudeDo.Data;
|
|
using ClaudeDo.Ui.Services;
|
|
using ClaudeDo.Ui.Services.Interfaces;
|
|
using ClaudeDo.Ui.ViewModels;
|
|
using ClaudeDo.Ui.ViewModels.Conflicts;
|
|
using ClaudeDo.Ui.ViewModels.Modals;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ClaudeDo.Ui.Tests;
|
|
|
|
/// <summary>
|
|
/// The test doubles every ViewModel test needs. They used to be redeclared as a private nested
|
|
/// class in each test file (TestDbFactory alone in 40 of them) — put new shared no-op doubles here
|
|
/// rather than copying one again. Test-specific behaviour still belongs in the test file.
|
|
/// </summary>
|
|
public sealed class TestDbFactory(Func<ClaudeDoDbContext> create) : IDbContextFactory<ClaudeDoDbContext>
|
|
{
|
|
public ClaudeDoDbContext CreateDbContext() => create();
|
|
}
|
|
|
|
public sealed class NullServiceProvider : IServiceProvider
|
|
{
|
|
public object? GetService(Type serviceType) => null;
|
|
}
|
|
|
|
public sealed class StubNotesApi : INotesApi
|
|
{
|
|
public Task<List<DailyNoteDto>> ListAsync(DateOnly day) => Task.FromResult(new List<DailyNoteDto>());
|
|
public Task<List<DailyNoteDto>> ListBetweenAsync(DateOnly start, DateOnly end) => Task.FromResult(new List<DailyNoteDto>());
|
|
public Task<DailyNoteDto?> AddAsync(DateOnly day, string text) => Task.FromResult<DailyNoteDto?>(null);
|
|
public Task UpdateAsync(string id, string text) => Task.CompletedTask;
|
|
public Task DeleteAsync(string id) => Task.CompletedTask;
|
|
}
|
|
|
|
/// <summary><see cref="StubWorkerClient"/> is abstract — this is the concrete no-op subclass.</summary>
|
|
public sealed class DefaultStub : StubWorkerClient { }
|
|
|
|
/// <summary>
|
|
/// Records the message/label of the last Confirm/Error call and returns a configurable
|
|
/// Confirm result. Covers the ViewModels (DetailsIsland, TasksIsland, ...) that take their
|
|
/// dialog seam via a settable <c>Dialogs</c> property instead of a per-call constructor arg.
|
|
/// </summary>
|
|
public sealed class RecordingDialogService : IDialogService
|
|
{
|
|
public bool ConfirmResult { get; set; } = true;
|
|
public string? LastConfirmMessage { get; private set; }
|
|
public string? LastConfirmLabel { get; private set; }
|
|
public string? LastErrorMessage { get; private set; }
|
|
|
|
public Task<bool> ConfirmAsync(string message, string? confirmLabel = null)
|
|
{
|
|
LastConfirmMessage = message;
|
|
LastConfirmLabel = confirmLabel;
|
|
return Task.FromResult(ConfirmResult);
|
|
}
|
|
|
|
public Task ShowErrorAsync(string message)
|
|
{
|
|
LastErrorMessage = message;
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task ShowAboutAsync(AboutModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowWeeklyReportAsync(WeeklyReportModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowUsageMonitorAsync(UsageMonitorModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowSettingsAsync(SettingsModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowListSettingsAsync(ListSettingsModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowRepoImportAsync(RepoImportModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowWorktreesOverviewAsync(WorktreesOverviewModalViewModel vm) => throw new NotImplementedException();
|
|
public Task<IReadOnlyList<string>?> ShowMergeHelperSelectionAsync(MergeHelperSelectionModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowWorkerConnectionAsync(WorkerConnectionModalViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowConflictResolverAsync(ConflictResolverViewModel vm) => throw new NotImplementedException();
|
|
public Task ShowLogVisualizerAsync(LogVisualizerViewModel vm) => throw new NotImplementedException();
|
|
public void ShowMissionControl(MissionControlViewModel vm) => throw new NotImplementedException();
|
|
public void ShowCheatSheets(CheatSheetsViewModel vm) => throw new NotImplementedException();
|
|
}
|