feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job. - One naming rule (FrameNaming) for import, upload and Reorganize. - Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder. - Writers refuse a folder another program moved or gave to another sequence. - Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules. - Phase 3 docs and translations merged; strings in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
1 parent
9aa818ed47
commit
7e4a3b481d
416 files changed
+15304
-1572
No files matched your search
@@ -225,28 +225,23 @@ public sealed class ArchiveLogicTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RenameTemplatesAreCheckedAndThePlanListedByMode()
|
||||
public void PlannedTitlesAndFoldersAreListedAsReorganizeRows()
|
||||
{
|
||||
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));
|
||||
var retitled = ReorganizePlans.Rows(titles).Select(r => r.Lines.Single()).ToList();
|
||||
Assert.SequenceEqual(new[] { "Harbour>Harbour · Canon EOS R5", "Comet>Comet · Canon EOS R5" }, retitled.Select(l => $"{l.From}>{l.To}"));
|
||||
Assert.False(retitled.Any(l => l.IsPath), "titles read in the language's direction");
|
||||
Assert.Equal("2 of 5 change", ReorganizePlans.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));
|
||||
var moves = ReorganizePlans.Rows(folders).Select(r => r.Lines.Single()).ToList();
|
||||
Assert.SequenceEqual(new[] { "2026/Harbour", "2026/Comet" }, moves.Select(l => l.From));
|
||||
Assert.SequenceEqual(new[] { "2026/2026-09-28 Harbour", "2026/2026-08-13 Comet" }, moves.Select(l => l.To));
|
||||
Assert.True(moves.All(l => l.IsPath), "folders read left to right");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -94,17 +94,18 @@ public sealed class ArchiveScreenSmokeTests
|
||||
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");
|
||||
await ArchiveScenes.ShowAsync(app.Shell, "reorganize");
|
||||
var reorganize = Assert.NotNull(archive.Dialog as ReorganizeDialogViewModel);
|
||||
Assert.NotEmpty(reorganize.Rows, "the dry run lists the sequences that change");
|
||||
Assert.Null(reorganize.ErrorText);
|
||||
await app.ExpectAsync<ArchiveView>("archive-reorganize");
|
||||
Assert.True(ButtonFor(app, reorganize.ApplyCommand).IsEnabled, "Apply follows the dry run");
|
||||
Assert.True(ButtonFor(app, reorganize.CloseCommand).IsDefault, "Enter takes the safe way out");
|
||||
foreach (var box in app.FindAll<CheckBox>().Where(c => c.IsVisible)) Assert.NotNull(box.ToolTip, "every template switch says what it does");
|
||||
AssertNoErrorShown(app);
|
||||
AssertEveryButtonIsNamed(app);
|
||||
|
||||
move.CloseCommand.Execute(null);
|
||||
reorganize.CloseCommand.Execute(null);
|
||||
archive.RetagSetCommand.Execute(null);
|
||||
var retag = Assert.NotNull(archive.Dialog as RetagDialogViewModel);
|
||||
retag.Add.Text = "sunset";
|
||||
@@ -134,14 +135,15 @@ public sealed class ArchiveScreenSmokeTests
|
||||
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));
|
||||
await ArchiveScenes.ShowAsync(app.Shell, "reorganize");
|
||||
var reorganize = Assert.NotNull(archive.Dialog as ReorganizeDialogViewModel);
|
||||
await app.ExpectAsync<ArchiveView>("archive-reorganize-ar");
|
||||
var template = Assert.NotNull(app.FindAll<TextBox>().FirstOrDefault(t => t.IsVisible && EditBehavior.GetField(t) == reorganize.Folders.Field));
|
||||
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);
|
||||
var folder = reorganize.Rows.SelectMany(r => r.Lines).First(l => l.IsPath);
|
||||
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, folder.From).FlowDirection, "a folder before the move reads left to right");
|
||||
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, folder.To).FlowDirection, "a folder after the move reads left to right");
|
||||
reorganize.CloseCommand.Execute(null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using Chronos.App.Archiving;
|
||||
using Chronos.App.DesignTime;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Tests.Import;
|
||||
using Chronos.App.Tests.Uploader;
|
||||
using Chronos.App.Tests.Windows;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Controls;
|
||||
|
||||
namespace Chronos.App.Tests.Archiving;
|
||||
|
||||
/// <summary>
|
||||
/// Reorganize… (owner review 2, R7): each template with its switch, the dry run listed sequence by sequence, and Apply
|
||||
/// queuing the job of exactly the plan on screen, which the job then applies.
|
||||
/// </summary>
|
||||
public sealed class ReorganizeDialogTests(TestContext context)
|
||||
{
|
||||
private static readonly DateTime Start = new(2026, 9, 28, 18, 0, 0);
|
||||
|
||||
[Test]
|
||||
public void EachTemplateIsCheckedAsItsPartIsNamed()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
Assert.Null(ReorganizePlans.Validate(ReorganizeParts.Folders, "{year}/{date} {title}"));
|
||||
Assert.NotNull(ReorganizePlans.Validate(ReorganizeParts.Folders, "{nope}"));
|
||||
Assert.Null(ReorganizePlans.Validate(ReorganizeParts.Files, "{date}_{n:000}"));
|
||||
Assert.Equal(Loc.L("Errors.Template.FileSeparator"), ReorganizePlans.Validate(ReorganizeParts.Files, "{year}/{n}"), "a file name has no folder");
|
||||
Assert.Equal(Loc.L("Errors.Template.NotUnique"), ReorganizePlans.Validate(ReorganizeParts.Files, "{date}"), "file names tell the photos apart");
|
||||
Assert.Null(ReorganizePlans.Validate(ReorganizeParts.Titles, "{title} · {camera}"));
|
||||
Assert.Null(ReorganizePlans.Validate(ReorganizeParts.Titles, "{date}"), "every photo of a sequence shares its title");
|
||||
Assert.NotNull(ReorganizePlans.Validate(ReorganizeParts.Titles, "{title"));
|
||||
foreach (var part in new[] { ReorganizeParts.Folders, ReorganizeParts.Files, ReorganizeParts.Titles })
|
||||
Assert.Equal(Loc.L("Errors.Template.Empty", string.Empty, 1), ReorganizePlans.Validate(part, " "), part.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheDryRunIsListedSequenceBySequence()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var moved = new RenameStep(Guid.CreateVersion7(), "2026/Harbour", "2026/2026-09-28 Harbour", "Harbour", "Harbour sunset")
|
||||
{
|
||||
FramesVersion = 3,
|
||||
FileChanges = 120,
|
||||
FileSamples =
|
||||
[
|
||||
new FileRename(Guid.CreateVersion7(), "originals/IMG_0001.JPG", "originals/Harbour sunset_001.JPG"),
|
||||
new FileRename(Guid.CreateVersion7(), "originals/IMG_0002.JPG", "originals/Harbour sunset_002.JPG"),
|
||||
],
|
||||
Blocked = [new RenameBlocked(RenameBlock.Unhashed, 12)],
|
||||
};
|
||||
var carried = new RenameStep(Guid.CreateVersion7(), "2026/Harbour/Night", "2026/2026-09-28 Harbour/Night", null, null, Carried: true);
|
||||
var kept = new RenameStep(Guid.CreateVersion7(), "2025/Comet", "2025/Comet", "Comet", "Comet") { Blocked = [new RenameBlocked(RenameBlock.Unreadable, 0)] };
|
||||
var plan = new RenamePlan(Guid.CreateVersion7(), Guid.CreateVersion7(), [moved, kept, carried])
|
||||
{
|
||||
FileTemplate = "{title}_{n:000}",
|
||||
Subjects = [moved.SequenceId, kept.SequenceId],
|
||||
};
|
||||
|
||||
var rows = ReorganizePlans.Rows(plan);
|
||||
|
||||
Assert.Count(3, rows);
|
||||
var first = rows[0];
|
||||
Assert.Equal("Harbour sunset", first.Name);
|
||||
Assert.False(first.IsNamePath, "a title reads in the language's direction");
|
||||
Assert.Equal(Loc.Plural("Archive.Reorganize.Renamed", 120), first.Note);
|
||||
Assert.SequenceEqual(
|
||||
[
|
||||
$"{Loc.L("Archive.Reorganize.Folder")}|2026/Harbour|2026/2026-09-28 Harbour|True",
|
||||
$"{Loc.L("Archive.Reorganize.Title")}|Harbour|Harbour sunset|False",
|
||||
$"{Loc.L("Archive.Reorganize.File")}|originals/IMG_0001.JPG|originals/Harbour sunset_001.JPG|True",
|
||||
$"{Loc.L("Archive.Reorganize.File")}|originals/IMG_0002.JPG|originals/Harbour sunset_002.JPG|True",
|
||||
],
|
||||
first.Lines.Select(l => $"{l.Label}|{l.From}|{l.To}|{l.IsPath}"));
|
||||
Assert.SequenceEqual([Loc.L("Archive.Reorganize.Blocked.Unhashed") + Loc.Separator + Loc.Plural("Shell.Status.Photos", 12)], first.Kept);
|
||||
Assert.Contains(Loc.L("Archive.Reorganize.Change", Loc.L("Archive.Reorganize.Folder"), "2026/Harbour", "2026/2026-09-28 Harbour"), first.Description);
|
||||
Assert.Contains(first.Kept[0], first.Description);
|
||||
|
||||
var comet = rows[1];
|
||||
Assert.Empty(comet.Lines, "nothing of it changes");
|
||||
Assert.SequenceEqual([Loc.L("Archive.Reorganize.Blocked.Unreadable")], comet.Kept, "an unreadable sidecar has no photo count");
|
||||
Assert.False(comet.HasNote);
|
||||
|
||||
var night = rows[2];
|
||||
Assert.Equal("2026/2026-09-28 Harbour/Night", night.Name, "without a title, the row is named by its folder");
|
||||
Assert.True(night.IsNamePath);
|
||||
Assert.Equal(Loc.L("Archive.Reorganize.Carried"), night.Note);
|
||||
|
||||
// A sequence carried along is listed, not counted; the names kept are the photos', not the sequences'.
|
||||
Assert.Equal(1, ReorganizePlans.Changed(plan));
|
||||
Assert.Equal(string.Join(Loc.Separator, Loc.Plural("Archive.Rename.Summary", 1, 2), Loc.Plural("Archive.Reorganize.Renamed", 120),
|
||||
Loc.Plural("Archive.Reorganize.Kept", 12)), ReorganizePlans.Summary(plan, 2));
|
||||
Assert.Equal(Loc.Plural("Archive.Rename.Summary", 1, 2), ReorganizePlans.Summary(plan with { FileTemplate = null, Steps = [moved with { Blocked = [] }] }, 2),
|
||||
"no file template, no file count; nothing kept, nothing said");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TemplatesChangedWhileTheToastIsUpJoinItsOffer()
|
||||
{
|
||||
var main = new Core.Model.Archive { Id = Guid.CreateVersion7(), Name = "Main", RootPath = "/archive" };
|
||||
var other = new Core.Model.Archive { Id = Guid.CreateVersion7(), Name = "Other", RootPath = "/other" };
|
||||
var offer = new ReorganizeOffer(TimeSpan.FromSeconds(8));
|
||||
var now = new DateTime(2026, 10, 27, 9, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
Assert.True(offer.Add(main, ReorganizeParts.Folders, now), "the first change raises the toast");
|
||||
var saved = main with { FileTemplate = "{date}_{n:000}" };
|
||||
Assert.False(offer.Add(saved, ReorganizeParts.Files, now.AddSeconds(5)), "a change while it is up joins it");
|
||||
Assert.Equal((saved, ReorganizeParts.Folders | ReorganizeParts.Files), offer.Take(main.Id), "both templates, the archive as saved last");
|
||||
Assert.Null(offer.Take(main.Id), "a second toast of the same offer finds it taken");
|
||||
|
||||
Assert.True(offer.Add(main, ReorganizeParts.Folders, now.AddSeconds(6)), "once taken, the next change raises a toast again");
|
||||
Assert.True(offer.Add(other, ReorganizeParts.Files, now.AddSeconds(7)), "another archive has its own toast");
|
||||
Assert.Equal((other, ReorganizeParts.Files), offer.Take(other.Id));
|
||||
Assert.True(offer.Add(other, ReorganizeParts.Files, now.AddSeconds(8)));
|
||||
Assert.True(offer.Add(other, ReorganizeParts.Folders, now.AddSeconds(17)), "the toast is gone: a new one");
|
||||
|
||||
// Each toast takes its own archive's offer: the older toast of Main opens Main, not the Other changed since.
|
||||
Assert.Equal((main, ReorganizeParts.Folders), offer.Take(main.Id));
|
||||
Assert.Equal((other, ReorganizeParts.Files | ReorganizeParts.Folders), offer.Take(other.Id), "Other's offer stayed for its own toast");
|
||||
Assert.Null(offer.Take(main.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AToastGoneEarlyLetsTheNextChangeRaiseItsOwn()
|
||||
{
|
||||
var main = new Core.Model.Archive { Id = Guid.CreateVersion7(), Name = "Main", RootPath = "/archive" };
|
||||
var offer = new ReorganizeOffer(TimeSpan.FromSeconds(8));
|
||||
var now = new DateTime(2026, 10, 27, 9, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
Assert.True(offer.Add(main, ReorganizeParts.Folders, now));
|
||||
offer.Closed(main.Id, now);
|
||||
Assert.True(offer.Add(main, ReorganizeParts.Files, now.AddSeconds(2)), "dismissed after a second: the next change has a toast of its own");
|
||||
Assert.False(offer.Add(main, ReorganizeParts.Titles, now.AddSeconds(3)), "and joins it while it is up");
|
||||
offer.Closed(main.Id, now);
|
||||
Assert.False(offer.Add(main, ReorganizeParts.Titles, now.AddSeconds(4)), "an older toast leaving changes nothing for the one up");
|
||||
Assert.Equal((main, ReorganizeParts.Folders | ReorganizeParts.Files | ReorganizeParts.Titles), offer.Take(main.Id),
|
||||
"the toast up offers every change since the last one taken");
|
||||
offer.Closed(main.Id, now.AddSeconds(2));
|
||||
Assert.Null(offer.Take(main.Id), "the toast closing after its action finds nothing to keep");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The toasts' host says when a toast leaves the screen, as Settings › Archive needs to know whether its offer is still
|
||||
/// up: dismissed, pushed out by three newer ones, timed out or closed by its action, once each.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public void AToastLeavingTheScreenSaysSoOnce() => WpfApplication.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var host = new ToastHost();
|
||||
var closed = new List<string>();
|
||||
Toast Show(string title)
|
||||
{
|
||||
var toast = new Toast { Title = title };
|
||||
toast.Closed += (_, _) => closed.Add(title);
|
||||
host.Show(toast);
|
||||
return toast;
|
||||
}
|
||||
|
||||
var first = Show("first");
|
||||
var second = Show("second");
|
||||
host.Dismiss(second);
|
||||
host.Dismiss(second);
|
||||
Assert.SequenceEqual(["second"], closed, "dismissed, once");
|
||||
Show("third");
|
||||
Show("fourth");
|
||||
Assert.Empty(closed.Skip(1), "three on screen");
|
||||
Show("fifth");
|
||||
Assert.SequenceEqual(["second", "first"], closed, "the oldest pushed out by a fourth");
|
||||
host.Dismiss(first);
|
||||
Assert.Count(2, closed, "a toast gone already says nothing");
|
||||
foreach (var toast in host.Toasts.ToList()) host.Dismiss(toast);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public async Task SwitchesChooseTheTemplatesAndApplyQueuesExactlyThatPlan()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var directory = context.CreateTempDirectory("reorganize-dialog");
|
||||
await using var db = await ChronosDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(directory, "index.db")), context.Cancellation);
|
||||
var archives = new ArchiveService(db, new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(TestTiming.Budget(20)) });
|
||||
var archive = await archives.CreateAsync(Path.Combine(directory, "archive"), "Main", cancellationToken: context.Cancellation);
|
||||
var harbour = await UploadAsync(archives, archive, "harbour", Start, 1);
|
||||
var comet = await UploadAsync(archives, archive, "comet", Start.AddDays(1), 11);
|
||||
var (before, title) = (await db.Sequences.GetAsync(harbour)) is { } filed ? (filed.Folder, filed.Title ?? string.Empty) : default;
|
||||
|
||||
var queued = new TaskCompletionSource<ArchiveJobRequest>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var closed = false;
|
||||
using var dialog = new ReorganizeDialogViewModel(archives, archive, [harbour, comet], ReorganizePlans.Layout, request =>
|
||||
{
|
||||
queued.TrySetResult(request);
|
||||
return Task.CompletedTask;
|
||||
}, _ => closed = true);
|
||||
|
||||
// From the mass bar: the archive's layout, folders and file names, prefilled from its settings.
|
||||
Assert.True(dialog.Folders.IsEnabled);
|
||||
Assert.True(dialog.Files.IsEnabled);
|
||||
Assert.False(dialog.Titles.IsEnabled);
|
||||
Assert.Equal(new RenameTemplates(archive.FolderTemplate, archive.FileTemplate), dialog.Current());
|
||||
Assert.Equal(Loc.Plural("Archive.Reorganize.Heading", 2), dialog.Heading);
|
||||
await dialog.PlanAsync();
|
||||
Assert.Empty(dialog.Rows, "photos filed with the archive's templates already follow them");
|
||||
Assert.Equal(Loc.L("Archive.Blocked.NoChanges"), dialog.ApplyToolTip);
|
||||
Assert.False(dialog.ApplyCommand.CanExecute(null));
|
||||
|
||||
// A template switched off neither counts nor blocks with its errors; switched on, its error does.
|
||||
dialog.Titles.Field.Text = "{title";
|
||||
Assert.Null(dialog.Titles.Error);
|
||||
Assert.Null(dialog.Current()!.Title);
|
||||
dialog.Titles.IsEnabled = true;
|
||||
Assert.NotNull(dialog.Titles.Error);
|
||||
Assert.Null(dialog.Current());
|
||||
Assert.Equal(dialog.Titles.Error, dialog.ApplyToolTip);
|
||||
dialog.Titles.IsEnabled = false;
|
||||
dialog.Folders.IsEnabled = false;
|
||||
dialog.Files.IsEnabled = false;
|
||||
Assert.Null(dialog.Current());
|
||||
Assert.Equal(Loc.L("Archive.Blocked.NoTemplate"), dialog.ApplyToolTip);
|
||||
Assert.False(dialog.ApplyCommand.CanExecute(null));
|
||||
|
||||
dialog.Folders.IsEnabled = true;
|
||||
dialog.Folders.Field.Text = "{year}/{date}";
|
||||
dialog.Titles.Field.Text = "Shoot {date}";
|
||||
dialog.Titles.IsEnabled = true;
|
||||
Assert.Equal(Loc.L("Archive.Blocked.Planning"), dialog.ApplyToolTip, "the dry run on screen is not the one of the templates typed");
|
||||
await dialog.PlanAsync();
|
||||
|
||||
var plan = Assert.NotNull(dialog.Plan);
|
||||
Assert.Count(2, dialog.Rows);
|
||||
var row = dialog.Rows.Single(r => r.SequenceId == harbour);
|
||||
Assert.Equal("Shoot 2026-09-28", row.Name);
|
||||
Assert.SequenceEqual([$"{before}>2026/2026-09-28", $"{title}>Shoot 2026-09-28"], row.Lines.Select(l => $"{l.From}>{l.To}"), "folders and titles, no file names");
|
||||
Assert.Equal(Loc.Plural("Archive.Rename.Summary", 2, 2), dialog.SummaryText);
|
||||
Assert.Null(plan.FileTemplate);
|
||||
Assert.True(dialog.ApplyCommand.CanExecute(null));
|
||||
|
||||
// Typing again: Apply waits for the dry run of what is on screen; Enter plans it at once.
|
||||
dialog.Folders.Field.Text = "{year}/{date} {title}";
|
||||
Assert.Null(dialog.Plan);
|
||||
Assert.False(dialog.ApplyCommand.CanExecute(null));
|
||||
Assert.True(dialog.Folders.Field.Commit());
|
||||
Assert.Equal(Loc.L("Archive.Reorganize.Planning"), dialog.BusyText, "a template changed since its dry run plans without waiting for the typing to pause");
|
||||
dialog.Folders.Field.Text = "{year}/{date}";
|
||||
await dialog.PlanAsync();
|
||||
plan = Assert.NotNull(dialog.Plan);
|
||||
|
||||
// A click on Apply takes the focus from the field first, which commits it: the dry run on screen is of that text
|
||||
// already, so no other one starts and Apply stays on under the click.
|
||||
Assert.True(dialog.Folders.Field.IsDirty, "typed, not committed");
|
||||
Assert.True(dialog.Folders.Field.Commit());
|
||||
Assert.Same(plan, dialog.Plan);
|
||||
Assert.Null(dialog.BusyText);
|
||||
Assert.True(dialog.ApplyCommand.CanExecute(null));
|
||||
|
||||
dialog.ApplyCommand.Execute(null);
|
||||
var request = await queued.Task.WaitAsync(TimeSpan.FromSeconds(TestTiming.Budget(20)));
|
||||
await UntilAsync(() => closed);
|
||||
Assert.Equal(JobKind.Move, request.Kind);
|
||||
Assert.SequenceEqual([archive.Id], request.Targets);
|
||||
Assert.Equal(archive.Name, request.Label);
|
||||
Assert.Equal(JobPriority.User, request.Priority);
|
||||
using (var parameters = JsonDocument.Parse(request.ParametersJson!))
|
||||
{
|
||||
var json = parameters.RootElement;
|
||||
Assert.Equal("{year}/{date}", json.GetProperty("folderTemplate").GetString());
|
||||
Assert.Equal("Shoot {date}", json.GetProperty("titleTemplate").GetString());
|
||||
Assert.False(json.TryGetProperty("fileTemplate", out var file) && file.ValueKind != JsonValueKind.Null, "the file names were switched off");
|
||||
Assert.Equal(plan.Fingerprint(), json.GetProperty("fingerprint").GetString());
|
||||
}
|
||||
Assert.Equal(before, (await db.Sequences.GetAsync(harbour))!.Folder, "the job reorganizes, not the dialog");
|
||||
|
||||
// The job applies the plan the dialog showed.
|
||||
await using var engine = new JobEngine(db, archives.CreateJobHandlers(),
|
||||
new JobEngineOptions { Workers = 1, WorkerId = "test", PollInterval = TimeSpan.FromMilliseconds(50), CheckpointInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync(context.Cancellation);
|
||||
var job = await engine.EnqueueAsync(request, cancellationToken: context.Cancellation);
|
||||
await WaitForAsync(db, job.Id);
|
||||
var after = (await db.Sequences.GetAsync(harbour))!;
|
||||
Assert.Equal(("2026/2026-09-28", "Shoot 2026-09-28"), (after.Folder, after.Title));
|
||||
Assert.True(Directory.Exists(Path.Combine(archive.RootPath, "2026", "2026-09-28")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Settings toast's Reorganize… is reached from another screen while the Archive screen may have a dialog open (a
|
||||
/// Delete moving sequences, the trash): that dialog is neither replaced nor stopped. Reorganize says it waits, and
|
||||
/// opens once that dialog closes, on every sequence with every part the toasts offered meanwhile.
|
||||
/// </summary>
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public void TheToastsReorganizeWaitsForTheDialogOpenOnTheArchiveScreen()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var environment = AppEnvironment.ForCapture();
|
||||
try
|
||||
{
|
||||
SingleThreadedContext.Run(async () =>
|
||||
{
|
||||
var services = new AppServices(environment, new AppSettings { Language = "en", FirstRunCompleted = true }, () => { }, new NoDialogs());
|
||||
var sample = SampleData.Configure(services);
|
||||
await sample.OpenEmptyAsync();
|
||||
await sample.FillAsync();
|
||||
var shell = new ShellViewModel(services);
|
||||
try
|
||||
{
|
||||
var toasts = new List<Toast>();
|
||||
shell.PendingToasts.CollectionChanged += (_, e) => toasts.AddRange(e.NewItems?.OfType<Toast>() ?? []);
|
||||
var screen = shell.Archive;
|
||||
await screen.LoadAsync();
|
||||
var archive = Assert.NotNull(screen.SelectedArchive);
|
||||
await screen.OpenTrashAsync();
|
||||
var trash = Assert.NotNull(screen.Dialog as TrashDialogViewModel);
|
||||
|
||||
await screen.OpenReorganizeAllAsync(archive with { FileTemplate = "{date}_{n:0000}" }, ReorganizeParts.Files);
|
||||
await screen.OpenReorganizeAllAsync(archive, ReorganizeParts.Folders);
|
||||
Assert.Same(trash, screen.Dialog);
|
||||
Assert.Equal(Loc.L("Archive.Reorganize.Waiting"), toasts[^1].Title);
|
||||
|
||||
trash.CloseCommand.Execute(null);
|
||||
await UntilAsync(() => screen.Dialog is ReorganizeDialogViewModel);
|
||||
var reorganize = (ReorganizeDialogViewModel)screen.Dialog!;
|
||||
await UntilAsync(() => reorganize.BusyText is null);
|
||||
Assert.Null(reorganize.ErrorText);
|
||||
Assert.Equal(Loc.L("Archive.Reorganize.HeadingAll", archive.Name), reorganize.Heading);
|
||||
Assert.True(reorganize.Folders.IsEnabled, "the parts of both toasts");
|
||||
Assert.True(reorganize.Files.IsEnabled);
|
||||
Assert.False(reorganize.Titles.IsEnabled);
|
||||
Assert.Equal(archive.FileTemplate, reorganize.Files.Field.Text, "the archive's templates as the index holds them when it opens");
|
||||
reorganize.CloseCommand.Execute(null);
|
||||
Assert.Null(screen.Dialog);
|
||||
}
|
||||
finally
|
||||
{
|
||||
shell.Dispose();
|
||||
await services.DisposeAsync();
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
environment.DeleteCaptureData();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Dialogs that answer like a user who cancels everything.</summary>
|
||||
private sealed class NoDialogs : IAppDialogs
|
||||
{
|
||||
public string? PickFolder(string title, string? initialFolder = null) => null;
|
||||
public string? PickJsonFile(string title) => null;
|
||||
public bool Confirm(ConfirmRequest request) => false;
|
||||
public bool SignIn(string server, string? username, Func<string, string, Task<string?>> signIn) => false;
|
||||
}
|
||||
|
||||
/// <summary>Uploads two photos ten seconds apart into a new sequence filed with the archive's templates; returns its id.</summary>
|
||||
private async Task<Guid> UploadAsync(ArchiveService archives, Core.Model.Archive archive, string key, DateTime start, int seed)
|
||||
{
|
||||
Guid id = default;
|
||||
var staging = Path.Combine(new ArchivePaths(archive.RootPath).StagingDirectory, "uploads");
|
||||
Directory.CreateDirectory(staging);
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var bytes = ImportTestData.Jpeg(start.AddSeconds(10 * i), seed + i);
|
||||
var path = Path.Combine(staging, $"{Guid.NewGuid():N}.part");
|
||||
await File.WriteAllBytesAsync(path, bytes, context.Cancellation);
|
||||
var request = new IngestRequest(archive.Id, null, null, key, path, $"IMG_{seed + i:0000}.JPG", bytes.Length, Convert.ToHexStringLower(SHA256.HashData(bytes)),
|
||||
null, null);
|
||||
id = (await archives.Ingest.CommitAsync(request, context.Cancellation)).SequenceId;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private async Task WaitForAsync(ChronosDatabase db, Guid jobId)
|
||||
{
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(TestTiming.Budget(30));
|
||||
Job? job = null;
|
||||
while (DateTime.UtcNow < until)
|
||||
{
|
||||
job = await db.Jobs.GetAsync(jobId, context.Cancellation);
|
||||
if (job?.State == JobState.Done) return;
|
||||
if (job?.State is JobState.Failed or JobState.Cancelled) Assert.Fail($"The reorganize job ended {job.State}: {job.Error}\n{job.LogTail}");
|
||||
await Task.Delay(20, context.Cancellation);
|
||||
}
|
||||
Assert.Fail($"The reorganize job did not finish (now {job?.State}).");
|
||||
}
|
||||
|
||||
private static async Task UntilAsync(Func<bool> condition)
|
||||
{
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(TestTiming.Budget(20));
|
||||
while (!condition())
|
||||
{
|
||||
Assert.True(DateTime.UtcNow < until, "timed out");
|
||||
await Task.Delay(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,6 +330,59 @@ public sealed class EditorSmokeTests
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// A Reorganize of this PC moves the folder of the sequence open in the editor: the editor reads it again where it is
|
||||
/// now as soon as its step is done, so its frames decode and its project goes there.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task AnOpenSequenceIsReadAgainWhereAReorganizeMovedIt() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var id = await app.Sample.FillEditorAsync();
|
||||
var db = app.Services.Database!;
|
||||
var archives = app.Services.Archives!;
|
||||
var source = new LocalSequenceSource(db, id, Chronos.Core.Imaging.Decoders.DecoderFactory.CreateClient(null), null);
|
||||
var content = await source.LoadAsync(CancellationToken.None);
|
||||
var editor = new EditorViewModel(app.Shell, new EditorSession(source, content, []), [], EncoderHost.Client);
|
||||
await using (editor)
|
||||
{
|
||||
var archive = (await db.Archives.GetAsync(content.Sequence.ArchiveId))!;
|
||||
var templates = new Chronos.Core.Archiving.RenameTemplates("Moved/{date}");
|
||||
var plan = await archives.PlanReorganizeAsync(archive.Id, [id], templates, CancellationToken.None);
|
||||
var moved = plan.Steps.Single().ToFolder;
|
||||
await using var engine = new Chronos.Data.Jobs.JobEngine(db, archives.CreateJobHandlers(), new Chronos.Data.Jobs.JobEngineOptions
|
||||
{
|
||||
WorkerId = "test",
|
||||
Kinds = [JobKind.Move],
|
||||
PollInterval = TimeSpan.FromMilliseconds(50),
|
||||
});
|
||||
await engine.StartAsync(CancellationToken.None);
|
||||
var job = await Chronos.Data.Archiving.ArchiveJobs.EnqueueAsync(engine, Chronos.Data.Archiving.ArchiveJobs.Reorganize(archive, plan, templates));
|
||||
// The editor reads its photos as it opens; on Windows the folder cannot move while one is open, and the job that
|
||||
// failed holds the plan for its retry.
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
Job? ended = null;
|
||||
for (var i = 0; i < 1200 && ended is null; i++)
|
||||
{
|
||||
await Task.Delay(25);
|
||||
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } now) ended = now;
|
||||
}
|
||||
Assert.NotNull(ended, "the move job ends");
|
||||
if (ended!.State == JobState.Done) break;
|
||||
Assert.True(ended.State == JobState.Failed && attempt < 20, ended.Error);
|
||||
await Task.Delay(250);
|
||||
await engine.ResumeAsync(job.Id, CancellationToken.None);
|
||||
}
|
||||
|
||||
for (var i = 0; i < 400 && editor.Session.Content.Sequence.Folder != moved; i++) await Task.Delay(25);
|
||||
Assert.Equal(moved, editor.Session.Content.Sequence.Folder);
|
||||
Assert.True(await source.FramesCurrentAsync(CancellationToken.None), "the editor holds the frames where they are now");
|
||||
using var frame = await source.DecodeAsync(0, 32, Chronos.Core.Imaging.DecodePurpose.Thumbnail, CancellationToken.None);
|
||||
Assert.NotNull(frame, "its frames decode");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// At the 1200 px minimum beside the 200 px rail (owner review 1, R1), the preview's tools stay inside the preview in
|
||||
/// every language, crop mask on (the crop-result tool enabled): they take a second line rather than lose Play and Full screen.
|
||||
|
||||
@@ -215,6 +215,44 @@ public sealed class ProjectStoreTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnEditorOpenWhileAReorganizeMovesItsFolderSavesWhereTheSequenceIsNow()
|
||||
{
|
||||
var (db, sequenceId, root) = await ArchiveAsync(6);
|
||||
await using (db)
|
||||
{
|
||||
var options = new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) };
|
||||
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null, options);
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
await using (session)
|
||||
{
|
||||
Assert.True(session.SetHero(2));
|
||||
Assert.True(await session.FlushAsync());
|
||||
|
||||
// Only the folder template changed: the Reorganize moves the folder and keeps the frames version.
|
||||
var service = new ArchiveService(db, options);
|
||||
var plan = await service.PlanRenameAsync(content.Sequence.ArchiveId, [sequenceId], "Moved/{title}", null, context.Cancellation);
|
||||
await service.ApplyRenameAsync(plan, null, context.Cancellation);
|
||||
var moved = new ArchivePaths(root).Sequence(plan.Steps.Single().ToFolder);
|
||||
Assert.Equal(content.Sequence.FramesVersion, (await db.Sequences.GetAsync(sequenceId))!.FramesVersion);
|
||||
Assert.False(await source.FramesCurrentAsync(context.Cancellation), "the files are no longer where the editor read them");
|
||||
|
||||
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.4 } });
|
||||
Assert.True(await session.FlushAsync());
|
||||
|
||||
var row = (await db.Sequences.GetAsync(sequenceId))!;
|
||||
Assert.Equal(0.4, ProjectSettings.FromJson(row.SettingsJson!).Exposure.ExposureOffsetEv);
|
||||
Assert.Equal(row.SettingsJson, File.ReadAllText(moved.ProjectPath), "the moved folder's project has the edit");
|
||||
Assert.False(Directory.Exists(Path.Combine(root, "Synthetic")), "the folder it left is not created again");
|
||||
Assert.True(await source.FramesCurrentAsync(context.Cancellation));
|
||||
Assert.Equal(moved.Exports, session.Content.ExportsFolder);
|
||||
using var frame = await source.DecodeAsync(1, 32, DecodePurpose.Thumbnail, context.Cancellation);
|
||||
Assert.NotNull(frame, "the frames are read where they are now");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASaveThatDoesNotReachTheIndexThrows()
|
||||
{
|
||||
@@ -230,6 +268,54 @@ public sealed class ProjectStoreTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASaveAfterAnotherIndexMovedTheFolderWritesNothing()
|
||||
{
|
||||
var (db, sequenceId, root) = await ArchiveAsync(4);
|
||||
await using (db)
|
||||
{
|
||||
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null,
|
||||
new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) });
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
|
||||
// A server sharing the archive moved the folder; this index finds it there at its next scan.
|
||||
var left = Path.Combine(root, "Synthetic");
|
||||
Directory.Move(left, Path.Combine(root, "Moved"));
|
||||
var gone = await Assert.ThrowsAsync<EditorException>(() => source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
|
||||
|
||||
Assert.Equal(Loc.L("Editor.Error.Missing"), gone.Message);
|
||||
Assert.False(Directory.Exists(left), "the folder it left is not created again");
|
||||
Assert.Equal(content.Sequence.SettingsVersion, (await db.Sequences.GetAsync(sequenceId))!.SettingsVersion, "nothing recorded");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASaveNeverWritesIntoAnotherSequenceMovedIntoTheFolder()
|
||||
{
|
||||
var (db, sequenceId, root) = await ArchiveAsync(4);
|
||||
await using (db)
|
||||
{
|
||||
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null,
|
||||
new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) });
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
|
||||
// A server sharing the archive moved the folder away, then another sequence into the folder it left; this index
|
||||
// finds both at its next scan.
|
||||
var paths = new ArchivePaths(root);
|
||||
Directory.Move(paths.Sequence("Synthetic").Folder, paths.Sequence("Moved").Folder);
|
||||
var stranger = paths.Sequence("Synthetic");
|
||||
Directory.CreateDirectory(stranger.MetaDirectory);
|
||||
ManifestStore.WriteSequence(stranger.ManifestPath, ManifestStore.ReadSequence(paths.Sequence("Moved").ManifestPath) with { Id = Guid.NewGuid() });
|
||||
const string theirs = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":7}}}""";
|
||||
await File.WriteAllTextAsync(stranger.ProjectPath, theirs, context.Cancellation);
|
||||
var gone = await Assert.ThrowsAsync<EditorException>(() => source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
|
||||
|
||||
Assert.Equal(Loc.L("Editor.Error.Missing"), gone.Message);
|
||||
Assert.Equal(theirs, await File.ReadAllTextAsync(stranger.ProjectPath, context.Cancellation), "the other sequence's project is untouched");
|
||||
Assert.Equal(content.Sequence.SettingsVersion, (await db.Sequences.GetAsync(sequenceId))!.SettingsVersion, "nothing recorded");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task JobsGoToTheEngine()
|
||||
{
|
||||
|
||||
@@ -2,9 +2,11 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Testing;
|
||||
@@ -60,4 +62,15 @@ public sealed class ErrorTextTests
|
||||
Assert.Equal("Something went wrong.", ErrorText.For(new IOException(@"Access to the path 'D:\Archive' is denied.")));
|
||||
Assert.Equal(@"The archive D:\Shoots is read-only.", ErrorText.For(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.ReadOnly)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ATemplateAnArchiveRefusesSaysTheRuleItBreaks()
|
||||
{
|
||||
// A new archive with this PC's templates, one saved before the rules existed: the toast says what to change.
|
||||
var refused = new TemplateRuleException("fileTemplate", "NotUnique");
|
||||
const string Sentence = "Names would repeat: add the frame number, the time or the original name.";
|
||||
Assert.Equal(Sentence, ErrorText.For(refused));
|
||||
Assert.Equal(Sentence, ArchiveActions.Cause(refused));
|
||||
Assert.Equal("Something went wrong.", ArchiveActions.Cause(new ArgumentException("The archive setting name is invalid.", "name")));
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public sealed class LibraryScreenSmokeTests
|
||||
await LibraryScenes.ShowAsync(app.Shell, "mass");
|
||||
Assert.Equal(LibraryScenes.MassSelection, library.SelectionCount);
|
||||
await app.ExpectAsync<LibraryView>("library-mass", waitForThumbnails: true);
|
||||
foreach (var command in new[] { library.AnalyseCommand, library.ProxiesCommand, library.VerifyCommand, library.TagCommand, library.MoveCommand,
|
||||
foreach (var command in new[] { library.AnalyseCommand, library.ProxiesCommand, library.VerifyCommand, library.TagCommand, library.ReorganizeCommand,
|
||||
library.ExportListCommand, library.DeleteCommand })
|
||||
Assert.True(ButtonFor(app, command).IsEnabled, "the bar's archive actions work on sequences of this PC");
|
||||
Assert.True(library.CanRate);
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class MassActionsTests
|
||||
var remote = Remote("Sunrise over Superga");
|
||||
SelectedSequence[] mixed = [harbour, remote];
|
||||
|
||||
foreach (var action in new[] { MassAction.Analyse, MassAction.Proxies, MassAction.Verify, MassAction.Tag, MassAction.Rate, MassAction.Move, MassAction.Delete })
|
||||
foreach (var action in new[] { MassAction.Analyse, MassAction.Proxies, MassAction.Verify, MassAction.Tag, MassAction.Rate, MassAction.Reorganize, MassAction.Delete })
|
||||
{
|
||||
Assert.Null(MassActions.Blocker(action, mixed, SignedIn), action.ToString());
|
||||
Assert.SequenceEqual([harbour], MassActions.Targets(action, mixed, SignedIn), action.ToString());
|
||||
@@ -76,11 +76,21 @@ public sealed class MassActionsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MoveStaysInsideOneArchive()
|
||||
public void ReorganizeStaysInsideOneArchive()
|
||||
{
|
||||
SelectedSequence[] two = [Only("Harbour sunset"), new(Local("Aurora", Guid.CreateVersion7()), null)];
|
||||
Assert.Equal(Loc.L("Library.Blocked.Archives"), MassActions.Blocker(MassAction.Move, two, Offline));
|
||||
Assert.Equal(Loc.L("Library.Blocked.OneArchive"), MassActions.Blocker(MassAction.Reorganize, two, Offline));
|
||||
Assert.Null(MassActions.Blocker(MassAction.Delete, two, Offline), "the trash of each archive takes its own sequences");
|
||||
|
||||
// A server card in the selection is left out: the archive of the sequences here is still one.
|
||||
var remote = Remote("Sunrise over Superga");
|
||||
SelectedSequence[] withCard = [two[0], Only("Comet"), remote];
|
||||
Assert.Null(MassActions.Blocker(MassAction.Reorganize, withCard, SignedIn));
|
||||
Assert.SequenceEqual(withCard[..2], MassActions.Targets(MassAction.Reorganize, withCard, SignedIn));
|
||||
Assert.Equal(Loc.L("Library.Blocked.ServerOnly"), MassActions.Blocker(MassAction.Reorganize, [remote], SignedIn));
|
||||
Assert.Equal(Loc.L("Library.Blocked.NoIndex"), MassActions.Blocker(MassAction.Reorganize, [two[0]], new SelectionContext(HasEngine: false, IsSignedIn: false, default)),
|
||||
"the dry run and the job need the engine");
|
||||
Assert.Equal(Loc.Plural("Tooltips.Library.Mass.Reorganize", 2), MassActions.ToolTip(MassAction.Reorganize, 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -37,6 +37,8 @@ public sealed class SettingsLogicTests
|
||||
[Case("{date}", "Errors.Template.NotUnique", "", 0)]
|
||||
[Case("{year}/{n}", "Errors.Template.FileSeparator", "", 0)]
|
||||
[Case("{date:%}_{n}", "Errors.Template.Format", "", 0)]
|
||||
[Case("{n}{ext}", "Errors.Template.Extension", "", 0)]
|
||||
[Case("{title}_{ext}", "Errors.Template.Extension", "", 0)]
|
||||
public void InvalidFileTemplatesExplainTheProblem(string template, string key, string token, int position)
|
||||
{
|
||||
var expected = position > 0 ? Loc.L(key, token, position) : Loc.L(key);
|
||||
@@ -56,6 +58,18 @@ public sealed class SettingsLogicTests
|
||||
{
|
||||
Assert.Null(NamingPreview.Validate("{year}/{month}/{camera}", isFolder: true));
|
||||
Assert.Equal("2026/09/Canon EOS R5/IMG_4211.CR2", NamingPreview.FirstNames("{year}/{month}/{camera}", "{name}")[0]);
|
||||
Assert.Null(NamingPreview.Validate("{name}.{ext}", isFolder: false));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Case("Originals/{year}")]
|
||||
[Case("{year}/exports")]
|
||||
[Case(".archive/{date}")]
|
||||
[Case("{year}/.chronos")]
|
||||
public void FolderTemplatesScansWouldSkipAreRefused(string template)
|
||||
{
|
||||
Assert.Equal(Loc.L("Errors.Template.ReservedFolder"), NamingPreview.Validate(template, isFolder: true), template);
|
||||
Assert.Empty(NamingPreview.FirstNames(template, TemplateDefaults.File));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user