feat(app): matches list, compare dialog, settings rows, library and picker surfaces (owner review 6, P6)
Server > Matches shows the pairs the copy engine found (same sequence on the server and this PC, or twice here), attention first, with the design 8.1 actions; Keep apart and Unlink toast with Undo. The in-window Compare dialog walks photos, details, projects and the plan, blocks until details are chosen, and confirms only what replaces or merges (typed count for a merge). Sync rows of an unanswered pair read "match found" and offer Compare first; Upload all local skips suspected copies and says why. Settings > Server gains Link matches, Integrate photos and Integrate projects. Library cards carry the match status with Compare..., the sequence picker marks twins, and Jobs opens Integrate and Merge targets. The sample engine and capture scenes render every state; tests cover the text rules and the screens. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
283d04d9cd
commit
06b826e39d
34 files changed
+3762
-43
No files matched your search
@@ -0,0 +1,193 @@
|
||||
using System.Windows.Controls;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Library;
|
||||
using Chronos.App.Sections;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.App.Server.Copies;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Tests.Windows;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Controls;
|
||||
|
||||
namespace Chronos.App.Tests.Server;
|
||||
|
||||
/// <summary>
|
||||
/// Server › Matches on the capture sample pairs (owner review 6, #73): the list and its chip, the Compare dialog in the
|
||||
/// window, its plan and blocks, the confirmations, the Library's match cards and the Settings rows.
|
||||
/// </summary>
|
||||
[WindowsOnly]
|
||||
[Serial]
|
||||
[Timeout(300_000)]
|
||||
public sealed class CopyScreenSmokeTests
|
||||
{
|
||||
[Test]
|
||||
public Task TheMatchesListOrdersThePairsAndEveryActionSaysWhatItDoes() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await StartAsync();
|
||||
var shell = app.Shell;
|
||||
var table = shell.Server.Sync;
|
||||
var list = table.Copies;
|
||||
await CopyScenes.ShowAsync(shell, "server-copies");
|
||||
|
||||
Assert.True(table.IsMatches);
|
||||
Assert.True(table.ShowCopyList, "the Matches list replaces the sync table");
|
||||
Assert.GreaterOrEqual(list.Count, 5);
|
||||
Assert.Equal(list.Count, table.Chips.Single(c => c.Filter == SyncFilter.FoundCopies).Count);
|
||||
Assert.True(list.AttentionCount > 0);
|
||||
// Pairs that ask for a choice come first.
|
||||
Assert.True(list.Rows[0].IsConflict);
|
||||
Assert.True(list.Rows.SkipWhile(r => r.IsConflict).All(r => !r.IsConflict), "attention first, then the rest");
|
||||
foreach (var row in list.Rows)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(row.StateToolTip), $"{row.Title}: the state has a tooltip");
|
||||
foreach (var action in row.Actions)
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(action.ToolTip), $"{row.Title}: {action.Text} has a tooltip");
|
||||
Assert.LessOrEqual(action.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length, 3, $"\"{action.Text}\" is at most three words");
|
||||
}
|
||||
}
|
||||
var lighthouse = list.Rows.Single(r => r.Title == CopyScenes.Lighthouse);
|
||||
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Integrate, CopyAction.KeepApart], lighthouse.Actions.Select(a => a.Action));
|
||||
Assert.SequenceEqual([CopyAction.Compare, CopyAction.Merge, CopyAction.KeepApart],
|
||||
list.Rows.Single(r => r.Title == CopyScenes.Alps).Actions.Select(a => a.Action));
|
||||
await app.ExpectAsync<ServerView>("server-copies");
|
||||
|
||||
// The search narrows the pairs, by either title.
|
||||
table.SearchText = "Alps";
|
||||
Assert.Count(1, list.Rows);
|
||||
table.SearchText = string.Empty;
|
||||
|
||||
// The sync table marks the sequence of an unanswered pair and offers Compare… first.
|
||||
table.ShowFilter(SyncFilter.All);
|
||||
var marked = table.Rows.First(r => r.Title == CopyScenes.Lighthouse);
|
||||
Assert.Equal(Loc.L("Server.Sync.State.CopyFound"), marked.StateText);
|
||||
Assert.Equal(SyncAction.Compare, marked.Actions[0].Action);
|
||||
CopyScenes.Reset(shell);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task TheCompareDialogWaitsForTheDetailsAndConfirmsWhatItReplaces() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await StartAsync();
|
||||
var shell = app.Shell;
|
||||
var server = shell.Server;
|
||||
var list = server.Sync.Copies;
|
||||
await CopyScenes.ShowAsync(shell, "server-copies");
|
||||
|
||||
// Integrate… opens on the details while one waits for a choice.
|
||||
var pair = list.Pairs.Single(p => p.Here.Title == CopyScenes.Lighthouse);
|
||||
var dialog = Assert.NotNull(list.Open(pair, CopyDialogPart.Plan, integrate: true));
|
||||
await dialog.LoadAsync();
|
||||
Assert.True(server.IsDialogOpen);
|
||||
Assert.False(server.IsContentEnabled, "the screen behind the dialog takes no input");
|
||||
Assert.Equal(CopyDialogPart.Details, dialog.Part);
|
||||
Assert.Equal(3, dialog.Unchosen);
|
||||
await app.ExpectAsync<ServerView>("server-copies-details");
|
||||
|
||||
// The footer: one primary action, Cancel answers Esc; both say what they do.
|
||||
var cancel = app.FindAll<Button>().Single(b => b.IsVisible && b.IsCancel);
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Copies.Cancel"), cancel.ToolTip);
|
||||
Assert.Contains(app.FindAll<Button>(), b => b.IsVisible && b.Content as string == dialog.ApplyText && b.ToolTip is not null);
|
||||
|
||||
// The plan is blocked until every detail is chosen; the block line offers Choose.
|
||||
dialog.Part = CopyDialogPart.Plan;
|
||||
await dialog.PlanNowAsync();
|
||||
var block = Assert.Contains(dialog.Blocks, b => b.Block == CopyBlock.DetailsUnchosen);
|
||||
Assert.True(block.HasChoose);
|
||||
Assert.False(dialog.ApplyCommand.CanExecute(null));
|
||||
Assert.Equal(block.Text, dialog.ApplyToolTip);
|
||||
dialog.AllHereCommand.Execute(null);
|
||||
Assert.Equal(0, dialog.Unchosen);
|
||||
await dialog.PlanNowAsync();
|
||||
Assert.False(dialog.Blocks.Any(b => b.Block == CopyBlock.DetailsUnchosen), "every detail chosen");
|
||||
Assert.True(dialog.ApplyCommand.CanExecute(null));
|
||||
Assert.NotEmpty(dialog.HereLines);
|
||||
await app.ExpectAsync<ServerView>("server-copies-plan");
|
||||
|
||||
// This PC's version wins: the server's versions go to its trash, so the confirmation is destructive.
|
||||
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ThisPcWins);
|
||||
await dialog.PlanNowAsync();
|
||||
var replace = CopyDialogViewModel.ReplaceRequest(Assert.NotNull(dialog.Plan));
|
||||
Assert.True(replace.IsDestructive);
|
||||
Assert.Equal(Loc.L("Server.Copies.Confirm.Replace.Title"), replace.Heading);
|
||||
|
||||
// Cancel closes the dialog and gives the screen back.
|
||||
dialog.CloseCommand.Execute(null);
|
||||
Assert.False(server.IsDialogOpen);
|
||||
Assert.True(server.IsContentEnabled);
|
||||
|
||||
// A local pair merges into the kept copy, preselected; the confirmation asks for the dropped photo count.
|
||||
var merge = Assert.NotNull(await CopyScenes.ShowAsync(shell, "server-copies-merge"));
|
||||
Assert.True(merge.IsMerge);
|
||||
Assert.Count(2, merge.KeepOptions);
|
||||
Assert.Count(1, merge.KeepOptions.Where(o => o.IsChecked));
|
||||
merge.AllHereCommand.Execute(null);
|
||||
await merge.PlanNowAsync();
|
||||
var plan = Assert.NotNull(merge.MergePlan);
|
||||
var request = merge.MergeRequest(plan);
|
||||
Assert.True(request.IsDestructive);
|
||||
var dropped = list.Pairs.Single(p => p.Here.Title == CopyScenes.Alps) is var alps && plan.KeepId == alps.Copy.LocalId ? alps.There : alps.Here;
|
||||
Assert.Equal(dropped.Photos.ToString(Loc.Culture), request.TypedConfirmation);
|
||||
await app.ExpectAsync<ServerView>("server-copies-merge");
|
||||
CopyScenes.Reset(shell);
|
||||
Assert.False(server.IsDialogOpen);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task TheLibraryAndSettingsShowTheMatches() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await StartAsync();
|
||||
var shell = app.Shell;
|
||||
|
||||
// A card in a pair that asks for a choice carries the match status and offers Compare….
|
||||
await LibraryScenes.ShowCopiesAsync(shell, CopyScenes.Alps);
|
||||
var item = Assert.Contains(shell.Library.Items, i => i.HasMatch && i.Title == CopyScenes.Alps);
|
||||
Assert.NotNull(item.MatchStatus);
|
||||
Assert.Contains(item.Statuses, s => s == item.MatchStatus);
|
||||
Assert.True(shell.Library.CompareItemCommand.CanExecute(item));
|
||||
await app.ExpectAsync<LibraryView>("library-copies", waitForThumbnails: true);
|
||||
shell.Library.CompareItemCommand.Execute(item);
|
||||
Assert.Equal(SectionKey.Server, shell.Current.Key);
|
||||
Assert.True(shell.Server.Sync.IsMatches);
|
||||
Assert.Equal(CopyScenes.Alps, shell.Server.Sync.SearchText);
|
||||
CopyScenes.Reset(shell);
|
||||
|
||||
// Settings › Server: three rows, every option with its tooltip, each choice saved at once.
|
||||
var rows = shell.Settings.CopyRows;
|
||||
foreach (var option in rows.LinkingOptions.Cast<object>().Concat(rows.PhotoOptions).Concat(rows.ProjectOptions))
|
||||
{
|
||||
var (label, tip) = option switch
|
||||
{
|
||||
SettingsOption<CopyLinking> o => (o.Label, o.ToolTip),
|
||||
SettingsOption<CopyPhotoPolicy> o => (o.Label, o.ToolTip),
|
||||
SettingsOption<CopyProjects> o => (o.Label, o.ToolTip),
|
||||
_ => (string.Empty, null),
|
||||
};
|
||||
Assert.False(string.IsNullOrWhiteSpace(tip), $"{label} has a tooltip");
|
||||
Assert.LessOrEqual(label.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length, 3, $"\"{label}\" is at most three words");
|
||||
}
|
||||
rows.Linking = rows.LinkingOptions.First(o => o.Value == CopyLinking.WhenIdentical);
|
||||
Assert.Equal(CopyLinking.WhenIdentical, shell.Services.Settings.CopyLinking);
|
||||
shell.Navigate(SectionKey.Settings);
|
||||
shell.Settings.Page = SettingsPage.Server;
|
||||
await app.ExpectAsync<SettingsView>("settings-server");
|
||||
Assert.Contains(app.FindAll<ComboBox>(), c => c.IsVisible && Equals(c.SelectedItem, rows.Linking) && c.ToolTip is not null);
|
||||
});
|
||||
|
||||
private static async Task<ScreenSmokeTests.SampleApp> StartAsync()
|
||||
{
|
||||
var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
await shell.Services.Server.RestoreAsync();
|
||||
Assert.NotNull(await shell.Services.Sync.RefreshAsync());
|
||||
await app.Sample.FillCopiesAsync();
|
||||
await shell.Library.RefreshAsync();
|
||||
await shell.Server.Sync.ReloadAsync();
|
||||
return app;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
using System.Globalization;
|
||||
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}");
|
||||
Assert.False(string.IsNullOrWhiteSpace(CopyText.ClassToolTip(c)), $"{culture}: {c} has a tooltip");
|
||||
}
|
||||
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.
|
||||
var skipped = SyncText.State(entry, new SyncMark(null, UploadSkip.KeptApart));
|
||||
Assert.Equal((StatusKind.Offline, 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));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in new issue
Block a user