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

+11
View File
@@ -4,6 +4,7 @@ using Titano.App.About;
using Titano.App.Editor;
using Titano.App.Import;
using Titano.App.Infrastructure;
using Titano.App.Library;
using Titano.App.Server;
using Titano.App.Settings;
using Titano.Core.Advice;
@@ -96,6 +97,7 @@ public sealed class SampleData
foreach (var job in Jobs(sequences.Select(s => s.Sequence).ToList(), archive.Id)) await db.Jobs.EnqueueAsync(job);
await FillServerAsync(db, sequences.Select(s => s.Sequence).ToList());
await SampleCards.InsertAsync(db, (SampleDeviceMonitor)_services.Devices, _services.Environment.DataDirectory);
await FillViewsAsync(db);
settings.LastArchivePath = @"D:\TitanoArchive";
settings.ServerUrl = "https://nas.local:8443";
@@ -107,6 +109,15 @@ public sealed class SampleData
settings.FirstRunCompleted = true;
}
/// <summary>Two saved views of the Library ("Not analysed, largest" and one camera), BRIEF §12.2.</summary>
private static async Task FillViewsAsync(TitanoDatabase db)
{
var views = new SavedViewStore(db.Settings);
await views.SaveAsync(SavedView.Of(Guid.CreateVersion7(), "Not analysed, largest",
new LibraryFilter { Status = StatusFilter.NotAnalysed, Sort = Data.Repositories.SequenceSort.Size }));
await views.SaveAsync(SavedView.Of(Guid.CreateVersion7(), "Nikon Z 8", new LibraryFilter { Camera = "NIKON Z 8" }));
}
/// <summary>
/// Transfers for the sync table: an upload at 46 % (Comet over the ridge), an upload waiting (Fog lifting, Asti), a
/// download of originals running (Sunrise over Superga) and one paused (Lake Como storm).
+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)));
}
}
+27
View File
@@ -7,6 +7,7 @@ using Titano.App.Archiving;
using Titano.App.DesignTime;
using Titano.App.Editor;
using Titano.App.Import;
using Titano.App.Library;
using Titano.App.Server;
using Titano.App.Settings;
using Titano.Core.Diagnostics;
@@ -61,6 +62,8 @@ public static class ScreenCapture
await shell.Services.Server.RestoreAsync();
await shell.Services.Sync.RefreshAsync();
await shell.Server.Sync.ReloadAsync();
// The server's sequences without a copy here join the Library as remote cards.
await shell.Library.RefreshAsync();
shell.About.SetResult(null);
await shell.Settings.DetectEncodersAsync();
await shell.Settings.SelfTestAsync();
@@ -79,6 +82,7 @@ public static class ScreenCapture
written += await SaveAsync(window, directory, "library-list", theme, waitForThumbnails: shell);
shell.Library.LayoutIndex = 0;
shell.Library.ClearSelectionCommand.Execute(null);
written += await CaptureLibraryScenesAsync(window, shell, directory, theme);
shell.Navigate(SectionKey.Jobs);
if (shell.Jobs.Rows.Count > 0) shell.Jobs.Rows[0].IsExpanded = true;
@@ -148,6 +152,29 @@ public static class ScreenCapture
}
}
/// <summary>
/// <c>library-timeline</c>, <c>library-mass</c> (the selection with the whole bar), <c>library-delete</c> (the dry run
/// of deleting that selection, behind its typed confirmation) and <c>library-remote</c> (the server's sequences as
/// remote cards), then the Library as it was.
/// </summary>
private static async Task<int> CaptureLibraryScenesAsync(MainWindow window, ShellViewModel shell, string directory, AppTheme theme)
{
var written = 0;
foreach (var scene in LibraryScenes.Scenes)
{
DismissToasts(window);
await LibraryScenes.ShowAsync(shell, scene);
written += await SaveAsync(window, directory, "library-" + scene, theme, waitForThumbnails: shell);
if (scene == "mass" && await LibraryScenes.DeleteRequestAsync(shell) is { } request)
written += await SaveDialogAsync(new ConfirmDialog(request), directory, "library-delete", theme);
}
shell.Library.ClearSelectionCommand.Execute(null);
shell.Library.ClearFiltersCommand.Execute(null);
shell.Library.LayoutIndex = 0;
await shell.Library.RefreshAsync();
return written;
}
private static void SelectSyncFilter(ShellViewModel shell, SyncFilter filter) =>
shell.Server.Sync.Chips.First(c => c.Filter == filter).SelectCommand.Execute(null);