refactor!: rename Titano to Chronos and move CI and releases to Gitea
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s

The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout. The release cross-compiles the Windows programs, checks their
  icon, version and DPI manifest, packs installers and zips, publishes the
  Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only
  tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow) and
  pe-check.

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-23 11:34:48 +02:00
1 parent c99842cc86
commit 5f27a86406
1799 files changed
+11728 -10668

No files matched your search

@@ -0,0 +1,61 @@
using System.Globalization;
using Chronos.App.Archiving;
using Chronos.Core.Archiving;
using Chronos.Core.Localization;
using Chronos.Testing;
using static Chronos.App.Tests.Archiving.ArchiveLogicTests;
namespace Chronos.App.Tests.Archiving;
/// <summary>
/// Archive texts in other languages. They switch the process-wide UI language, so the class is serial: in parallel it
/// would race with the English assertions of the classes running beside it.
/// </summary>
[Serial]
public sealed class ArchiveLanguageTests
{
public ArchiveLanguageTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
[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 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" + Loc.Separator + year.Detail), year.RowToolTip, "the arrow keys of a mirrored tree");
Assert.Contains("\u200F", year.RowToolTip, "right-to-left marks keep the year and its figures apart");
}
finally
{
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
}
}
}
@@ -0,0 +1,339 @@
using System.Globalization;
using System.IO;
using Chronos.App.Archiving;
using Chronos.App.Infrastructure;
using Chronos.App.Library;
using Chronos.Core.Archiving;
using Chronos.Core.Imaging;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data;
using Chronos.Data.Archiving;
using Chronos.Data.Repositories;
using Chronos.Testing;
using Chronos.Ui.Controls;
namespace Chronos.App.Tests.Archiving;
public sealed class ArchiveLogicTests
{
internal static readonly Core.Model.Archive Main = new() { Id = Guid.CreateVersion7(), Name = "ChronosArchive", RootPath = "/archive" };
public ArchiveLogicTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
internal static Sequence Seq(string title, DateTime? first, int frames = 100, long bytes = 1_000_000, params string[] tags) => new()
{
Id = Guid.CreateVersion7(),
ArchiveId = Main.Id,
Title = title,
Folder = $"{first?.Year.ToString(CultureInfo.InvariantCulture) ?? "misc"}/{title}",
FirstCapture = first,
FrameCount = frames,
TotalBytes = bytes,
Tags = tags,
};
[Test]
public void TheTreeGroupsByYearNewestFirstWithUndatedLast()
{
var a = Seq("Harbour", new DateTime(2026, 9, 28), 3_600, 72_000_000_000);
var b = Seq("Comet", new DateTime(2026, 8, 13));
var c = Seq("Stars", new DateTime(2025, 8, 2));
var d = Seq("Scans", null);
var tree = ArchiveTree.Build(Main, ArchiveAvailability.Online, [c, d, b, a]);
Assert.Equal("ChronosArchive", tree.Root.Title);
Assert.SequenceEqual(new[] { "2026", "2025", "Undated" }, tree.Root.Children.Select(n => n.Title));
Assert.SequenceEqual(new[] { "Harbour", "Comet" }, tree.Root.Children[0].Children.Select(n => n.Title));
Assert.Equal("3,600 photos · 72 GB", tree.Root.Children[0].Children[0].Detail);
Assert.Equal("2 sequences · 72 GB", tree.Root.Children[0].Detail);
// Collapsed years show only themselves; expanding one reveals its sequences.
Assert.Equal(4, tree.Visible().Count);
tree.Root.Children[1].IsExpanded = true;
Assert.SequenceEqual(new[] { "ChronosArchive", "2026", "2025", "Stars", "Undated" }, tree.Visible().Select(n => n.Title));
var expanded = tree.ExpandedKeys();
var rebuilt = ArchiveTree.Build(Main, ArchiveAvailability.ReadOnly, [a, b, c, d]);
rebuilt.Expand(expanded);
Assert.Equal(5, rebuilt.Visible().Count);
Assert.Equal(ArchiveAvailability.ReadOnly, rebuilt.Availability);
}
[Test]
public void TheMassOperationSetIsTheSelectionOrEverything()
{
var a = Seq("Harbour", new DateTime(2026, 9, 28));
var b = Seq("Comet", new DateTime(2026, 8, 13));
var c = Seq("Stars", new DateTime(2025, 8, 2));
var tree = ArchiveTree.Build(Main, ArchiveAvailability.Online, [a, b, c]);
Assert.Equal(3, ArchiveTree.SetOf(tree, []).Count);
var year = tree.Root.Children[0];
Assert.SequenceEqual(new[] { a.Id, b.Id }, ArchiveTree.SetOf(tree, [year]).Select(s => s.Id));
// A year and one of its sequences count that sequence once.
Assert.Equal(2, ArchiveTree.SetOf(tree, [year, year.Children[1]]).Count);
Assert.Equal(3, ArchiveTree.SetOf(tree, [tree.Root]).Count);
}
private static ArchiveStats Stats() => new(
Sequences: 12,
Photos: 10_000,
Bytes: 9_400_000_000_000,
ByYear: [new YearBucket(2026, 8, 6_000, 2_100_000_000_000), new YearBucket(2024, 4, 4_000, 1_400_000_000_000)],
ByMonth: [new MonthBucket(2024, 3, 2, 1_000), new MonthBucket(2026, 7, 5, 5_000), new MonthBucket(2026, 9, 1, 2_000)],
ByCamera:
[
new CameraBucket("Canon", "Canon EOS R5", 4, 4_100, 0),
new CameraBucket("SONY", "ILCE-7M4", 2, 2_200, 0),
new CameraBucket("NIKON CORPORATION", "NIKON Z 8", 2, 1_400, 0),
new CameraBucket("GoPro", "HERO12 Black", 1, 900, 0),
new CameraBucket("Apple", "iPhone 16 Pro", 1, 600, 0),
new CameraBucket("DJI", "Osmo Action 5 Pro", 1, 500, 0),
new CameraBucket(null, null, 1, 300, 0),
],
ByFormat:
[
new FormatBucket(ImageFileFormat.Cr2, 3_800, 0),
new FormatBucket(ImageFileFormat.Arw, 2_100, 0),
new FormatBucket(ImageFileFormat.Jpeg, 2_000, 0),
new FormatBucket(ImageFileFormat.Nef, 1_400, 0),
new FormatBucket(ImageFileFormat.Dng, 400, 0),
new FormatBucket(ImageFileFormat.Heif, 200, 0),
new FormatBucket(ImageFileFormat.ThreeFr, 60, 0),
new FormatBucket(ImageFileFormat.Unknown, 40, 0),
],
Health: new ArchiveHealth(Unverified: 3, WithWarnings: 1, WithErrors: 0, NotAnalyzed: 2, MissingFrames: 0, CorruptFrames: 0, DuplicateFrames: 5));
[Test]
public void TheSetFilterNarrowsByCameraStatusAndTag()
{
var canon = Seq("Harbour", new DateTime(2026, 9, 28), tags: "sunset") with
{
CameraMake = "Canon",
CameraModel = "Canon EOS R5",
Status = SequenceStatus.AnalyzedLight | SequenceStatus.ProxiesBuilt,
};
var sony = Seq("Comet", new DateTime(2026, 8, 13), tags: "night") with { CameraMake = "SONY", CameraModel = "ILCE-7M4" };
var unknown = Seq("Old", null);
Assert.True(new ArchiveSetFilter().IsEmpty);
Assert.True(new ArchiveSetFilter().Matches(unknown), "no filter keeps everything");
var byCamera = new ArchiveSetFilter(Camera: ArchiveSetFilter.CameraOf(canon));
Assert.True(byCamera.Matches(canon));
Assert.False(byCamera.Matches(sony));
Assert.Equal(Loc.L("Archive.Chart.UnknownCamera"), ArchiveSetFilter.CameraOf(unknown));
Assert.True(new ArchiveSetFilter(Status: StatusFilter.NotAnalysed).Matches(sony));
Assert.False(new ArchiveSetFilter(Status: StatusFilter.NotAnalysed).Matches(canon));
Assert.True(new ArchiveSetFilter(Status: StatusFilter.Proxies).Matches(canon));
Assert.True(new ArchiveSetFilter(Tag: "SUNSET").Matches(canon), "tags compare without case");
Assert.False(new ArchiveSetFilter(Tag: "sunset").Matches(sony));
Assert.Equal(ArchiveSetFilter.CameraOf(canon) + " · Not analysed · sunset",
new ArchiveSetFilter(ArchiveSetFilter.CameraOf(canon), StatusFilter.NotAnalysed, "sunset").Describe());
Assert.Equal(string.Empty, new ArchiveSetFilter().Describe());
}
[Test]
public void ChartsAggregateYearsCamerasAndFormats()
{
var stats = Stats();
var years = ArchiveFigures.StorageByYear(stats);
Assert.SequenceEqual(new[] { "2024", "2026" }, years.Select(b => b.Label));
Assert.Equal("2.1 TB", years[1].ValueText);
var cameras = ArchiveFigures.ByCamera(stats);
Assert.Equal(ArchiveFigures.TopCameras + 1, cameras.Count);
Assert.Equal("Canon EOS R5", cameras[0].Label);
Assert.Equal("41 %", cameras[0].ValueText);
Assert.Equal("SONY ILCE-7M4", cameras[1].Label);
Assert.Equal("Nikon Z 8", cameras[2].Label);
Assert.Equal("2 others", cameras[^1].Label);
Assert.Equal(800, cameras[^1].Value);
Assert.Equal(stats.Photos, (long)cameras.Sum(c => c.Value));
var formats = ArchiveFigures.ByFormat(stats);
Assert.SequenceEqual(new[] { "CR2", "ARW", "JPEG", "NEF", "DNG", "HEIF", "Other" }, formats.Select(f => f.Label));
Assert.Equal(100, formats[^1].Value);
Assert.Equal("3FR", ArchiveFigures.FormatName(ImageFileFormat.ThreeFr));
}
[Test]
public void ThePhotosPerMonthHeatmapHasOneRowPerYearAndNoFuture()
{
var rows = ArchiveFigures.PhotosPerMonth(Stats(), new DateTime(2026, 10, 2));
Assert.SequenceEqual(new[] { "2024", "2025", "2026" }, rows.Select(r => r.Label));
Assert.Equal(1_000, rows[0].Values[2]);
Assert.Equal(0, rows[1].Values[5]);
Assert.Equal(5_000, rows[2].Values[6]);
Assert.Equal(0, rows[2].Values[9]);
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.Empty(ArchiveFigures.PhotosPerMonth(Stats() with { ByMonth = [] }, DateTime.Today));
}
[Test]
public void TilesAndHealthSummariseTheIndex()
{
var tiles = ArchiveFigures.Tiles(Stats());
Assert.Equal(5, tiles.Count);
Assert.Equal("10,000", tiles[0].Value);
Assert.Equal("9.4 TB", tiles[2].Value);
Assert.Equal("6", tiles[3].Value);
Assert.Equal("cameras · 8 formats", tiles[3].Caption);
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);
Assert.False(health[0].IsOk);
Assert.Equal("3 sequences unverified", health[0].Text);
Assert.True(health[1].IsOk);
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("Chronos 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 RenameTemplatesAreCheckedAndThePlanListedByMode()
{
Assert.Null(MassRename.Validate(RenameMode.Titles, "{title} · {camera}"));
Assert.NotNull(MassRename.Validate(RenameMode.Titles, "{title"));
Assert.NotNull(MassRename.Validate(RenameMode.Titles, " "));
Assert.Null(MassRename.Validate(RenameMode.Folders, "{year}/{date} {title}"));
Assert.NotNull(MassRename.Validate(RenameMode.Folders, "{nope}"));
var a = Seq("Harbour", new DateTime(2026, 9, 28));
var b = Seq("Comet", new DateTime(2026, 8, 13));
var subjects = new[] { a, b }.Select(s => new RenameSubject(s.Id, s.Folder, s.Title, s.FirstCapture, "Canon", "Canon EOS R5", null)).ToList();
var titles = RenamePlanner.Plan(Main.Id, subjects, null, "{title} · {camera}", subjects.Select(s => s.Folder), _ => false);
var rows = MassRename.Rows(titles, RenameMode.Titles);
Assert.Equal("Harbour", rows[0].From);
Assert.Equal("Harbour · Canon EOS R5", rows[0].To);
Assert.Equal("2 of 5 change", MassRename.Summary(titles, 5));
Assert.Empty(RenamePlanner.Plan(Main.Id, subjects, "{year}/{title}", null, subjects.Select(s => s.Folder), _ => false).Steps);
var folders = RenamePlanner.Plan(Main.Id, subjects, "{year}/{date} {title}", null, subjects.Select(s => s.Folder), _ => false);
var moves = MassRename.Rows(folders, RenameMode.Folders);
Assert.SequenceEqual(new[] { "2026/Harbour", "2026/Comet" }, moves.Select(r => r.From));
Assert.SequenceEqual(new[] { "2026/2026-09-28 Harbour", "2026/2026-08-13 Comet" }, moves.Select(r => r.To));
}
[Test]
public void RetagAddsAndRemovesWithoutDuplicates()
{
Assert.SequenceEqual(new[] { "sunset", "harbour", "Holy grail" }, Retag.Parse(" sunset, harbour; Holy grail ,SUNSET"));
Assert.Empty(Retag.Parse(" "));
Assert.Null(Retag.Validate("sunset, dusk"));
Assert.NotNull(Retag.Validate(new string('x', 65)));
Assert.Empty(Retag.Parse(new string('x', 65)));
Assert.SequenceEqual(new[] { "harbour", "dusk" }, Retag.Apply(["Sunset", "harbour"], ["dusk", "HARBOUR"], ["sunset"]));
var a = Seq("A", DateTime.Today, tags: ["sunset"]);
var b = Seq("B", DateTime.Today, tags: ["dusk"]);
var changes = Retag.Changes([a, b], ["dusk"], []);
Assert.Equal(a.Id, changes.Single().Sequence.Id);
Assert.SequenceEqual(new[] { "sunset", "dusk" }, changes.Single().Tags);
}
[Test]
public void ReportsListDuplicatesOrphansAndRecentMaintenance()
{
var a = Seq("Harbour", new DateTime(2026, 9, 28));
var b = Seq("Comet", new DateTime(2026, 8, 13));
var locations = new[] { new SequenceLocation(a.Id, a.Folder, a.Title), new SequenceLocation(b.Id, b.Folder, null) };
var groups = new[]
{
new DuplicateGroup("ab", [new DuplicateFrame("ab", Guid.NewGuid(), a.Id, 0, a.Folder + "/originals/IMG_1.CR2"),
new DuplicateFrame("ab", Guid.NewGuid(), b.Id, 4, b.Folder + "/originals/IMG_9.CR2")]),
new DuplicateGroup("cd", [new DuplicateFrame("cd", Guid.NewGuid(), a.Id, 1, a.Folder + "/originals/IMG_2.CR2")]),
};
var duplicates = MaintenanceReports.Duplicates(groups, locations);
Assert.Equal("IMG_1.CR2", duplicates.Single().Title);
Assert.Equal("2 copies", duplicates.Single().Detail);
Assert.Equal(a.Id, duplicates.Single().SequenceId);
Assert.Contains("Comet", duplicates.Single().Places[1]);
var report = new OrphanReport(
[new SequenceOrphans(a.Folder, ["IMG_7.CR2", "IMG_8.CR2"], [])],
[new SequenceLocation(Guid.NewGuid(), "2024/Gone", "Gone")],
["2026/New shoot"]);
var orphans = MaintenanceReports.Orphans(report, locations);
Assert.SequenceEqual(new[] { OrphanKind.UnlistedFiles, OrphanKind.MissingSequence, OrphanKind.NewFolder }, orphans.Select(o => o.Kind));
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[]
{
new Job { Id = Guid.NewGuid(), Kind = JobKind.Verify, State = JobState.Running, ProgressDone = 71, ProgressTotal = 100, TargetLabel = "ChronosArchive", Created = now },
new Job { Id = Guid.NewGuid(), Kind = JobKind.Scan, State = JobState.Done, Created = now.AddDays(-2), Finished = now.AddDays(-2) },
};
var recent = MaintenanceReports.Recent(jobs, 5);
Assert.Equal("Verify · ChronosArchive", 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");
// The row shows a running job's percentage, so its tooltip names the state first; a finished one has no run time to explain.
Assert.Equal(string.Join(Loc.Separator, Loc.L("Jobs.State.Running"), Loc.L("Tooltips.Jobs.State.Running")), recent[0].StateToolTip);
Assert.Equal(Loc.L("Jobs.State.Done"), recent[1].StateToolTip);
}
[Test]
public void TheScreensWorkOnTheRememberedArchiveElseTheFirst()
{
var other = Main with { Id = Guid.CreateVersion7(), Name = "Travel", RootPath = "/media/travel" };
Assert.Null(CurrentArchive.Pick([], "/archive"));
Assert.Equal(other.Id, CurrentArchive.Pick([Main, other], "/media/travel/")!.Id);
Assert.Equal(Main.Id, CurrentArchive.Pick([Main, other], "/elsewhere")!.Id);
Assert.Equal(Main.Id, CurrentArchive.Pick([Main, other], null)!.Id);
}
[Test]
public void TheSampleReportsFillEveryKindOfReportRow()
{
var locations = Enumerable.Range(1, 6).Select(i => new SequenceLocation(Guid.CreateVersion7(), $"2026/Shoot {i}", $"Shoot {i}")).ToList();
Assert.Equal("2 copies", MaintenanceReports.Duplicates(SampleReports.Duplicates(locations), locations).Single().Detail);
Assert.SequenceEqual(new[] { OrphanKind.UnlistedFiles, OrphanKind.MissingSequence, OrphanKind.NewFolder },
MaintenanceReports.Orphans(SampleReports.Orphans(locations), locations).Select(o => o.Kind));
var folders = SampleReports.Folders(locations);
Assert.Equal(4, folders.Count(f => f.Sidecar is not null));
Assert.Equal(2, folders.Count(f => f.Sidecar is null));
}
}
@@ -0,0 +1,360 @@
using System.IO;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using Chronos.App.Archiving;
using Chronos.App.Infrastructure;
using Chronos.App.Sections;
using Chronos.App.Shell;
using Chronos.App.Tests.Windows;
using Chronos.Core.Archiving;
using Chronos.Core.Localization;
using Chronos.Testing;
using Chronos.Ui.Controls;
namespace Chronos.App.Tests.Archiving;
/// <summary>
/// Every Archive view of <c>--capture</c> (<see cref="ArchiveScenes"/>) on the sample archive, rendered in both themes
/// in the real main window, with what each view must show — the buttons really enabled and named for screen readers,
/// keyboard focus visible, no error or busy state left over — and paths and templates readable in a right-to-left
/// language.
/// </summary>
[WindowsOnly]
[Serial]
[Timeout(300_000)]
public sealed class ArchiveScreenSmokeTests
{
[Test]
public Task EveryArchiveViewRendersInBothThemes() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
var archive = app.Shell.Archive;
await ArchiveScenes.ShowAsync(app.Shell, "overview");
Assert.True(archive.IsOverview);
Assert.True(archive.TreeRows[0].IsArchive);
Assert.Equal(StatusKind.Online, archive.TreeRows[0].AvailabilityKind);
Assert.True(archive.TreeRows[1].IsYear);
Assert.True(archive.TreeRows[1].IsExpanded, "the newest year opens with the screen");
Assert.Equal(5, archive.Tiles.Count);
Assert.Equal(2, archive.MonthRows.Count, "one heatmap row per year, 2025 and 2026");
Assert.NotEmpty(archive.StorageBars);
Assert.NotEmpty(archive.CameraBars);
Assert.NotEmpty(archive.FormatBars);
Assert.True(archive.HasMonthScale, "the heatmap's scale sits in its header");
Assert.Contains(archive.CameraBars[0].ToolTip!, archive.CamerasDescription);
Assert.True(archive.ScanCommand.CanExecute(null), "an online archive can be scanned");
await app.ExpectAsync<ArchiveView>("archive-overview");
Assert.True(ButtonFor(app, archive.ScanCommand).IsEnabled, "the Scan button is enabled once the archive is read");
Assert.True(ButtonFor(app, archive.AnalyseSetCommand).IsEnabled, "mass operations are enabled on the whole archive");
AssertEveryButtonIsNamed(app);
Assert.Contains(archive.SetText, AutomationProperties.GetName(SetButton(app)));
foreach (var row in TreeItems(app)) Assert.NotNull(row.FocusVisualStyle, "a tree row shows keyboard focus");
Assert.Equal(Loc.L("Archive.Tree.Collapse"), AutomationProperties.GetName(ButtonFor(app, archive.TreeRows[1].ToggleCommand)),
"the open year's expander has a short name; the sentence is its tooltip");
var sequence = archive.TreeRows.First(r => r.Node.Kind == TreeNodeKind.Sequence);
Assert.Contains(sequence.Title, sequence.RowToolTip);
// Expanding another year keeps the selection: the set stays what the user chose.
var year = archive.TreeRows[1];
var tree = Tree(app);
tree.SelectedItems.Add(year);
var chosen = archive.SetText;
archive.Toggle(archive.TreeRows.Last(r => r.IsYear));
Assert.Equal(chosen, archive.SetText, "opening a year does not change the set");
Assert.True(tree.SelectedItems.Cast<ArchiveTreeRowViewModel>().Any(r => r.Node.Key == year.Node.Key), "the list shows the same selection");
tree.SelectedItems.Clear();
await ArchiveScenes.ShowAsync(app.Shell, "maintenance");
Assert.True(archive.IsMaintenance);
Assert.Equal(5, archive.Health.Count);
Assert.Equal(1, archive.Duplicates!.Count);
Assert.Equal(3, archive.Orphans!.Count, "unlisted photos, a row without sidecar, a folder not indexed");
var duplicatesLine = archive.Health[4].Line;
Assert.False(duplicatesLine.IsOk, "index health agrees with the duplicate groups listed beside it");
Assert.Equal(HealthAction.MarkDuplicates, duplicatesLine.Action);
await app.ExpectAsync<ArchiveView>("archive-maintenance");
Assert.False(app.FindAll<Button>().Any(b => b.IsVisible && ReferenceEquals(b.Command, archive.CancelSearchCommand)), "no Cancel without a search");
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(TextFor(app, archive.DuplicatesText)), "search results are announced");
AssertEveryButtonIsNamed(app);
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
var rebuild = Assert.NotNull(archive.Dialog as RebuildDialogViewModel);
Assert.True(rebuild.RebuildCommand.CanExecute(null));
Assert.False(archive.IsContentEnabled, "the screen behind a dialog takes no input");
Assert.False(rebuild.FactRows.Any(f => f.Value == Loc.L("Archive.Rebuild.Counting")), "counted, the facts no longer say Counting…");
await app.ExpectAsync<ArchiveView>("archive-rebuild");
Assert.False(tree.IsEnabled);
var frame = Assert.NotNull(VisualTreeHelper.GetChild(tree, 0) as Border);
Assert.Equal(0, ((SolidColorBrush)frame.Background).Color.A, "the disabled tree keeps its panel's fill instead of the system's white");
AssertNoErrorShown(app);
await ArchiveScenes.ShowAsync(app.Shell, "move");
var move = Assert.NotNull(archive.Dialog as RenameDialogViewModel);
Assert.NotEmpty(move.Rows, "the dry run lists the folders that change");
Assert.Null(move.ErrorText);
await app.ExpectAsync<ArchiveView>("archive-move");
Assert.True(ButtonFor(app, move.ApplyCommand).IsEnabled, "Apply follows the dry run");
Assert.True(ButtonFor(app, move.CloseCommand).IsDefault, "Enter takes the safe way out");
AssertNoErrorShown(app);
AssertEveryButtonIsNamed(app);
move.CloseCommand.Execute(null);
archive.RetagSetCommand.Execute(null);
var retag = Assert.NotNull(archive.Dialog as RetagDialogViewModel);
retag.Add.Text = "sunset";
await app.ExpectAsync<ArchiveView>("archive-retag");
Assert.True(ButtonFor(app, retag.ApplyCommand).IsEnabled, "Apply follows the typed tags");
AssertNoErrorShown(app);
retag.CloseCommand.Execute(null);
});
[Test]
public Task PathsTemplatesAndMonthsStayReadableRightToLeft() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
UiLanguage.Apply("ar");
try
{
var archive = app.Shell.Archive;
await ArchiveScenes.ShowAsync(app.Shell, "overview");
Assert.Equal(12.ToString("N0", Loc.Culture), archive.MonthLabels[^1], "Arabic month names have no initials: the columns are numbered");
var year = archive.TreeRows[1];
Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", year.Title + Loc.Separator + year.Detail), year.RowToolTip, "the tooltip names the mirrored arrow keys");
await app.ExpectAsync<ArchiveView>("archive-overview-ar");
// The dialogs' templates exist once they are laid out: render first, then look inside.
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
await app.ExpectAsync<ArchiveView>("archive-rebuild-ar");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, archive.SelectedArchive!.RootPath).FlowDirection, "the archive folder reads left to right");
await ArchiveScenes.ShowAsync(app.Shell, "move");
var move = Assert.NotNull(archive.Dialog as RenameDialogViewModel);
await app.ExpectAsync<ArchiveView>("archive-move-ar");
var template = Assert.NotNull(app.FindAll<TextBox>().FirstOrDefault(t => t.IsVisible && EditBehavior.GetField(t) == move.Template));
Assert.Equal(FlowDirection.LeftToRight, template.FlowDirection, "the naming template reads left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, move.Rows[0].From).FlowDirection, "a folder before the move reads left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, move.Rows[0].To).FlowDirection, "a folder after the move reads left to right");
move.CloseCommand.Execute(null);
}
finally
{
UiLanguage.Apply("en");
}
});
[Test]
public async Task RebuildCountsSayWhyInsteadOfCountingForever()
{
var offline = new RebuildDialogViewModel(Archive("/nowhere"), ArchiveAvailability.Offline, 3, () => Task.CompletedTask, _ => { });
await offline.CountAsync();
var sidecars = Fact(offline, "Archive.Rebuild.Sidecars");
Assert.Equal("—", sidecars.Value);
Assert.Equal(Loc.L("Archive.Error.Offline", Formatting.LeftToRight("/nowhere")), sidecars.ToolTip);
Assert.True(Fact(offline, "Archive.Rebuild.Root").IsPath, "the archive folder is shown left to right");
var missing = Path.Combine(Path.GetTempPath(), "chronos-missing-" + Guid.NewGuid().ToString("N"));
var unreadable = new RebuildDialogViewModel(Archive(missing), ArchiveAvailability.Online, 3, () => Task.CompletedTask, _ => { });
await unreadable.CountAsync();
Assert.Equal("—", Fact(unreadable, "Archive.Rebuild.Metadata").Value);
Assert.Equal(Loc.L("Archive.Failed.Files"), Fact(unreadable, "Archive.Rebuild.Metadata").ToolTip);
Assert.Null(unreadable.BusyText, "nothing is counting any more");
static Core.Model.Archive Archive(string root) => new() { Id = Guid.CreateVersion7(), Name = "ChronosArchive", RootPath = root };
static DialogFact Fact(RebuildDialogViewModel dialog, string label) => dialog.FactRows.Single(f => f.Label == Loc.L(label));
}
/// <summary>
/// Picking another archive while one is being read shows the picked one: the read in progress is followed by one of
/// the new archive, and meanwhile nothing of the previous archive's tree can be acted on.
/// </summary>
[Test]
public Task PickingAnotherArchiveDuringAReadShowsThePickedOne() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
var archive = app.Shell.Archive;
await ArchiveScenes.ShowAsync(app.Shell, "overview");
Assert.Contains(archive.TreeRows, r => r.Node.Kind == TreeNodeKind.Sequence);
Assert.NotEmpty(archive.Tiles);
Assert.NotEmpty(archive.CameraBars);
var first = archive.SelectedArchive!;
var second = await app.Services.Archives!.CreateAsync(Path.Combine(app.Services.Environment.DataDirectory, "second-archive"), "Second");
var reading = archive.LoadAsync();
archive.SelectedArchive = second;
Assert.Empty(archive.TreeRows);
// None of the first archive's figures stays on screen under the picked one's name while it is read (or if its read fails).
Assert.Empty(archive.Tiles);
Assert.Empty(archive.MonthRows);
Assert.Empty(archive.StorageBars);
Assert.Empty(archive.CameraBars);
Assert.Empty(archive.FormatBars);
Assert.Empty(archive.Recent);
Assert.False(archive.HasRecent);
Assert.Equal(string.Empty, archive.LastScanText);
Assert.Equal(0, archive.Badge, "the rail badge counts the picked archive's health, which is not read yet");
Assert.False(archive.AnalyseSetCommand.CanExecute(null), "nothing of the first archive can be acted on while the picked one is read");
Assert.False(archive.ScanCommand.CanExecute(null), "the picked archive is not known to be online yet");
Assert.Equal(Loc.L("Archive.Blocked.Reading"), archive.ScanToolTip, "not yet read is not offline");
Assert.False(archive.RebuildCommand.CanExecute(null), "the rebuild dialog waits for the picked archive's own state and figures");
Assert.Null(await archive.OpenRebuildDialogAsync());
Assert.Empty(archive.Health);
// Back to the first archive before the picked one is read: it was read before, but none of its figures is left.
archive.SelectedArchive = first;
Assert.Empty(archive.TreeRows);
Assert.False(archive.RebuildCommand.CanExecute(null), "the first archive is not read again yet");
Assert.False(archive.ScanCommand.CanExecute(null));
Assert.Equal(Loc.L("Archive.Blocked.Reading"), archive.ScanToolTip);
Assert.Null(await archive.OpenRebuildDialogAsync());
archive.SelectedArchive = second;
await reading;
Assert.Equal(second.Id, archive.SelectedArchive!.Id);
Assert.Contains(archive.Archives, a => a.Id == second.Id);
Assert.True(archive.TreeRows[0].IsArchive);
Assert.False(archive.TreeRows.Any(r => r.Node.Kind == TreeNodeKind.Sequence), "the tree is the picked, empty archive's");
Assert.True(archive.ScanCommand.CanExecute(null), "the picked archive was probed: it is online");
Assert.Equal(Loc.L("Tooltips.Archive.Scan"), archive.ScanToolTip);
Assert.True(archive.RebuildCommand.CanExecute(null));
var rebuild = Assert.NotNull(await archive.OpenRebuildDialogAsync());
Assert.Equal(second.Id, rebuild.Archive.Id);
Assert.Equal(ArchiveAvailability.Online, rebuild.Availability, "the dialog shows the picked archive's availability");
Assert.Equal(0, rebuild.Indexed, "and its own index, not the first archive's");
rebuild.CloseCommand.Execute(null);
});
[Test]
public void TheArrowTowardsTheIndentOpensAYearInEitherDirection()
{
Assert.True(ArchiveView.Toggles(Key.Right, FlowDirection.LeftToRight, isExpanded: false));
Assert.False(ArchiveView.Toggles(Key.Right, FlowDirection.LeftToRight, isExpanded: true));
Assert.True(ArchiveView.Toggles(Key.Left, FlowDirection.LeftToRight, isExpanded: true));
Assert.True(ArchiveView.Toggles(Key.Left, FlowDirection.RightToLeft, isExpanded: false), "a mirrored tree opens with Left");
Assert.True(ArchiveView.Toggles(Key.Right, FlowDirection.RightToLeft, isExpanded: true), "and closes with Right");
Assert.False(ArchiveView.Toggles(Key.Right, FlowDirection.RightToLeft, isExpanded: false));
Assert.True(ArchiveView.Toggles(Key.Enter, FlowDirection.RightToLeft, isExpanded: true));
Assert.False(ArchiveView.Toggles(Key.Down, FlowDirection.LeftToRight, isExpanded: false));
}
/// <summary>Every button of the screen has a name screen readers can announce, menu buttons with drawn chevrons included.</summary>
private static void AssertEveryButtonIsNamed(ScreenSmokeTests.SampleApp app)
{
foreach (var button in app.FindAll<ButtonBase>().Where(b => b.IsVisible && b.Focusable && IsInArchive(b)))
{
var name = AutomationProperties.GetName(button);
if (string.IsNullOrEmpty(name)) name = button.Content as string;
Assert.False(string.IsNullOrWhiteSpace(name), $"{button.GetType().Name} '{button.Name}' bound to {button.Command} has no accessible name");
}
}
/// <summary>
/// Beside the 200 px rail at the 1200 px minimum (owner review 1, R1), in every shipped language: a year row shows its year
/// whole (its figures give way, and stay inside the row).
/// </summary>
[Test]
public Task YearRowsKeepTheirYearAtTheMinimumWidthInEveryLanguage() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
await ArchiveScenes.ShowAsync(app.Shell, "overview");
var window = app.Window;
window.Width = 1200;
window.Height = 788;
try
{
foreach (var language in Languages.Shipped)
{
UiLanguage.Apply(language);
window.UpdateLayout();
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
var years = TreeItems(app).Where(i => ((ArchiveTreeRowViewModel)i.DataContext).IsYear).ToList();
Assert.True(years.Count > 0, $"{language}: year rows show");
foreach (var item in years)
{
var row = (ArchiveTreeRowViewModel)item.DataContext;
var texts = Descendants<TextBlock>(item).Where(t => t.IsVisible).ToList();
var title = texts.Single(t => t.Text == row.Title);
// A copy with the same font, measured by the same layout engine, needs no more room than the year got (layout
// rounding aside: a cut year keeps barely half of it).
var probe = new TextBlock
{
Text = title.Text,
FontFamily = title.FontFamily,
FontSize = title.FontSize,
FontStyle = title.FontStyle,
FontWeight = title.FontWeight,
FontStretch = title.FontStretch,
FlowDirection = title.FlowDirection,
Language = title.Language,
};
TextOptions.SetTextFormattingMode(probe, TextOptions.GetTextFormattingMode(title));
probe.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
Assert.True(probe.DesiredSize.Width <= title.ActualWidth + 1, $"{language}: the year '{row.Title}' is cut ({title.ActualWidth:0} of {probe.DesiredSize.Width:0} px)");
var (left, right) = Span(item, window);
foreach (var text in texts)
{
var (start, end) = Span(text, window);
Assert.True(start >= left - 0.5 && end <= right + 0.5, $"{language}: '{text.Text}' spans {start:0}–{end:0} px, its row {left:0}–{right:0} px");
}
}
}
}
finally
{
UiLanguage.Apply("en");
}
});
/// <summary>The left and right edges of an element in window coordinates, whichever way the window reads.</summary>
private static (double Left, double Right) Span(FrameworkElement element, Window window)
{
var a = element.TranslatePoint(new Point(0, 0), window).X;
var b = element.TranslatePoint(new Point(element.ActualWidth, 0), window).X;
return (Math.Min(a, b), Math.Max(a, b));
}
private static IEnumerable<T> Descendants<T>(DependencyObject node)
where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
{
var child = VisualTreeHelper.GetChild(node, i);
if (child is T match) yield return match;
foreach (var nested in Descendants<T>(child)) yield return nested;
}
}
/// <summary>A dialog that has not failed shows no error line.</summary>
private static void AssertNoErrorShown(ScreenSmokeTests.SampleApp app) =>
Assert.False(app.FindAll<StatusGlyph>().Any(g => g.IsVisible && g.Kind == StatusKind.Error && IsInArchive(g)), "no error state before anything failed");
private static ListBox Tree(ScreenSmokeTests.SampleApp app) => app.FindAll<ListBox>().Single(l => l.Name == "Tree");
private static IEnumerable<ListBoxItem> TreeItems(ScreenSmokeTests.SampleApp app) =>
app.FindAll<ListBoxItem>().Where(i => i.IsVisible && i.DataContext is ArchiveTreeRowViewModel);
private static Button SetButton(ScreenSmokeTests.SampleApp app) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => b.IsVisible && b.ToolTip as string == Loc.L("Tooltips.Archive.Set")), "the set filter button");
private static bool IsInArchive(DependencyObject element)
{
for (var node = VisualTreeHelper.GetParent(element); node is not null; node = VisualTreeHelper.GetParent(node))
{
if (node is ArchiveView) return true;
}
return false;
}
private static TextBlock TextFor(ScreenSmokeTests.SampleApp app, string text) =>
Assert.NotNull(app.FindAll<TextBlock>().FirstOrDefault(t => t.IsVisible && t.Text == text && IsInArchive(t)), $"a visible text '{text}'");
private static Button ButtonFor(ScreenSmokeTests.SampleApp app, ICommand command) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => ReferenceEquals(b.Command, command) && b.IsVisible), "a visible button bound to the command");
}