Files
Chronos/tests/Chronos.App.Tests/Library/VersionsDialogTests.cs
T
Alby96andClaude Opus 5.5 bf7701d279 fix(copies): close the fifth verification round of owner review 6
The metered hold now records the jobs it paused in the index and forgets
any job the user pauses, resumes, retries or cancels, so it never resumes
a pause of the user's and still resumes its own after a restart.

Drop... reports why its dry run is blocked instead of asking first, and
dropping the version Main uses lets Main use the version that stays,
with its hero and keyframes. That version reads "In Main".

Merges:
- A re-plan no longer hashes the other's photos again.
- A resumed merge verifies photos flagged damaged while it waited.
- A merge is blocked while the other's folder holds photos the index
  has not read; this is checked again under the lease before the trash.
- Choose each offers Keep both, Kept and Other, and blocks until every
  differing photo is chosen.
- Classes are named by role.

The Compare dialog:
- Its headings stay over their columns.
- The Projects part scrolls.
- Every confirmation line carries its own prefix, and a merge's facts
  carry none.
- A server card in a match offers Compare... alone.

The Italian strings follow the glossary.

Finding 9 (a local drop counting 0 photos) is not reproduced; a test now
keeps the count at 2.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:51:23 +01:00

82 lines
3.0 KiB
C#

using System.Reflection;
using Chronos.App.Infrastructure;
using Chronos.App.Library;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Archiving;
using Chronos.Data.Copies;
using Chronos.Testing;
namespace Chronos.App.Tests.Library;
/// <summary>Two versions… (owner Q3, #73): a drop whose dry run cannot go says why and asks nothing.</summary>
[Serial]
public sealed class VersionsDialogTests
{
private static readonly Sequence Comet = new()
{
Id = Guid.CreateVersion7(),
ArchiveId = Guid.CreateVersion7(),
Title = "Comet",
Folder = "2026/comet",
};
[Test]
public async Task ABlockedDropSaysWhyAndNeverAsksOrDrops()
{
foreach (var (block, expected) in new[]
{
(FrameDeleteBlock.Offline, Loc.L("Errors.Copies.TrashBlocked", "IMG_0002.JPG", Loc.L("Archive.Delete.Reason.Offline"))),
(FrameDeleteBlock.Busy, Loc.L("Errors.Copies.TrashBlocked", "IMG_0002.JPG", Loc.L("Archive.Delete.Reason.Busy"))),
(FrameDeleteBlock.FramesChanged, Loc.L("Archive.Convert.Blocked.FramesChanged")),
})
{
var engine = FakeEngine.Create(new OwnVersionDropPlan(new FrameDeletePlan(Comet, [], 0, [block]), Guid.NewGuid(), "IMG_0003.JPG", "b", []));
var asked = 0;
var dialog = new VersionsDialogViewModel((ICopyEngine)engine, Comet.Id, Comet.DisplayTitle, _ =>
{
asked++;
return true;
}, _ => { });
var row = new VersionRow(dialog, new PhotoVersions(Guid.NewGuid(), "IMG_0002.JPG", "a", Guid.NewGuid(), "IMG_0003.JPG", "b"), Guid.NewGuid(), "IMG_0002.JPG", 10, "IMG_0003.JPG", inMain: true);
await dialog.DropAsync(row);
Assert.Equal(0, asked);
Assert.Equal(0, ((FakeEngine)engine).Dropped);
Assert.Equal(expected, dialog.ErrorText);
Assert.True(row.InMain);
}
}
/// <summary>An <see cref="ICopyEngine"/> that plans <see cref="Plan"/> for every drop and counts the drops applied.</summary>
public class FakeEngine : DispatchProxy
{
internal OwnVersionDropPlan? Plan { get; set; }
internal int Dropped { get; private set; }
internal static object Create(OwnVersionDropPlan plan)
{
var proxy = Create<ICopyEngine, FakeEngine>();
((FakeEngine)(object)proxy).Plan = plan;
return proxy;
}
protected override object? Invoke(MethodInfo? targetMethod, object?[]? args) => targetMethod?.Name switch
{
nameof(ICopyEngine.PlanDropOwnVersionAsync) => Task.FromResult(Plan!),
nameof(ICopyEngine.DropOwnVersionAsync) => Drop(),
nameof(ICopyEngine.VersionsAsync) => Task.FromResult<IReadOnlyList<PhotoVersions>>([]),
nameof(IDisposable.Dispose) => null,
_ => throw new NotSupportedException(targetMethod?.Name),
};
private Task<int> Drop()
{
Dropped++;
return Task.FromResult(1);
}
}
}