CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
186 lines
11 KiB
C#
186 lines
11 KiB
C#
using Chronos.App.Server;
|
|
using Chronos.Core.Localization;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Sync;
|
|
using Chronos.Testing;
|
|
using Chronos.Ui.Controls;
|
|
|
|
namespace Chronos.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, Chronos.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")));
|
|
}
|
|
|
|
[Test]
|
|
public void ATransferCountsWhereItsOriginalsAre()
|
|
{
|
|
var uploadNotOnServer = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Queued)) with { Link = null };
|
|
var download = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.Download, State = JobState.Running };
|
|
var downloadNotHere = Entry(SyncStatus.Transferring, transfer: download) with { Local = null };
|
|
var uploadOnBoth = Entry(SyncStatus.Transferring, transfer: Upload(JobState.Running));
|
|
|
|
Assert.True(SyncText.Matches(uploadNotOnServer, SyncFilter.LocalOnly, string.Empty));
|
|
Assert.False(SyncText.Matches(uploadNotOnServer, SyncFilter.Remote, string.Empty));
|
|
Assert.True(SyncText.Matches(downloadNotHere, SyncFilter.Remote, string.Empty));
|
|
Assert.False(SyncText.Matches(downloadNotHere, SyncFilter.LocalOnly, string.Empty));
|
|
// Partly on both sides: neither "only here" nor "only on the server".
|
|
Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.LocalOnly, string.Empty));
|
|
Assert.False(SyncText.Matches(uploadOnBoth, SyncFilter.Remote, string.Empty));
|
|
Assert.True(SyncText.Matches(uploadOnBoth, SyncFilter.All, string.Empty));
|
|
}
|
|
|
|
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 };
|
|
}
|