test(archive): month columns per culture, failure sentences, health against duplicates, RTL paths and keys, named buttons and focus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+216
-14
No files matched your search
@@ -1,13 +1,17 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Titano.App.Archiving;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Library;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Imaging;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Archiving;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Testing;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Tests.Archiving;
|
||||
|
||||
@@ -163,11 +167,31 @@ public sealed class ArchiveLogicTests
|
||||
Assert.True(double.IsNaN(rows[2].Values[10]));
|
||||
Assert.Null(rows[2].ToolTips[11]);
|
||||
Assert.Equal("July 2026 · 5,000 photos · 5 sequences", rows[2].ToolTips[6]);
|
||||
Assert.Equal(12, ArchiveFigures.MonthLabels().Count);
|
||||
Assert.Equal("J", ArchiveFigures.MonthLabels()[0]);
|
||||
Assert.Empty(ArchiveFigures.PhotosPerMonth(Stats() with { ByMonth = [] }, DateTime.Today));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MonthColumnsAreInitialsOnlyWhereTheyAreLetters()
|
||||
{
|
||||
var numbers = Enumerable.Range(1, 12).Select(m => m.ToString(CultureInfo.InvariantCulture)).ToArray();
|
||||
try
|
||||
{
|
||||
Assert.Equal("J F M A M J J A S O N D", string.Join(' ', ArchiveFigures.MonthLabels()));
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("it"));
|
||||
Assert.Equal("G F M A M G L A S O N D", string.Join(' ', ArchiveFigures.MonthLabels()));
|
||||
// Numbered abbreviations ("10月", "Tháng 10") would read "1" for October to December, or "T" for every month.
|
||||
foreach (var culture in new[] { "ja", "ko", "zh-Hans", "zh-Hant", "vi", "th", "ar", "he" })
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo(culture));
|
||||
Assert.SequenceEqual(numbers, ArchiveFigures.MonthLabels(), culture);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TilesAndHealthSummariseTheIndex()
|
||||
{
|
||||
@@ -177,7 +201,7 @@ public sealed class ArchiveLogicTests
|
||||
Assert.Equal("9.4 TB", tiles[2].Value);
|
||||
Assert.Equal("6", tiles[3].Value);
|
||||
Assert.Equal("cameras · 8 formats", tiles[3].Caption);
|
||||
Assert.Equal("2024 – 2026", tiles[4].Value);
|
||||
Assert.Equal(Formatting.LeftToRight("2024 – 2026"), tiles[4].Value, "a year range keeps its order in right-to-left text");
|
||||
|
||||
var health = ArchiveFigures.Health(Stats(), withoutProxies: 0);
|
||||
Assert.Equal(HealthAction.Verify, health[0].Action);
|
||||
@@ -187,6 +211,59 @@ public sealed class ArchiveLogicTests
|
||||
Assert.True(health[2].IsOk);
|
||||
Assert.Equal(HealthAction.Analyse, health[3].Action);
|
||||
Assert.Equal(HealthAction.Duplicates, health[4].Action);
|
||||
Assert.Equal("5 duplicate frames", health[4].Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HealthDuplicatesFollowTheLastDuplicatesSearch()
|
||||
{
|
||||
var unflagged = Stats() with { Health = Stats().Health with { DuplicateFrames = 0 } };
|
||||
var before = ArchiveFigures.Health(unflagged, withoutProxies: 0)[4];
|
||||
Assert.True(before.IsOk);
|
||||
Assert.Equal("No copies flagged", before.Text, "before a search the line says what it measures");
|
||||
|
||||
var found = ArchiveFigures.Health(unflagged, withoutProxies: 0, duplicateGroups: 1)[4];
|
||||
Assert.False(found.IsOk, "never a tick while the Duplicates card lists groups");
|
||||
Assert.Equal("1 duplicate group", found.Text);
|
||||
Assert.Equal(HealthAction.MarkDuplicates, found.Action);
|
||||
|
||||
var none = ArchiveFigures.Health(Stats(), withoutProxies: 0, duplicateGroups: 0)[4];
|
||||
Assert.True(none.IsOk);
|
||||
Assert.Equal(HealthAction.None, none.Action);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FailuresAreOneLocalizedSentenceByCause()
|
||||
{
|
||||
Assert.Equal("The archive " + Formatting.LeftToRight("/archive") + " is offline.",
|
||||
ArchiveFailures.Cause(new ArchiveOfflineException("/archive", ArchiveAvailability.Offline)));
|
||||
Assert.Equal("The archive " + Formatting.LeftToRight("/archive") + " is read-only.",
|
||||
ArchiveFailures.Cause(new ArchiveOfflineException("/archive", ArchiveAvailability.ReadOnly)));
|
||||
Assert.Equal("Titano was denied access to the archive.", ArchiveFailures.Cause(new UnauthorizedAccessException("Access to '/x' is denied.")));
|
||||
Assert.Equal("The index could not be read or written.", ArchiveFailures.Cause(new DatabaseConnectionException("socket closed")));
|
||||
Assert.Equal("The sequence is no longer in the index.", ArchiveFailures.Cause(new ArgumentException("Unknown sequence 42.")));
|
||||
Assert.Equal("A file of the archive could not be read or written.", ArchiveFailures.Cause(new IOException("The device is not ready.")));
|
||||
Assert.Equal(Loc.L("Archive.Error.StalePlan"), ArchiveFailures.Cause(new StaleRenamePlanException(Guid.NewGuid())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TreeRowsShowTheirWholeTitleAndTheKeysOfTheReadingDirection()
|
||||
{
|
||||
var harbour = Seq("Construction cam · weekly", new DateTime(2026, 9, 28), 3_600, 72_000_000_000);
|
||||
var tree = ArchiveTree.Build(Main, ArchiveAvailability.Online, [harbour]);
|
||||
var year = new ArchiveTreeRowViewModel(tree.Root.Children[0], ArchiveAvailability.Online, _ => { });
|
||||
var sequence = new ArchiveTreeRowViewModel(tree.Root.Children[0].Children[0], ArchiveAvailability.Online, _ => { });
|
||||
Assert.Equal("Construction cam · weekly · 3,600 photos · 72 GB", sequence.RowToolTip);
|
||||
Assert.Equal("2026 · 1 sequence · 72 GB · Right arrow opens the year, Left arrow closes it", year.RowToolTip);
|
||||
try
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("he"));
|
||||
Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", "2026 · " + year.Detail), year.RowToolTip, "the arrow keys of a mirrored tree");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -257,6 +334,11 @@ public sealed class ArchiveLogicTests
|
||||
Assert.Equal("2 photos not in sidecar", orphans[0].Detail);
|
||||
Assert.Equal(a.Id, orphans[0].SequenceId);
|
||||
Assert.Null(orphans[2].SequenceId);
|
||||
// Folders stay left to right inside right-to-left text.
|
||||
Assert.Equal("No sidecar in " + Formatting.LeftToRight("2024/Gone"), orphans[1].Detail);
|
||||
Assert.Equal(Formatting.LeftToRight("2026/New shoot"), orphans[2].Title);
|
||||
Assert.True(duplicates.Single().Places[1].EndsWith(Formatting.LeftToRight(b.Folder + "/originals/IMG_9.CR2"), StringComparison.Ordinal),
|
||||
"a duplicate's path stays left to right");
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var jobs = new[]
|
||||
@@ -267,7 +349,9 @@ public sealed class ArchiveLogicTests
|
||||
var recent = MaintenanceReports.Recent(jobs, 5);
|
||||
Assert.Equal("Verify · TitanoArchive", recent[0].Text);
|
||||
Assert.Equal("71 %", recent[0].StateText);
|
||||
Assert.Equal(StatusKind.Running, recent[0].StateKind);
|
||||
Assert.Equal(JobState.Done, recent[1].State);
|
||||
Assert.Equal(StatusKind.Done, recent[1].StateKind, "a finished run is a green dot, a failed one a red cross");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user