Files
Chronos/tests/Chronos.App.Tests/Server/UploadHoldTests.cs
T
Alby96andClaude Opus 5.5 9657c1711d fix(copies): close the owner review 6 second verification findings
Upload again now deletes the gone pair row once the new sequence is linked, so
the pair stops reading "deleted on server" or "kept here". A linked upload the
server refuses into its sequence (403 for an account without Edit that does not
own it) falls back to ordinary uploads instead of failing; an Integrate that
would add photos to such a sequence is blocked in its plan (NoAddRight).
Automatic photo transfers pause on a metered connection whatever the option
says. Integrate trashes server photos only against the manifest version that
checked the winner, and a merge is blocked while the other sequence holds a
damaged photo nothing else holds (DamagedPhotos), so nothing unverified reaches
the trash.

The plan and the confirmations now say what really happens: replaced versions
are no longer counted as kept, a merge lists the kept sequence's replaced
photos, plan lines use the text colour, an integrated pair that left photos out
says new photos move by hand, and a merging pair reads "merging" with its
progress. The Compare dialog gets per-side tooltips, class sizes for both
sides, policy-aware class tooltips, column headings and readable file names;
the sync table shows "deleted there" with Review and warns on skipped rows; the
Edit picker names the server, the Library card shows the match status second,
a deleted server sequence is named instead of "0 photos", and the match
tooltips stop calling a sequence a copy. The capture scenes use the server
name, the link names and consistent sample sizes.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 16:08:49 +01:00

89 lines
4.2 KiB
C#

using Chronos.App.Server;
using Chronos.Core.Model;
using Chronos.Data.Archiving.Jobs;
using Chronos.Data.Workspaces;
using Chronos.Testing;
namespace Chronos.App.Tests.Server;
/// <summary>
/// Which jobs "Pause metered transfers" holds (Server.html, phase 5c): uploads, the sync's downloads, and the workspace's copies from and renders
/// sent to a server, and the integrations of pairs with a server sequence; never a copy from or a send to this PC's archive, nor a merge.
/// </summary>
public sealed class UploadHoldTests
{
private const string Server = "https://nas.local:8443";
private static readonly Guid SequenceId = Guid.CreateVersion7();
private static readonly Guid ProjectId = Guid.CreateVersion7();
private const string Root = @"C:\Users\me\Chronos\workspace";
private static Job Of(ArchiveJobRequest request) => new()
{
Id = Guid.CreateVersion7(),
Kind = request.Kind,
TargetIds = request.Targets,
TargetLabel = request.Label,
ParametersJson = request.ParametersJson,
State = JobState.Queued,
Created = DateTimeOffset.UtcNow,
};
private static Job Of(JobKind kind, string? parameters = null) => new()
{
Id = Guid.CreateVersion7(),
Kind = kind,
TargetIds = [SequenceId],
ParametersJson = parameters,
State = JobState.Queued,
Created = DateTimeOffset.UtcNow,
};
[Test]
public void TransfersWithAServerAreHeld()
{
Assert.True(UploadHold.Holds(Of(JobKind.UploadCommit)));
// The sync's downloads too: the option's tooltip says "uploads and downloads".
Assert.True(UploadHold.Holds(Of(JobKind.Download)));
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.CopyFromServer(SequenceId, "Harbour", Server, Root, ProjectId))));
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, [], Server))));
Assert.SequenceEqual([JobKind.UploadCommit, JobKind.Download, JobKind.WorkspaceCopy, JobKind.WorkspaceSend, JobKind.Integrate], UploadHold.Kinds);
}
[Test]
public void AnIntegrationIsHeldAMergeIsNot()
{
// An integration always moves photos with a server (owner review 6, #73); a merge of two local sequences never does.
Assert.True(UploadHold.Holds(Of(JobKind.Integrate)));
Assert.False(UploadHold.Holds(Of(JobKind.MergeSequences)));
}
[Test]
public void AnAutomaticTransferIsHeldOnAMeteredConnectionWithTheOptionOff()
{
// Owner review 6, Q6: new photos of an integrated pair move by themselves, "paused on metered connections".
var automatic = Of(JobKind.Download, $$"""{"server":"{{Server}}","mode":"Originals","automatic":true}""");
var manual = Of(JobKind.Download, $$"""{"server":"{{Server}}","mode":"Originals"}""");
Assert.True(Chronos.Data.Sync.SyncService.IsAutomaticTransfer(automatic));
Assert.False(Chronos.Data.Sync.SyncService.IsAutomaticTransfer(manual));
Assert.True(UploadHold.HeldNow(automatic, metered: true, optionOn: false));
Assert.False(UploadHold.HeldNow(manual, metered: true, optionOn: false));
Assert.True(UploadHold.HeldNow(manual, metered: true, optionOn: true));
Assert.False(UploadHold.HeldNow(automatic, metered: false, optionOn: true));
// An automatic upload too.
Assert.True(UploadHold.HeldNow(Of(JobKind.UploadCommit, $$"""{"server":"{{Server}}","automatic":true}"""), metered: true, optionOn: false));
}
[Test]
public void TransfersWithThisPcsLibraryAndOtherJobsAreNot()
{
var sequence = new Sequence { Id = SequenceId, ArchiveId = Guid.CreateVersion7(), Title = "Harbour", Folder = "2026/harbour" };
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Copy(sequence, Root, ProjectId))));
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, []))));
Assert.False(UploadHold.Holds(Of(JobKind.Render)));
// Parameters that cannot be read are not held: the job fails with its reason.
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceSend, "{not json")));
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceCopy)));
}
}