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:
10 files changed
+729
No files matched your search
@@ -0,0 +1,82 @@
|
||||
using System.IO;
|
||||
using Titano.App.Library;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.App.Tests.Library;
|
||||
|
||||
/// <summary>Saved views of the Library (BRIEF §12.2): a name for filters and sort, kept as app-scope settings rows.</summary>
|
||||
public sealed class SavedViewTests(TestContext context)
|
||||
{
|
||||
private static readonly LibraryFilter Night = new()
|
||||
{
|
||||
Text = " night ",
|
||||
Year = 2026,
|
||||
Camera = "ILCE-7M4",
|
||||
Status = StatusFilter.NotAnalysed,
|
||||
Tag = "stars",
|
||||
Origin = OriginFilter.Local,
|
||||
Sort = SequenceSort.Size,
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void AViewKeepsFiltersAndSortAndRecognisesThem()
|
||||
{
|
||||
var view = SavedView.Of(Guid.CreateVersion7(), " Night, 4K, not analysed ", Night);
|
||||
|
||||
Assert.Equal("Night, 4K, not analysed", view.Name);
|
||||
Assert.Equal("night", view.Text);
|
||||
Assert.Equal(Night with { Text = "night" }, view.ToFilter());
|
||||
Assert.True(view.Matches(Night));
|
||||
Assert.True(view.Matches(Night with { Text = "NIGHT" }), "the search compares trimmed and ignoring case");
|
||||
Assert.False(view.Matches(Night with { Sort = SequenceSort.Newest }), "the sort is part of the view");
|
||||
Assert.False(view.Matches(Night with { Origin = OriginFilter.Any }));
|
||||
Assert.False(view.Matches(Night with { Tag = null }));
|
||||
|
||||
var blank = SavedView.Of(Guid.CreateVersion7(), "All", new LibraryFilter { Text = " " });
|
||||
Assert.Null(blank.Text);
|
||||
Assert.True(blank.Matches(new LibraryFilter()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NamesAreShortUniqueAndPrintable()
|
||||
{
|
||||
string[] others = ["Night", "Holy grail"];
|
||||
Assert.Equal(Loc.L("Library.Views.Error.Empty"), SavedView.Validate(" ", others));
|
||||
Assert.Equal(Loc.L("Library.Views.Error.Long", SavedView.MaxName), SavedView.Validate(new string('a', SavedView.MaxName + 1), others));
|
||||
Assert.Equal(Loc.L("Library.Views.Error.Long", SavedView.MaxName), SavedView.Validate("Night\tsky", others));
|
||||
Assert.Equal(Loc.L("Library.Views.Error.Taken"), SavedView.Validate(" night ", others));
|
||||
Assert.Null(SavedView.Validate("Night, 4K", others));
|
||||
Assert.Null(SavedView.Validate(new string('a', SavedView.MaxName), others));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ViewsRoundTripThroughTheSettingsTable()
|
||||
{
|
||||
await using var db = await TitanoDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory("db"), "titano.db")), context.Cancellation);
|
||||
var store = new SavedViewStore(db.Settings);
|
||||
Assert.Empty(await store.ListAsync());
|
||||
|
||||
var night = SavedView.Of(Guid.CreateVersion7(), "Night", Night);
|
||||
var grail = SavedView.Of(Guid.CreateVersion7(), "holy grail", new LibraryFilter { Tag = "holy grail", Sort = SequenceSort.Oldest });
|
||||
await store.SaveAsync(night);
|
||||
await store.SaveAsync(grail);
|
||||
// Other app settings and a damaged row live next to the views and are not views.
|
||||
await db.Settings.SetJsonAsync(SettingScope.App, null, "library.layout", "2");
|
||||
await db.Settings.SetJsonAsync(SettingScope.App, null, "library.view.broken", "\"not a view\"");
|
||||
|
||||
var listed = await store.ListAsync();
|
||||
Assert.SequenceEqual(["holy grail", "Night"], listed.Select(v => v.Name), "by name, ignoring case");
|
||||
Assert.Equal(night, listed[1]);
|
||||
Assert.Equal(grail, listed[0]);
|
||||
|
||||
await store.SaveAsync(night with { Name = "Night sky" });
|
||||
Assert.SequenceEqual(["holy grail", "Night sky"], (await store.ListAsync()).Select(v => v.Name), "a rename keeps one row");
|
||||
|
||||
Assert.True(await store.DeleteAsync(grail.Id));
|
||||
Assert.False(await store.DeleteAsync(grail.Id));
|
||||
Assert.Equal(night.Id, (await store.ListAsync()).Single().Id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user