merge: client server mode (sync engine, Server screen sync table and conflicts, Library sync glyphs, render transfers)
Keeps the render node host from the processing branch and disposes the sync host after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
56 files changed
+6777
-25
No files matched your search
@@ -0,0 +1,151 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Server;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Windows;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Sync;
|
||||
using Titano.Testing;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Tests.Server;
|
||||
|
||||
/// <summary>The Server screen's sync table on the capture sample data: comparison, transfers, conflict and the Library's glyphs.</summary>
|
||||
[WindowsOnly]
|
||||
[Serial]
|
||||
[Timeout(300_000)]
|
||||
public sealed class ServerScreenSmokeTests
|
||||
{
|
||||
[Test]
|
||||
public Task TheSyncTableShowsEveryStateOfTheSample() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
await shell.Library.RefreshAsync();
|
||||
await shell.Services.Server.RestoreAsync();
|
||||
Assert.NotNull(await shell.Services.Sync.RefreshAsync());
|
||||
await app.Sample.CacheProxiesAsync();
|
||||
var table = shell.Server.Sync;
|
||||
await table.ReloadAsync();
|
||||
|
||||
// 36 sequences here (6 also on the server) and 2 only on the server; the conflict is listed first.
|
||||
Assert.True(table.IsActive);
|
||||
Assert.Equal(38, table.Rows.Count);
|
||||
Assert.Equal("Holy grail · Monviso", table.Rows[0].Title);
|
||||
Assert.True(table.Rows[0].IsConflict);
|
||||
Assert.Equal(1, Chip(table, SyncFilter.Conflicts).Count);
|
||||
Assert.Equal(2, Chip(table, SyncFilter.Remote).Count);
|
||||
Assert.Equal(30, Chip(table, SyncFilter.LocalOnly).Count);
|
||||
Assert.Equal(SyncStatus.InSync, Row(table, "Harbour sunset").Entry.Status);
|
||||
Assert.Equal(SyncStatus.ServerAhead, Row(table, "Construction cam · week 38").Entry.Status);
|
||||
Assert.SequenceEqual([SyncAction.DownloadOriginals], Actions(Row(table, "Construction cam · week 38")));
|
||||
Assert.SequenceEqual([SyncAction.Upload], Actions(Row(table, "Milan skyline dusk")));
|
||||
Assert.SequenceEqual([SyncAction.GetExports], Actions(Row(table, "Star trails, Colle del Nivolet")));
|
||||
var sunrise = Row(table, "Sunrise over Superga");
|
||||
Assert.Equal(SyncStatus.ProxiesOnly, sunrise.Entry.Status);
|
||||
Assert.Equal(Loc.L("Server.Sync.Proxies"), sunrise.LocalText);
|
||||
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals], Actions(sunrise));
|
||||
Assert.SequenceEqual([SyncAction.Upload], Actions(Row(table, "Clouds over the Langhe")));
|
||||
var conflict = Row(table, "Holy grail · Monviso");
|
||||
Assert.Equal(StatusKind.Warning, conflict.StateKind);
|
||||
Assert.SequenceEqual([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth], Actions(conflict));
|
||||
Assert.Equal(Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.DeflickerWindow"), "41", "33"), conflict.StateToolTip);
|
||||
Assert.NotNull(table.LastSyncText);
|
||||
Assert.NotNull(table.ArchiveText);
|
||||
Assert.True(table.UploadAllCommand.CanExecute(null), "the table filled after the view bound");
|
||||
|
||||
// Resolving shows the plan first: what differs and which side is overwritten.
|
||||
var keepMine = SyncTableViewModel.ConflictRequest(conflict.Entry, SyncAction.KeepMine);
|
||||
Assert.True(keepMine.IsDestructive);
|
||||
Assert.Contains(Loc.L("Server.Setting.DeflickerWindow"), keepMine.Detail);
|
||||
Assert.False(SyncTableViewModel.ConflictRequest(conflict.Entry, SyncAction.SaveBoth).IsDestructive);
|
||||
|
||||
// The Library shows the real sync state of each local copy, in one word.
|
||||
var holyGrail = shell.Library.Items.Single(i => i.Title == "Holy grail · Monviso");
|
||||
Assert.Equal(SyncState.Conflict, holyGrail.Sequence.SyncState);
|
||||
Assert.Equal(StatusKind.Warning, holyGrail.Statuses[^1].Kind);
|
||||
Assert.Contains(shell.Library.Items.Single(i => i.Title == "Harbour sunset").Statuses, s => s.Kind == StatusKind.Synced);
|
||||
var milan = shell.Library.Items.Single(i => i.Title == "Milan skyline dusk").Statuses[^1];
|
||||
Assert.Equal((StatusKind.Synced, Loc.L("Library.Status.Synced")), (milan.Kind, milan.Text));
|
||||
|
||||
shell.Navigate(SectionKey.Server);
|
||||
await app.ExpectAsync<ServerView>("server");
|
||||
|
||||
// Tab walks the row buttons of every row: the rows take no focus, the list passes Tab on to their content.
|
||||
var list = app.FindAll<ListBox>().Single(l => l.Name == "SyncList");
|
||||
Assert.Equal(KeyboardNavigationMode.Continue, KeyboardNavigation.GetTabNavigation(list));
|
||||
var rowButtons = app.FindAll<Button>().Where(b => b.DataContext is SyncRowAction && b.IsVisible).ToList();
|
||||
Assert.True(rowButtons.Select(b => b.DataContext).OfType<SyncRowAction>().Count() > 3, "buttons of several rows are on screen");
|
||||
Assert.True(rowButtons.All(b => b.Focusable && b.IsTabStop), "every row button is a tab stop");
|
||||
|
||||
// Transfers in every state: the rows show what moves and offer Pause or Resume.
|
||||
await app.Sample.FillSyncAsync();
|
||||
await table.ReloadAsync();
|
||||
var comet = Row(table, "Comet over the ridge");
|
||||
Assert.Equal(SyncStatus.Transferring, comet.Entry.Status);
|
||||
Assert.SequenceEqual([SyncAction.Pause], Actions(comet));
|
||||
Assert.Contains("46", comet.ServerText);
|
||||
Assert.Equal(StatusKind.Queued, Row(table, "Fog lifting, Asti").StateKind);
|
||||
Assert.Equal((StatusKind.Running, Loc.L("Server.Sync.State.Downloading")), (Row(table, "Sunrise over Superga").StateKind, Row(table, "Sunrise over Superga").StateText));
|
||||
Assert.SequenceEqual([SyncAction.Resume], Actions(Row(table, "Lake Como storm")));
|
||||
await app.ExpectAsync<ServerView>("server-sync");
|
||||
|
||||
// A reload keeps the row's buttons (focus, tooltips and clicks survive progress and comparisons).
|
||||
var pause = comet.Actions[0];
|
||||
await table.ReloadAsync();
|
||||
Assert.Same(pause, Row(table, "Comet over the ridge").Actions[0]);
|
||||
|
||||
// The conflict filter leaves the one row waiting for a choice.
|
||||
Chip(table, SyncFilter.Conflicts).SelectCommand.Execute(null);
|
||||
Assert.Equal("Holy grail · Monviso", Assert.Contains(table.Rows, _ => true).Title);
|
||||
Assert.Count(1, table.Rows);
|
||||
await app.ExpectAsync<ServerView>("server-conflict");
|
||||
table.SearchText = "nothing like this";
|
||||
Assert.False(table.HasRows);
|
||||
Assert.NotNull(table.EmptyText);
|
||||
|
||||
// Another language relabels chips and rows at once.
|
||||
UiLanguage.Apply("it");
|
||||
try
|
||||
{
|
||||
Assert.Equal("Tutte · 38", Chip(table, SyncFilter.All).Text);
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task SigningOutEmptiesTheTable() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
await app.Sample.FillAsync();
|
||||
await shell.Services.Server.RestoreAsync();
|
||||
await shell.Services.Sync.RefreshAsync();
|
||||
await shell.Server.Sync.ReloadAsync();
|
||||
Assert.True(shell.Server.Sync.HasRows);
|
||||
|
||||
await shell.Services.Server.SignOutAsync();
|
||||
Assert.Null(await shell.Services.Sync.RefreshAsync());
|
||||
await shell.Server.Sync.ReloadAsync();
|
||||
|
||||
Assert.False(shell.Server.Sync.IsActive);
|
||||
Assert.False(shell.Server.Sync.HasRows);
|
||||
Assert.False(shell.Server.Sync.UploadAllCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Sync.UploadAll.NotConnected"), shell.Server.Sync.UploadAllToolTip);
|
||||
shell.Navigate(SectionKey.Server);
|
||||
await app.ExpectAsync<ServerView>("server-signedout-table");
|
||||
});
|
||||
|
||||
private static SyncFilterChip Chip(SyncTableViewModel table, SyncFilter filter) => table.Chips.Single(c => c.Filter == filter);
|
||||
|
||||
private static SyncRow Row(SyncTableViewModel table, string title) => table.Rows.Single(r => r.Title == title);
|
||||
|
||||
private static IEnumerable<SyncAction> Actions(SyncRow row) => row.Actions.Select(a => a.Action);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
using Titano.App.Server;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Sync;
|
||||
using Titano.Testing;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Tests.Server;
|
||||
|
||||
/// <summary>Words, glyphs and actions of the sync table rows (Server.html).</summary>
|
||||
public sealed class SyncTextTests
|
||||
{
|
||||
private static readonly SyncRights Editor = SyncRights.Of((long)RolePermissions.Default(UserRole.Editor));
|
||||
private static readonly SyncRights Viewer = SyncRights.Of((long)RolePermissions.Default(UserRole.Viewer));
|
||||
|
||||
private static readonly Sequence Local = new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ArchiveId = Guid.CreateVersion7(),
|
||||
Title = "Harbour sunset",
|
||||
Folder = "2026/harbour",
|
||||
FrameCount = 3_600,
|
||||
TotalBytes = 86_000_000_000,
|
||||
Status = SequenceStatus.ProxiesBuilt,
|
||||
SettingsJson = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":41}}}""",
|
||||
};
|
||||
|
||||
private static readonly SyncLink Link = new()
|
||||
{
|
||||
Server = "https://nas.local:8443",
|
||||
RemoteId = Guid.CreateVersion7(),
|
||||
Title = "Harbour sunset",
|
||||
TotalBytes = 61_000_000_000,
|
||||
RemoteStatus = SequenceStatus.ProxiesBuilt | SequenceStatus.ThumbsBuilt,
|
||||
RenderCount = 2,
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void RightsFollowTheServerPermissions()
|
||||
{
|
||||
Assert.Equal(new SyncRights(true, true, true), Editor);
|
||||
Assert.Equal(new SyncRights(false, false, false), Viewer);
|
||||
Assert.Equal(new SyncRights(false, true, false), SyncRights.Of((long)Permissions.RenderNode));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EachStateOffersItsActions()
|
||||
{
|
||||
Assert.SequenceEqual([SyncAction.Upload], SyncText.Actions(Entry(SyncStatus.LocalOnly, link: null), Editor));
|
||||
Assert.Empty(SyncText.Actions(Entry(SyncStatus.LocalOnly, link: null), Viewer));
|
||||
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals], SyncText.Actions(Entry(SyncStatus.RemoteOnly, local: null), Editor));
|
||||
Assert.SequenceEqual([SyncAction.OpenWithProxies], SyncText.Actions(Entry(SyncStatus.ProxiesOnly, local: null), Viewer));
|
||||
Assert.SequenceEqual([SyncAction.Upload], SyncText.Actions(Entry(SyncStatus.LocalAhead, Link with { MissingRemote = 4 }), Editor));
|
||||
Assert.SequenceEqual([SyncAction.DownloadOriginals], SyncText.Actions(Entry(SyncStatus.ServerAhead, Link with { MissingLocal = 2 }), Editor));
|
||||
Assert.SequenceEqual([SyncAction.SyncSettings], SyncText.Actions(Entry(SyncStatus.ServerAhead), Editor));
|
||||
Assert.SequenceEqual([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth], SyncText.Actions(Entry(SyncStatus.Conflict), Editor));
|
||||
Assert.Empty(SyncText.Actions(Entry(SyncStatus.InSync), Editor));
|
||||
|
||||
// Without the edit right nothing of this PC is sent: no "Keep mine", no settings push.
|
||||
Assert.SequenceEqual([SyncAction.TakeServer, SyncAction.SaveBoth], SyncText.Actions(Entry(SyncStatus.Conflict), Viewer));
|
||||
Assert.Empty(SyncText.Actions(Entry(SyncStatus.LocalAhead), Viewer));
|
||||
Assert.SequenceEqual([SyncAction.SyncSettings], SyncText.Actions(Entry(SyncStatus.ServerAhead), Viewer));
|
||||
|
||||
// Renders travel on request once the originals agree.
|
||||
var exports = Link with { ExportsToGet = 3, ExportsToGetBytes = 1_900_000_000, ExportsToSend = 1, ExportsToSendBytes = 600_000_000 };
|
||||
Assert.SequenceEqual([SyncAction.GetExports, SyncAction.SendExports], SyncText.Actions(Entry(SyncStatus.InSync, exports), Editor));
|
||||
Assert.SequenceEqual([SyncAction.GetExports], SyncText.Actions(Entry(SyncStatus.InSync, exports), Viewer));
|
||||
Assert.SequenceEqual([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth], SyncText.Actions(Entry(SyncStatus.Conflict, exports), Editor));
|
||||
Assert.Equal(Loc.Plural("Tooltips.Server.Sync.GetExports", 3, Titano.App.Infrastructure.Formatting.Bytes(1_900_000_000)),
|
||||
SyncText.ToolTip(Entry(SyncStatus.InSync, exports), SyncAction.GetExports));
|
||||
|
||||
Assert.SequenceEqual([SyncAction.Pause], SyncText.Actions(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running)), Editor));
|
||||
Assert.SequenceEqual([SyncAction.Pause], SyncText.Actions(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Queued)), Editor));
|
||||
Assert.SequenceEqual([SyncAction.Resume], SyncText.Actions(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Paused)), Editor));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ColumnsSayWhatEachSideHolds()
|
||||
{
|
||||
var originals = Loc.L("Server.Sync.Originals");
|
||||
var proxies = Loc.L("Server.Sync.Proxies");
|
||||
Assert.Equal($"{originals} · {proxies}", SyncText.Local(Entry(SyncStatus.InSync)));
|
||||
Assert.Equal(originals, SyncText.Local(Entry(SyncStatus.InSync, local: Local with { Status = SequenceStatus.None })));
|
||||
Assert.Equal(proxies, SyncText.Local(Entry(SyncStatus.ProxiesOnly, Link with { ProxiesCached = 10 }, local: null)));
|
||||
Assert.Equal(Loc.L("Server.Sync.None"), SyncText.Local(Entry(SyncStatus.RemoteOnly, local: null)));
|
||||
|
||||
Assert.Equal($"{originals} · {proxies} · {Loc.Plural("Server.Sync.Exports", 2)}", SyncText.Server(Entry(SyncStatus.InSync)));
|
||||
Assert.Equal(Loc.L("Server.Sync.None"), SyncText.Server(Entry(SyncStatus.LocalOnly, link: null)));
|
||||
var uploading = Entry(SyncStatus.Transferring, link: null, transfer: Upload(JobState.Running) with { ProgressDone = 462, ProgressTotal = 1_005 });
|
||||
Assert.Equal(Loc.L("Server.Sync.Received", Loc.L("Common.Percent", "46")), SyncText.Server(uploading));
|
||||
Assert.Equal(86_000_000_000, SyncText.Size(Entry(SyncStatus.LocalOnly, link: null), SyncAction.Upload));
|
||||
Assert.Equal(61_000_000_000, SyncText.Size(Entry(SyncStatus.RemoteOnly, local: null), SyncAction.DownloadOriginals));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StatesPairAGlyphWithAWord()
|
||||
{
|
||||
Assert.Equal((StatusKind.Done, Loc.L("Server.Sync.State.InSync")), Kind(Entry(SyncStatus.InSync)));
|
||||
Assert.Equal((StatusKind.Offline, Loc.L("Server.Sync.State.LocalOnly")), Kind(Entry(SyncStatus.LocalOnly, link: null)));
|
||||
Assert.Equal((StatusKind.Remote, Loc.L("Server.Sync.State.RemoteOnly")), Kind(Entry(SyncStatus.RemoteOnly, local: null)));
|
||||
Assert.Equal((StatusKind.Warning, Loc.L("Server.Sync.State.Conflict")), Kind(Entry(SyncStatus.Conflict)));
|
||||
Assert.Equal((StatusKind.Running, Loc.L("Server.Sync.State.Uploading")), Kind(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running))));
|
||||
Assert.Equal((StatusKind.Paused, Loc.L("Server.Sync.State.Paused")), Kind(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Paused))));
|
||||
Assert.Equal((StatusKind.Running, Loc.L("Server.Sync.State.Downloading")),
|
||||
Kind(Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running) with { Kind = JobKind.Download })));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AConflictNamesTheSettingsThatDifferInWords()
|
||||
{
|
||||
var theirs = new SyncPayload(Local.Title, ["boats"], 0, null, """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":33},"deflicker":{"isAuto":false,"manual":true}}}""");
|
||||
var conflict = Entry(SyncStatus.Conflict, Link with { ConflictRemote = theirs });
|
||||
|
||||
var lines = SyncText.Conflict(conflict, 10);
|
||||
|
||||
Assert.SequenceEqual(
|
||||
[
|
||||
Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.Tags"), Loc.L("Server.Sync.None"), "boats"),
|
||||
Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.Deflicker"), Loc.L("Server.Setting.Auto"), Loc.L("Server.Setting.Manual")),
|
||||
Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.DeflickerWindow"), "41", "33"),
|
||||
], lines);
|
||||
// The State tooltip is one line: the first difference and how many more.
|
||||
Assert.Equal(Loc.L("Server.Conflict.More", lines[0], "2"), SyncText.State(conflict).ToolTip);
|
||||
Assert.False(SyncText.State(conflict).ToolTip.Contains('\n', StringComparison.Ordinal), "one line");
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Sync.State.Conflict"), SyncText.ConflictSummary(Entry(SyncStatus.Conflict)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ASequenceThatCouldNotBeComparedSaysWhy()
|
||||
{
|
||||
var (kind, text, tip) = SyncText.State(Entry(SyncStatus.InSync, Link with { Error = "403 forbidden" }));
|
||||
|
||||
Assert.Equal((StatusKind.Warning, Loc.L("Server.Sync.State.Failed")), (kind, text));
|
||||
Assert.Contains("403 forbidden", tip);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FiltersAndSearchSelectRows()
|
||||
{
|
||||
var rows = new[]
|
||||
{
|
||||
Entry(SyncStatus.LocalOnly, link: null),
|
||||
Entry(SyncStatus.RemoteOnly, local: null),
|
||||
Entry(SyncStatus.ProxiesOnly, local: null),
|
||||
Entry(SyncStatus.Conflict),
|
||||
Entry(SyncStatus.InSync, local: Local with { Title = "Comet over the ridge" }),
|
||||
};
|
||||
Assert.Equal(5, rows.Count(r => SyncText.Matches(r, SyncFilter.All, string.Empty)));
|
||||
Assert.Equal(1, rows.Count(r => SyncText.Matches(r, SyncFilter.LocalOnly, string.Empty)));
|
||||
Assert.Equal(2, rows.Count(r => SyncText.Matches(r, SyncFilter.Remote, string.Empty)));
|
||||
Assert.Equal(1, rows.Count(r => SyncText.Matches(r, SyncFilter.Conflicts, string.Empty)));
|
||||
Assert.Equal(1, rows.Count(r => SyncText.Matches(r, SyncFilter.All, "COMET")));
|
||||
Assert.Equal(0, rows.Count(r => SyncText.Matches(r, SyncFilter.Conflicts, "comet")));
|
||||
}
|
||||
|
||||
private static (StatusKind, string) Kind(SyncEntry entry)
|
||||
{
|
||||
var (kind, text, _) = SyncText.State(entry);
|
||||
return (kind, text);
|
||||
}
|
||||
|
||||
private static SyncEntry Entry(SyncStatus status, SyncLink? link = null, Sequence? local = null, Job? transfer = null) =>
|
||||
new(local ?? (status is SyncStatus.RemoteOnly or SyncStatus.ProxiesOnly ? null : Local), link ?? (status == SyncStatus.LocalOnly ? null : Link), status,
|
||||
transfer);
|
||||
|
||||
private static Job Upload(JobState state) => new() { Id = Guid.CreateVersion7(), Kind = JobKind.UploadCommit, State = state };
|
||||
}
|
||||
Reference in new issue
Block a user