test(app): Library logic tests, capture scenes and smoke tests

Timeline bands and month mapping, saved views (validation and a round trip
through the settings table), the mass actions bar's targets and reasons, remote
cards and their place among the pages, the CSV list and the delete dry run's
confirmation. --capture writes library-timeline, library-mass, library-delete
and library-remote in both themes (LibraryScenes), the sample data saves two
views, and a Windows smoke test renders each scene and checks the bar, the
typed confirmation and the saved views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 16:44:10 +00:00
1 parent 743418d944
commit 7f94c9a839
10 files changed
+729

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
using Titano.App.Archiving;
using Titano.App.Infrastructure;
using Titano.App.Shell;
namespace Titano.App.Library;
/// <summary>
/// The Library states that <c>--capture</c> renders (<c>library-&lt;scene&gt;-&lt;theme&gt;.png</c>) and the screen smoke
/// tests check, on the sample index while signed in to the sample server: the timeline with a month chosen, a selection
/// with the whole mass actions bar, and the server's sequences without a copy here as remote cards.
/// </summary>
public static class LibraryScenes
{
public static readonly IReadOnlyList<string> Scenes = ["timeline", "mass", "remote"];
/// <summary>Sequences selected for the mass actions bar.</summary>
public const int MassSelection = 3;
public static async Task ShowAsync(ShellViewModel shell, string scene)
{
var library = shell.Library;
shell.Navigate(SectionKey.Library);
library.ClearSelectionCommand.Execute(null);
library.ClearFiltersCommand.Execute(null);
library.LayoutIndex = 0;
await library.RefreshAsync();
switch (scene)
{
case "timeline":
library.LayoutIndex = 2;
// A month further down the list: the year becomes the filter and the grid scrolls to the month.
if (library.Items.Count > 0 && library.Items[Math.Min(12, library.Items.Count - 1)].Sequence.FirstCapture is { } month)
{
library.ShowMonth(month.Year, month.Month);
await library.RefreshAsync();
}
break;
case "mass":
foreach (var item in library.Items.Where(i => !i.IsRemote).Take(MassSelection)) item.IsSelected = true;
break;
case "remote":
library.SelectedOrigin = library.Origins.First(o => o.Value == OriginFilter.Server);
await library.RefreshAsync();
if (library.Items.FirstOrDefault() is { } remote) remote.IsSelected = true;
// Remote thumbnails come through the sync engine's connection, not the local thumbnail service.
for (var i = 0; i < 60 && library.Items.Any(item => item.Thumbnail is null); i++) await Task.Delay(50);
break;
default:
throw new ArgumentOutOfRangeException(nameof(scene), scene, "Unknown Library scene.");
}
}
/// <summary>The confirmation Delete shows for the selection: the archive engine's dry run (nothing moves).</summary>
public static async Task<ConfirmRequest?> DeleteRequestAsync(ShellViewModel shell)
{
var archives = shell.Services.Archives ?? throw new InvalidOperationException("The sample index is not open.");
var ids = shell.Library.SelectedItems().Where(i => !i.IsRemote).Select(i => i.Id).ToList();
return DeletePlans.Request(await Task.Run(() => archives.PlanDeleteAsync(ids)));
}
}