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>
403 lines
25 KiB
C#
403 lines
25 KiB
C#
using System.Globalization;
|
|
using System.IO;
|
|
using Chronos.App.Infrastructure;
|
|
using Chronos.App.Server;
|
|
using Chronos.App.Server.Copies;
|
|
using Chronos.Core.Localization;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Copies;
|
|
using Chronos.Data.Sync;
|
|
using Chronos.Testing;
|
|
using Chronos.Ui.Controls;
|
|
|
|
namespace Chronos.App.Tests.Server;
|
|
|
|
/// <summary>Words, glyphs and actions of a match (owner review 6, #73, design §8.1), and the sync rows a match marks.</summary>
|
|
[Serial]
|
|
public sealed class CopyTextTests
|
|
{
|
|
private const string Nas = "https://nas.local:8443";
|
|
private static readonly CopyRights SignedIn = new(Nas, "Studio NAS", CanIntegrate: true, CanUpload: true);
|
|
|
|
private static readonly Sequence Local = new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
ArchiveId = Guid.CreateVersion7(),
|
|
Title = "Lighthouse 2026-08-13",
|
|
Folder = "2026/lighthouse",
|
|
FrameCount = 1_204,
|
|
TotalBytes = 18_200_000_000,
|
|
Status = SequenceStatus.ProxiesBuilt,
|
|
};
|
|
|
|
private static readonly SyncLink Link = new()
|
|
{
|
|
Server = Nas,
|
|
RemoteId = Guid.CreateVersion7(),
|
|
Title = "Lighthouse 2026-08-13",
|
|
TotalBytes = 18_200_000_000,
|
|
RemoteStatus = SequenceStatus.ProxiesBuilt,
|
|
};
|
|
|
|
[Test]
|
|
public void EachStateOffersTheActionsOfTheTable()
|
|
{
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Integrate, CopyAction.KeepApart], CopyText.Actions(Copy(CopyState.Candidate)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Merge, CopyAction.KeepApart], CopyText.Actions(Copy(CopyState.Candidate, CopyKind.LocalLocal)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.AskAgain], CopyText.Actions(Copy(CopyState.KeptApart)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Integrate, CopyAction.Unlink], CopyText.Actions(Copy(CopyState.Linked)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Integrate, CopyAction.Unlink, CopyAction.Review],
|
|
CopyText.Actions(Copy(CopyState.Linked, deletedThere: 3)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Unlink], CopyText.Actions(Copy(CopyState.Integrated)));
|
|
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Unlink, CopyAction.Review], CopyText.Actions(Copy(CopyState.Integrated, deletedThere: 3)));
|
|
Assert.SequenceEqual([CopyAction.Pause], CopyText.Actions(Copy(CopyState.Integrating), JobState.Running));
|
|
Assert.SequenceEqual([CopyAction.Resume], CopyText.Actions(Copy(CopyState.Integrating), JobState.Paused));
|
|
|
|
// The server deleted its copy: keep it here, send it again or move it to the trash; once kept, only send again.
|
|
Assert.SequenceEqual([CopyAction.KeepHere, CopyAction.UploadAgain, CopyAction.ToTrash], CopyText.Actions(Copy(CopyState.Linked, gone: true)));
|
|
Assert.SequenceEqual([CopyAction.UploadAgain], CopyText.Actions(Copy(CopyState.KeptApart, gone: true)));
|
|
}
|
|
|
|
[Test]
|
|
public void TheStateGlyphFollowsWhatThePairAsksFor()
|
|
{
|
|
Assert.Equal(StatusKind.Warning, CopyText.State(Copy(CopyState.Candidate)).Kind);
|
|
Assert.Equal(StatusKind.Offline, CopyText.State(Copy(CopyState.KeptApart)).Kind);
|
|
Assert.Equal(StatusKind.Synced, CopyText.State(Copy(CopyState.Linked)).Kind);
|
|
Assert.Equal(StatusKind.Running, CopyText.State(Copy(CopyState.Integrating), progress: (3, 10)).Kind);
|
|
Assert.Equal(StatusKind.Done, CopyText.State(Copy(CopyState.Integrated)).Kind);
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Copies.State.DeletedThere", "3")),
|
|
Head(CopyText.State(Copy(CopyState.Integrated, deletedThere: 3))));
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Copies.State.DeletedOther", "3")),
|
|
Head(CopyText.State(Copy(CopyState.Integrated, CopyKind.LocalLocal, deletedThere: 3))));
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Copies.State.RemoteGone")), Head(CopyText.State(Copy(CopyState.Linked, gone: true))));
|
|
Assert.Equal((StatusKind.Offline, Loc.L("Server.Copies.State.KeptHere")), Head(CopyText.State(Copy(CopyState.KeptApart, gone: true))));
|
|
// The candidate's tooltip says how much the two share.
|
|
Assert.Contains("98", CopyText.State(Copy(CopyState.Candidate)).ToolTip);
|
|
}
|
|
|
|
[Test]
|
|
public void AnActionThatCannotRunSaysWhy()
|
|
{
|
|
var candidate = Copy(CopyState.Candidate);
|
|
Assert.Null(CopyText.Blocked(candidate, CopyAction.Integrate, SignedIn));
|
|
// A pair of another server needs that server signed in; the answers that move nothing never do.
|
|
var signedOut = new CopyRights(null, null, false, false);
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.SignIn", Nas), CopyText.Blocked(candidate, CopyAction.Compare, signedOut));
|
|
Assert.Null(CopyText.Blocked(candidate, CopyAction.KeepApart, signedOut));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.NeedsNewerServer"), CopyText.Blocked(candidate, CopyAction.Integrate, SignedIn with { CanIntegrate = false }));
|
|
Assert.Equal(Loc.L("Errors.Copies.Busy"), CopyText.Blocked(candidate, CopyAction.Integrate, SignedIn with { Busy = true }));
|
|
Assert.Null(CopyText.Blocked(candidate, CopyAction.Compare, SignedIn with { Busy = true }));
|
|
var gone = Copy(CopyState.Linked, gone: true);
|
|
Assert.Equal(Loc.L("Tooltips.Server.Sync.UploadAll.NoRight"), CopyText.Blocked(gone, CopyAction.UploadAgain, SignedIn with { CanUpload = false }));
|
|
// A local pair needs no server.
|
|
Assert.Null(CopyText.Blocked(Copy(CopyState.Candidate, CopyKind.LocalLocal), CopyAction.Merge, signedOut));
|
|
// The tooltip of a disabled button is its reason.
|
|
Assert.Equal(Loc.L("Errors.Copies.Busy"), CopyText.ToolTip(candidate, CopyAction.Integrate, SignedIn with { Busy = true }));
|
|
}
|
|
|
|
[Test]
|
|
public void AttentionComesFirstThenTheStrongerHints()
|
|
{
|
|
var kept = View(Copy(CopyState.KeptApart) with { Score = Score(hints: 900) }, "Aurora");
|
|
var weak = View(Copy(CopyState.Candidate) with { Score = Score(hints: 100) }, "Bridge");
|
|
var strong = View(Copy(CopyState.Candidate) with { Score = Score(hints: 800) }, "Comet");
|
|
Assert.SequenceEqual(["Comet", "Bridge", "Aurora"], CopyText.Sorted([kept, weak, strong]).Select(p => p.Here.Title));
|
|
Assert.True(CopyText.Matches(strong, "com"));
|
|
Assert.True(CopyText.Matches(strong, "Comet (nas)"));
|
|
Assert.False(CopyText.Matches(strong, "Aurora"));
|
|
}
|
|
|
|
[Test]
|
|
public void EveryWordResolvesInEnglishAndItalianAndLabelsStayShort()
|
|
{
|
|
var missing = new List<string>();
|
|
void OnMissing(string key) => missing.Add(key);
|
|
Loc.MissingKey += OnMissing;
|
|
try
|
|
{
|
|
foreach (var culture in new[] { "en", "it" })
|
|
{
|
|
Loc.SetCulture(CultureInfo.GetCultureInfo(culture));
|
|
var gone = Copy(CopyState.Linked, gone: true);
|
|
foreach (var action in Enum.GetValues<CopyAction>())
|
|
{
|
|
var label = CopyText.Label(action);
|
|
Assert.LessOrEqual(label.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length, 3, $"{culture}: \"{label}\" is at most three words");
|
|
Assert.False(string.IsNullOrWhiteSpace(CopyText.ToolTip(gone, action, SignedIn)), $"{culture}: {action} has a tooltip");
|
|
}
|
|
foreach (var c in Enum.GetValues<PhotoClass>())
|
|
{
|
|
Assert.False(string.IsNullOrWhiteSpace(CopyText.Class(c)), $"{culture}: {c}");
|
|
foreach (var policy in Enum.GetValues<CopyPhotoPolicy>())
|
|
{
|
|
foreach (var merge in new[] { false, true })
|
|
Assert.False(string.IsNullOrWhiteSpace(CopyText.ClassToolTip(c, policy, merge)), $"{culture}: {c} has a tooltip under {policy}");
|
|
}
|
|
}
|
|
foreach (var block in Enum.GetValues<CopyBlock>())
|
|
Assert.False(string.IsNullOrWhiteSpace(CopyText.Block(block, "Lighthouse", "Studio NAS", "2 GB", 2)), $"{culture}: {block}");
|
|
foreach (var state in Enum.GetValues<CopyState>())
|
|
{
|
|
foreach (var copy in new[] { Copy(state), Copy(state, deletedThere: 2), Copy(state, gone: true), Copy(state, CopyKind.LocalLocal, deletedThere: 2) })
|
|
{
|
|
var (_, text, tip) = CopyText.State(copy, "Studio NAS", (1, 4));
|
|
Assert.False(string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(tip), $"{culture}: {state}");
|
|
}
|
|
}
|
|
foreach (var why in Enum.GetValues<UploadSkip>())
|
|
Assert.False(string.IsNullOrWhiteSpace(SyncText.State(Entry(SyncStatus.LocalOnly, link: null), new SyncMark(null, why)).ToolTip), $"{culture}: {why}");
|
|
Assert.False(string.IsNullOrWhiteSpace(SyncText.ToolTip(Entry(SyncStatus.InSync), SyncAction.Compare)), $"{culture}: Compare has a tooltip");
|
|
Assert.Equal(Loc.L("Server.Copies.Detail.OtherSetting"), SyncText.DetailLabel("nothing.known"));
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
Loc.MissingKey -= OnMissing;
|
|
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
|
}
|
|
Assert.Empty(missing);
|
|
}
|
|
|
|
[Test]
|
|
public void ASyncRowInAMatchSaysSoAndOffersCompare()
|
|
{
|
|
var entry = Entry(SyncStatus.LocalOnly, link: null);
|
|
// The Matches chip lists pairs, never sync rows.
|
|
Assert.False(SyncText.Matches(entry, SyncFilter.FoundCopies, string.Empty));
|
|
|
|
var editor = SyncRights.Of((long)RolePermissions.Default(UserRole.Editor));
|
|
var candidate = new SyncMark(Copy(CopyState.Candidate), null, "Studio NAS");
|
|
var (kind, text, tip) = SyncText.State(entry, candidate);
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Sync.State.CopyFound")), (kind, text));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Sync.State.CopyFound", "Studio NAS"), tip);
|
|
Assert.SequenceEqual([SyncAction.Compare, SyncAction.Upload], SyncText.Actions(entry, editor, candidate));
|
|
|
|
// A linked row offers Compare last; one without a pair, nothing more.
|
|
var linked = Entry(SyncStatus.InSync);
|
|
Assert.SequenceEqual([SyncAction.Compare], SyncText.Actions(linked, editor, new SyncMark(Copy(CopyState.Linked), null)));
|
|
Assert.Empty(SyncText.Actions(linked, editor, default));
|
|
|
|
// Deleted on the server, or kept here after that.
|
|
Assert.Equal(Loc.L("Server.Sync.State.RemoteGone"), SyncText.State(linked, new SyncMark(Copy(CopyState.Linked, gone: true), null)).Text);
|
|
Assert.Equal(Loc.L("Server.Sync.State.KeptHere"), SyncText.State(linked, new SyncMark(Copy(CopyState.KeptApart, gone: true), null)).Text);
|
|
|
|
// Upload all local left it out: "skipped", with the reason, under the Warning glyph (design §6.4).
|
|
var skipped = SyncText.State(entry, new SyncMark(null, UploadSkip.KeptApart));
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Sync.State.Skipped")), (skipped.Kind, skipped.Text));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Sync.State.Skipped", Loc.L("Tooltips.Server.Sync.Skip.KeptApart")), skipped.ToolTip);
|
|
// A transfer still shows first.
|
|
var upload = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.UploadCommit, State = JobState.Running };
|
|
Assert.Equal(SyncText.State(entry with { Transfer = upload }), SyncText.State(entry with { Transfer = upload }, candidate));
|
|
}
|
|
|
|
[Test]
|
|
public void TheOwnerReview6TextsFitTheirPlaces()
|
|
{
|
|
// Integrating: the share in the cell, "x of y" in the tooltip.
|
|
var (_, text, tip) = CopyText.State(Copy(CopyState.Integrating), progress: (1_234, 2_400));
|
|
Assert.Equal(Loc.L("Server.Copies.State.Integrating", "51"), text);
|
|
Assert.Contains(Loc.L("Server.Copies.State.Progress", "1,234", "2,400"), tip);
|
|
Assert.Equal(Loc.L("Server.Copies.State.Integrating", "0"), CopyText.State(Copy(CopyState.Integrating)).Text);
|
|
|
|
// The count comes first, so a trimmed cell keeps what tells two pairs apart.
|
|
Assert.True(CopyText.Where(Facts("Lighthouse", "Main archive", 1_204), isServer: false).StartsWith("1,204", StringComparison.Ordinal));
|
|
// A server that deleted its sequence is named alone, never "0 photos".
|
|
Assert.Equal("Studio NAS", CopyText.Where(Facts(string.Empty, "Studio NAS", 0), isServer: true, gone: true));
|
|
|
|
// The frame positions read as the setting they are, with the count of photos they place.
|
|
Assert.Equal(Loc.L("Server.Copies.Detail.Positions"), SyncText.DetailLabel(CopyPayload.PendingFramesPath));
|
|
Assert.Equal(Loc.Plural("Shell.Status.Photos", 2), SyncText.DetailValue(CopyPayload.PendingFramesPath, "{\"a\":{},\"b\":{}}"));
|
|
Assert.Equal("Lighthouse", SyncText.DetailValue("sequence.title", "Lighthouse"));
|
|
Assert.Equal("41", SyncText.DetailValue("exposure.deflickerWindow.manual", "41"));
|
|
Assert.Equal(Loc.L("Server.Copies.Detail.Changed"), SyncText.DetailValue("exposure.curve", "{\"points\":[[0,0],[1,1]]}"));
|
|
// The members of one setting are one row and one choice.
|
|
Assert.Equal(SyncText.DetailSetting("exposure.deflickerWindow.isAuto"), SyncText.DetailSetting("exposure.deflickerWindow.manual"));
|
|
var row = new CopyDetailRow([new DetailLine("exposure.deflickerWindow.isAuto", "true", "false"), new DetailLine("exposure.deflickerWindow.manual", "41", "33")],
|
|
isMerge: false, () => { });
|
|
Assert.SequenceEqual(["exposure.deflickerWindow.isAuto", "exposure.deflickerWindow.manual"], row.Paths);
|
|
Assert.Equal(string.Join(Loc.Separator, Loc.L("Server.Setting.Auto"), "41"), row.HereText);
|
|
|
|
// A match between this PC's archives names the other archive, not the server.
|
|
var local = new SyncMark(Copy(CopyState.Candidate, CopyKind.LocalLocal), null, "Studio NAS", OtherWhere: "Old archive");
|
|
Assert.Equal(Loc.L("Tooltips.Library.Status.CopyFoundLocal", "Old archive"), SyncText.State(Entry(SyncStatus.LocalOnly, link: null), local).ToolTip);
|
|
|
|
// The Library card of a sequence whose server copy was deleted says so.
|
|
var gone = View(Copy(CopyState.Linked, gone: true), "Lighthouse");
|
|
var status = CopyListViewModel.LibraryStatus(gone, Local.Id);
|
|
Assert.Equal(Loc.L("Library.Status.RemoteGone"), status.Text);
|
|
|
|
// A plan line is what will happen (queued), a warning leads.
|
|
Assert.Equal(StatusKind.Queued, new CopyPlanLine("Receives 2 photos").Kind);
|
|
Assert.Equal(StatusKind.Warning, new CopyPlanLine("Only copy", IsWarning: true).Kind);
|
|
}
|
|
|
|
[Test]
|
|
public void TheReplaceConfirmationListsEachSidesLosersUnderItsHeading()
|
|
{
|
|
var trashed = new List<PhotoStep>
|
|
{
|
|
new("a", PhotoAction.TrashHere, Guid.NewGuid(), "IMG_0001.JPG", 10, "a"),
|
|
new("b", PhotoAction.TrashHere, Guid.NewGuid(), "IMG_0002.JPG", 10, "b"),
|
|
new("c", PhotoAction.TrashThere, Guid.NewGuid(), "IMG_0003.JPG", 10, "c"),
|
|
};
|
|
var lasts = new List<LastCopy> { new("b", CopySide.ThisPc, "IMG_0002.JPG", 10) };
|
|
|
|
var lines = CopyDialogViewModel.ReplaceLines(lasts, trashed, "Studio NAS").Split(Environment.NewLine);
|
|
|
|
Assert.SequenceEqual(
|
|
[
|
|
Loc.L("Server.Copies.Plan.OnThisPc"),
|
|
" " + Loc.L("Server.Copies.Confirm.LastCopy", "IMG_0002.JPG"),
|
|
" IMG_0001.JPG",
|
|
Loc.L("Server.Copies.Plan.OnServer", "Studio NAS"),
|
|
" IMG_0003.JPG",
|
|
], lines);
|
|
}
|
|
|
|
[Test]
|
|
public void ThePairWordsFollowWhatTheRunReallyDoes()
|
|
{
|
|
// An Integrate that left photos out moves new photos only by hand; one that left nothing out, by itself.
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.State.IntegratedByHand"), CopyText.State(Copy(CopyState.Integrated)).ToolTip);
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.State.Integrated"), CopyText.State(Copy(CopyState.Integrated) with { AutoPhotos = true }).ToolTip);
|
|
|
|
// A pair of this PC's archives is merged, with the same "x of y".
|
|
var (_, text, tip) = CopyText.State(Copy(CopyState.Integrating, CopyKind.LocalLocal), progress: (1, 4));
|
|
Assert.Equal(Loc.L("Server.Copies.State.Merging", "25"), text);
|
|
Assert.Equal(string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State.Merging"), Loc.L("Server.Copies.State.Progress", "1", "4")), tip);
|
|
// The row follows a merge's progress as it follows an Integrate's.
|
|
Assert.True(CopyListViewModel.Follows(JobKind.MergeSequences));
|
|
Assert.True(CopyListViewModel.Follows(JobKind.Integrate));
|
|
Assert.False(CopyListViewModel.Follows(JobKind.UploadCommit));
|
|
|
|
// A class says what the chosen policy does with it, and a merge says it its own way.
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs"), CopyText.ClassToolTip(PhotoClass.Differs));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.ThisPcWins"), CopyText.ClassToolTip(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.KeptWins"), CopyText.ClassToolTip(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins, isMerge: true));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyHere.Choose"), CopyText.ClassToolTip(PhotoClass.OnlyHere, CopyPhotoPolicy.ChoosePerPhoto));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyThere.Merge"), CopyText.ClassToolTip(PhotoClass.OnlyThere, CopyPhotoPolicy.ChoosePerPhoto, isMerge: true));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.SameUnhashed.Integrate"), CopyText.ClassToolTip(PhotoClass.SameUnhashed));
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.SameUnhashed"), CopyText.ClassToolTip(PhotoClass.SameUnhashed, isMerge: true));
|
|
|
|
// The class row follows the dialog's policy, and a merge keeping the other sequence reads its classes from the kept side.
|
|
var differs = new CopyClassRow(new PhotoClassTotal(PhotoClass.Differs, 2, 51_400_000, 51_800_000));
|
|
differs.Policy = CopyPhotoPolicy.OtherWins;
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.OtherWins"), differs.ToolTip);
|
|
var onlyHere = new CopyClassRow(new PhotoClassTotal(PhotoClass.OnlyHere, 38, 570_000_000, 0), CopyPhotoPolicy.Union, isMerge: true) { Swapped = true };
|
|
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyThere.Merge"), onlyHere.ToolTip);
|
|
|
|
// The size cell shows the bytes of the side that holds them; both sides in the tooltip when both do.
|
|
var onlyThere = new CopyClassRow(new PhotoClassTotal(PhotoClass.OnlyThere, 3, 0, 45_000_000));
|
|
Assert.Equal(Formatting.Bytes(45_000_000), onlyThere.BytesText);
|
|
Assert.Equal(Loc.L("Server.Copies.Detail.Server") + " " + Formatting.Bytes(45_000_000), onlyThere.BytesToolTip);
|
|
Assert.Equal(Formatting.Bytes(51_400_000), differs.BytesText);
|
|
Assert.Equal(string.Join(Loc.Separator, Loc.L("Server.Copies.Detail.ThisPc") + " " + Formatting.Bytes(51_400_000),
|
|
Loc.L("Server.Copies.Detail.Server") + " " + Formatting.Bytes(51_800_000)), differs.BytesToolTip);
|
|
}
|
|
|
|
[Test]
|
|
public void ASyncRowOfAPairWhoseMatchDeletedPhotosSaysSoAndOffersReview()
|
|
{
|
|
var entry = Entry(SyncStatus.InSync);
|
|
var editor = SyncRights.Of((long)RolePermissions.Default(UserRole.Editor));
|
|
foreach (var state in new[] { CopyState.Linked, CopyState.Integrated })
|
|
{
|
|
var mark = new SyncMark(Copy(state, deletedThere: 3), null);
|
|
Assert.Equal((StatusKind.Warning, Loc.L("Server.Copies.State.DeletedThere", "3"), Loc.Plural("Tooltips.Server.Copies.State.DeletedThere", 3)),
|
|
SyncText.State(entry, mark));
|
|
Assert.SequenceEqual([SyncAction.Compare, SyncAction.Review], SyncText.Actions(entry, editor, mark).TakeLast(2));
|
|
Assert.False(string.IsNullOrWhiteSpace(SyncText.ToolTip(entry, SyncAction.Review)));
|
|
}
|
|
// Nothing deleted: the ordinary sync state, Compare last.
|
|
Assert.Equal(SyncText.State(entry), SyncText.State(entry, new SyncMark(Copy(CopyState.Linked), null)));
|
|
Assert.Equal(SyncAction.Compare, SyncText.Actions(entry, editor, new SyncMark(Copy(CopyState.Linked), null))[^1]);
|
|
}
|
|
|
|
[Test]
|
|
public void TheMatchStatusComesRightAfterTheAnalysisStatus()
|
|
{
|
|
var analysed = new Chronos.Ui.Visuals.CardStatus(StatusKind.Analysed, "Analysed");
|
|
var proxies = new Chronos.Ui.Visuals.CardStatus(StatusKind.Done, "Proxies");
|
|
var synced = new Chronos.Ui.Visuals.CardStatus(StatusKind.Synced, "Synced");
|
|
var match = new Chronos.Ui.Visuals.CardStatus(StatusKind.Warning, "Also elsewhere");
|
|
Assert.SequenceEqual([analysed, match, proxies, synced], Chronos.App.Library.SequenceItem.WithMatch([analysed, proxies, synced], match));
|
|
Assert.SequenceEqual([analysed, proxies], Chronos.App.Library.SequenceItem.WithMatch([analysed, proxies], null));
|
|
}
|
|
|
|
[Test]
|
|
public void TheMatchWordsNeverUseTheNounCopy()
|
|
{
|
|
// Design §1.1: the duplicates report owns "copy/copie"; a match is a sequence twice. The photo-level "last copy"
|
|
// and the verb "copy" stay.
|
|
string[] areas = ["Server.Copies.", "Server.Sync.Skip.", "Server.Sync.State.", "Library.Status.", "Settings.Copy", "Errors.Copies."];
|
|
string[] allowed =
|
|
[
|
|
"Server.Copies.Projects.CopyAcross", "Server.Copies.Plan.LastCopies.one", "Server.Copies.Plan.LastCopies.other",
|
|
"Server.Copies.Confirm.LastCopy", "Tooltips.Server.Copies.ToTrashSequence", "Tooltips.Server.Copies.Bring",
|
|
];
|
|
var noun = new System.Text.RegularExpressions.Regex(@"\b(copy|copie)\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
|
var found = new List<string>();
|
|
foreach (var culture in new[] { "en", "it" })
|
|
{
|
|
foreach (var file in Directory.EnumerateFiles(Path.Combine(TestContext.RepositoryRoot, "i18n", culture), "*.resx"))
|
|
{
|
|
foreach (var data in System.Xml.Linq.XDocument.Load(file).Root!.Elements("data"))
|
|
{
|
|
var name = (string)data.Attribute("name")!;
|
|
var bare = name.StartsWith("Tooltips.", StringComparison.Ordinal) ? name["Tooltips.".Length..] : name;
|
|
if (!areas.Any(a => bare.StartsWith(a, StringComparison.Ordinal)) || allowed.Contains(name)) continue;
|
|
if (noun.IsMatch((string?)data.Element("value") ?? string.Empty)) found.Add($"{culture}: {name}");
|
|
}
|
|
}
|
|
}
|
|
Assert.Empty(found);
|
|
}
|
|
|
|
[Test]
|
|
public void APlanCountsAsSecondVersionsOnlyThoseKeptBesideTheirPair()
|
|
{
|
|
// Union keeps "a" beside its pair; This PC wins replaces "b" (its loser goes to the trash on the same side).
|
|
var steps = new List<PhotoStep>
|
|
{
|
|
new("a", PhotoAction.SendVersion, Guid.NewGuid(), "IMG_0001.JPG", 10, "a"),
|
|
new("b", PhotoAction.SendVersion, Guid.NewGuid(), "IMG_0002.JPG", 10, "b"),
|
|
new("b", PhotoAction.TrashThere, Guid.NewGuid(), "IMG_0002.JPG", 10, "b2"),
|
|
new("c", PhotoAction.FetchVersion, Guid.NewGuid(), "IMG_0003.JPG", 10, "c"),
|
|
new("c", PhotoAction.TrashHere, Guid.NewGuid(), "IMG_0003.JPG", 10, "c2"),
|
|
};
|
|
Assert.Equal(1, CopyDialogViewModel.KeptVersions(steps, PhotoAction.SendVersion, PhotoAction.TrashThere));
|
|
Assert.Equal(0, CopyDialogViewModel.KeptVersions(steps, PhotoAction.FetchVersion, PhotoAction.TrashHere));
|
|
}
|
|
|
|
private static (StatusKind, string) Head((StatusKind Kind, string Text, string ToolTip) state) => (state.Kind, state.Text);
|
|
|
|
private static FoundCopy Copy(CopyState state, CopyKind kind = CopyKind.LocalServer, int deletedThere = 0, bool gone = false) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = kind,
|
|
LocalId = Local.Id,
|
|
Server = kind == CopyKind.LocalServer ? Nas : null,
|
|
RemoteId = kind == CopyKind.LocalServer ? Link.RemoteId : null,
|
|
OtherId = kind == CopyKind.LocalLocal ? Guid.CreateVersion7() : null,
|
|
Evidence = CopyEvidence.Hashes,
|
|
State = state,
|
|
Score = Score(deletedThere: deletedThere),
|
|
Fingerprint = "f",
|
|
RemoteGoneHits = gone ? 2 : 0,
|
|
UpdatedAt = new DateTimeOffset(2026, 11, 16, 9, 0, 0, TimeSpan.Zero),
|
|
};
|
|
|
|
private static CopyScore Score(int deletedThere = 0, int hints = 500) =>
|
|
new(1_178, 0, 0, 24, 0, 2, 0, deletedThere, 0, 1_204, 1_180, 980, 960, hints);
|
|
|
|
private static FoundCopyView View(FoundCopy copy, string title) =>
|
|
new(copy, Facts(title, "Main archive", 1_204), Facts(title + " (nas)", "Studio NAS", 1_180));
|
|
|
|
private static CopyFacts Facts(string title, string where, int photos) =>
|
|
new(title, where, null, photos, photos * 15_000_000L, null, null, null, photos, null, [], false);
|
|
|
|
private static SyncEntry Entry(SyncStatus status, SyncLink? link = null) =>
|
|
new(Local, status == SyncStatus.LocalOnly ? link : link ?? Link, status, null);
|
|
}
|