feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Infrastructure;
|
||||
@@ -50,7 +51,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
|
||||
// Checked out from the server: its media are downloaded by a copy job that names the server, never this PC's archive.
|
||||
var checkout = await host.CheckoutAsync(named, null, null, cancellationToken: bed.Ct);
|
||||
var bundle = host.Store.Find(checkout.Project.Id)!.ReadBundle();
|
||||
var bundle = host.Find(checkout.Project.Id)!.ReadBundle();
|
||||
Assert.Equal((BundleHome.ServerKind, Server, bed.SequenceId), (bundle.Workspace!.Home.Kind, bundle.Workspace.Home.Server, bundle.Workspace.Home.SequenceId));
|
||||
using (var parameters = JsonDocument.Parse(checkout.Copy.ParametersJson!))
|
||||
{
|
||||
@@ -83,8 +84,8 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
var other = bed.Host(name: "other-pc");
|
||||
var otherId = await bed.CheckoutAsync(other);
|
||||
Assert.Equal(projectId, otherId);
|
||||
var session = await other.Sync.OpenAsync(projectId, bed.Ct);
|
||||
await other.Sync.SaveAsync(projectId, session.Working with { HeroFrame = 2 }, bed.Ct);
|
||||
var session = await other.SyncOf(projectId).OpenAsync(projectId, bed.Ct);
|
||||
await other.SyncOf(projectId).SaveAsync(projectId, session.Working with { HeroFrame = 2 }, bed.Ct);
|
||||
await other.SaveVersionAsync(projectId, null, bed.Ct);
|
||||
status = await host.StatusAsync(projectId, cancellationToken: bed.Ct);
|
||||
Assert.Equal((WorkspaceState.Behind, 1), (status.State, status.Behind));
|
||||
@@ -109,13 +110,46 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
Assert.Equal(Loc.L("Editor.Workspace.State.Gone.Server"), WorkspaceText.State(status, server: true));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Workspace.State.Gone.Server"), WorkspaceText.StateToolTip(status, server: true));
|
||||
Assert.Equal(StatusKind.Warning, WorkspaceText.Kind(status));
|
||||
Assert.NotNull(host.Store.Find(projectId)?.ReadMedia());
|
||||
Assert.NotNull(host.Find(projectId)?.ReadMedia());
|
||||
// A server that answers 404 for the project itself (deleted with its sequence) is gone too.
|
||||
server.Deleted.Clear();
|
||||
server.Missing = true;
|
||||
Assert.Equal(WorkspaceState.Gone, (await host.StatusAsync(projectId, cancellationToken: bed.Ct)).State);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task EachHomeChecksOutIntoItsOwnFolderAndTheServerIsOneByItsId()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 3);
|
||||
var serverId = Guid.CreateVersion7();
|
||||
var idKey = Chronos.Core.IO.HomeFolders.IdKey(serverId);
|
||||
var host = bed.Host();
|
||||
host.Identity = () => new Chronos.Data.Sync.ServerIdentity([new Chronos.Data.Sync.KnownServerKey(serverId, [Server])]);
|
||||
var server = new FakeServer(bed);
|
||||
host.ServerHomes = home => host.SameServer(home.Server, idKey) && home.SequenceId == server.Inner.SequenceId ? server : null;
|
||||
|
||||
// A server project goes into the server's folder, named by its id even though the project names its address.
|
||||
var checkout = await host.CheckoutAsync(ServerHome(bed), null, null, cancellationToken: bed.Ct);
|
||||
var folder = host.Find(checkout.Project.Id)!;
|
||||
Assert.Equal(Path.Combine(host.Root, "servers", serverId.ToString("N")), folder.Store.Root);
|
||||
Assert.Equal(Server, folder.ReadBundle().Workspace!.Home.Server);
|
||||
Assert.True(host.SameServer(Server, idKey), "the address is an alias of the id");
|
||||
Assert.False(host.SameServer("https://elsewhere:8443", idKey));
|
||||
|
||||
// The server told by its id reaches the project that names its address.
|
||||
var told = new List<WorkspaceHomeChange>();
|
||||
host.HomeChanged += told.Add;
|
||||
host.OnServerProjectChanged(idKey, new ProjectChangedEvent(bed.SequenceId, checkout.Project.Id, ProjectChanges.Pushed, 2, Guid.CreateVersion7()));
|
||||
Assert.Equal(checkout.Project.Id, told.Single().ProjectId);
|
||||
|
||||
// A project of this PC's archive goes into local\, and the picker lists both.
|
||||
var other = bed.Host(name: "second");
|
||||
var localId = await bed.CheckoutAsync(other);
|
||||
Assert.Equal(Path.Combine(other.Root, "local"), other.Find(localId)!.Store.Root);
|
||||
Assert.SequenceEqual([checkout.Project.Id], host.Homes.List().Select(p => p.ProjectId).ToArray());
|
||||
Assert.Count(1, (await host.ListAsync(bed.Ct)).Where(e => e.ProjectId == checkout.Project.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheServersProjectChangesReachOnlyTheProjectsItIsHomeOf()
|
||||
{
|
||||
@@ -146,7 +180,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
|
||||
// Opened signed out; the sign-in made later is the one the source connects with.
|
||||
FakeRemoteSequenceApi? signedIn = null;
|
||||
var source = new WorkspaceSequenceSource(host.Sync, projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine,
|
||||
var source = new WorkspaceSequenceSource(host.SyncOf(projectId), projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine,
|
||||
new WorkspaceServerHome(() => signedIn, () => signedIn));
|
||||
var content = await source.LoadAsync(bed.Ct);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
@@ -181,7 +215,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
// In step with the server: the render names the version it holds, whose settings the server renders.
|
||||
Assert.True(await menu.ReadyToRenderAsync(), "nothing to send");
|
||||
Assert.Empty(ui.Confirmations);
|
||||
var basis = host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!;
|
||||
var basis = host.Find(projectId)!.ReadBundle().Workspace!.Base!;
|
||||
var (held, _) = ProcessingJobs.ReadRender(session.RenderRequests(session.Project.Export)[0].ParametersJson);
|
||||
Assert.Equal<(Guid?, Guid?, string?)>((projectId, basis.VersionId, null), (held.ProjectId, held.ProjectVersionId, held.SettingsJson));
|
||||
|
||||
@@ -198,7 +232,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
ui.ConfirmAnswer = true;
|
||||
Assert.True(await menu.ReadyToRenderAsync(), "saved and sent: the server holds it");
|
||||
Assert.Equal(WorkspaceState.InSync, menu.Status!.State);
|
||||
var sent = host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!;
|
||||
var sent = host.Find(projectId)!.ReadBundle().Workspace!.Base!;
|
||||
Assert.NotEqual(basis.VersionId, sent.VersionId);
|
||||
var (version, _) = ProcessingJobs.ReadRender(session.RenderRequests(session.Project.Export)[0].ParametersJson);
|
||||
Assert.Equal<(Guid?, string?)>((sent.VersionId, null), (version.ProjectVersionId, version.SettingsJson));
|
||||
@@ -219,8 +253,8 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
// Another PC sends a version and the server says so: the chip reads Server newer at once.
|
||||
var other = bed.Host(name: "other-pc");
|
||||
await bed.CheckoutAsync(other);
|
||||
var theirs = await other.Sync.OpenAsync(projectId, bed.Ct);
|
||||
await other.Sync.SaveAsync(projectId, theirs.Working with { Exposure = theirs.Working.Exposure with { ExposureOffsetEv = 0.7 } }, bed.Ct);
|
||||
var theirs = await other.SyncOf(projectId).OpenAsync(projectId, bed.Ct);
|
||||
await other.SyncOf(projectId).SaveAsync(projectId, theirs.Working with { Exposure = theirs.Working.Exposure with { ExposureOffsetEv = 0.7 } }, bed.Ct);
|
||||
var stored = (await other.SaveVersionAsync(projectId, null, bed.Ct)).Version!;
|
||||
host.OnServerProjectChanged(Server, new ProjectChangedEvent(bed.SequenceId, projectId, ProjectChanges.Pushed, stored.Number, stored.Id));
|
||||
Assert.Equal(projectId, told.Single().ProjectId);
|
||||
@@ -240,7 +274,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
Assert.Equal(Loc.L("Editor.Workspace.State.Gone.Server"), menu.StateText);
|
||||
Assert.False(await menu.ReadyToRenderAsync(), "nothing to render it from");
|
||||
Assert.True(ui.Toasts[^1].IsError);
|
||||
Assert.NotNull(host.Store.Find(projectId)?.ReadMedia());
|
||||
Assert.NotNull(host.Find(projectId)?.ReadMedia());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +294,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
var server = new FakeServer(bed) { SettingsFormat = ProjectSettings.BaseVersion };
|
||||
Connect(host, server);
|
||||
var projectId = await CheckoutAsync(bed, host);
|
||||
var source = new WorkspaceSequenceSource(host.Sync, projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine,
|
||||
var source = new WorkspaceSequenceSource(host.SyncOf(projectId), projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine,
|
||||
new WorkspaceServerHome(() => null, () => null));
|
||||
var content = await source.LoadAsync(bed.Ct);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
@@ -282,9 +316,9 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
Assert.False(menu.SyncCommand.CanExecute(null));
|
||||
Assert.False(await menu.ReadyToRenderAsync(), "the server cannot read it");
|
||||
Assert.Equal((Loc.L("Editor.Workspace.RenderHeld"), true), (ui.Toasts[^1].Title, ui.Toasts[^1].IsError));
|
||||
var before = host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId;
|
||||
var before = host.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId;
|
||||
await menu.SyncAsync();
|
||||
Assert.Equal(before, host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId, "nothing was sent");
|
||||
Assert.Equal(before, host.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId, "nothing was sent");
|
||||
|
||||
// Saved as a version with the turn, then turned back: the working state is of the base format, but the version
|
||||
// waiting to be sent is not. Sync stays disabled, and the workspace itself never sends it (Send first, Delete,
|
||||
@@ -300,7 +334,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
var refused = await Assert.ThrowsAsync<WorkspaceSyncException>(() => host.SyncAsync(projectId, bed.Ct));
|
||||
Assert.True(refused.HomeReadsOlderFormat);
|
||||
Assert.Equal(Loc.L("Tooltips.Server.NeedsNewerServer"), WorkspaceText.Failure(refused, server: true));
|
||||
Assert.Equal(before, host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId, "nothing was sent");
|
||||
Assert.Equal(before, host.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId, "nothing was sent");
|
||||
|
||||
// A server of this format takes it.
|
||||
server.SettingsFormat = ProjectSettings.CurrentVersion;
|
||||
@@ -323,7 +357,7 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
private static async Task<Guid> CheckoutAsync(WorkspaceTestBed bed, WorkspaceHost host)
|
||||
{
|
||||
var projectId = await bed.CheckoutAsync(host);
|
||||
var folder = host.Store.Find(projectId)!;
|
||||
var folder = host.Find(projectId)!;
|
||||
var bundle = folder.ReadBundle();
|
||||
folder.WriteBundle(bundle with { Workspace = bundle.Workspace! with { Home = ServerHome(bed) } });
|
||||
return projectId;
|
||||
|
||||
Reference in new issue
Block a user