fix(app): viewers open server sequences with proxies, the editor follows the sign-in
An account without Edit is offered Open with proxies on a server that keeps projects and checks nothing out, since it could never push. The editor of a server's workspace project connects with the sign-in in use at each call, so a project opened signed out renders once signed in; SyncHost tells every session start and stop so workspace projects read their state again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cdd29f8e84
commit
48d8158fd7
8 files changed
+165
-24
No files matched your search
@@ -1,7 +1,10 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using Chronos.App.DesignTime;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Tests.Uploader;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.App.Tests.Server;
|
||||
@@ -58,4 +61,67 @@ public sealed class SyncHostTests
|
||||
environment.DeleteCaptureData();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Phase 5b glue: a server that keeps projects is the home of its sequences' workspace projects while signed in to it,
|
||||
/// never another server's; each session start and stop is told as "changes may have been missed", so the workspace
|
||||
/// reads its projects' state again (offline once signed out, reachable once signed in anew).
|
||||
/// </summary>
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public void TheSignedInServerIsTheHomeOfItsProjectsAndEverySessionChangeIsTold()
|
||||
{
|
||||
var environment = AppEnvironment.ForCapture();
|
||||
try
|
||||
{
|
||||
SingleThreadedContext.Run(async () =>
|
||||
{
|
||||
await using var services = new AppServices(environment, new AppSettings { Language = "en" }, () => { }, new NoDialogs());
|
||||
var sample = SampleData.Configure(services);
|
||||
sample.Capabilities = [ServerCapabilities.Projects];
|
||||
await sample.OpenEmptyAsync();
|
||||
await sample.FillAsync();
|
||||
services.Settings.RenderNodeOptIn = false;
|
||||
var told = new ConcurrentQueue<(string Server, ProjectChangedEvent? Change)>();
|
||||
services.Sync.ProjectChanged += (server, change) => told.Enqueue((server, change));
|
||||
var sequence = Guid.CreateVersion7();
|
||||
|
||||
await services.Server.RestoreAsync();
|
||||
await UntilAsync(() => services.Sync.Agent is not null && !told.IsEmpty, "session started and told");
|
||||
var server = Assert.NotNull(services.Sync.Server);
|
||||
Assert.True(services.Sync.HasProjects, "the server keeps projects");
|
||||
var home = Assert.NotNull(services.Sync.ServerHome(sequence));
|
||||
var reached = (ServerProjectHome)Assert.NotNull(services.Sync.ProjectHome(home));
|
||||
Assert.Equal(sequence, reached.SequenceId);
|
||||
Assert.Null(services.Sync.ProjectHome(home with { Server = "https://other.example:8443" }));
|
||||
Assert.Same(reached.Client, ((ServerProjectHome)services.Sync.ProjectHome(home)!).Client);
|
||||
|
||||
// Signed out: told again, and its projects have no home to reach (offline) until signed in anew.
|
||||
var before = told.Count;
|
||||
services.Server.Disconnect();
|
||||
await UntilAsync(() => told.Count > before && services.Sync.Agent is null, "session stop told");
|
||||
Assert.Null(services.Sync.ProjectHome(home));
|
||||
Assert.False(services.Sync.HasProjects);
|
||||
before = told.Count;
|
||||
await services.Server.RestoreAsync();
|
||||
await UntilAsync(() => told.Count > before && services.Sync.Agent is not null, "new session told");
|
||||
Assert.NotNull(services.Sync.ProjectHome(home));
|
||||
Assert.True(told.All(t => t.Server == server && t.Change is null), "only session changes were told");
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
environment.DeleteCaptureData();
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task UntilAsync(Func<bool> condition, string what)
|
||||
{
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(TestTiming.Budget(10));
|
||||
while (!condition())
|
||||
{
|
||||
Assert.True(DateTime.UtcNow < until, what);
|
||||
await Task.Delay(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,9 @@ public sealed class SyncTextTests
|
||||
// Owner review 2, R8, phase 5b: the workspace replaces Open with proxies, and the originals can still come down.
|
||||
var projects = Editor with { KeepsProjects = true };
|
||||
Assert.SequenceEqual([SyncAction.OpenInWorkspace, SyncAction.DownloadOriginals], SyncText.Actions(Entry(SyncStatus.RemoteOnly, local: null), projects));
|
||||
Assert.SequenceEqual([SyncAction.OpenInWorkspace], SyncText.Actions(Entry(SyncStatus.ProxiesOnly, local: null), Viewer with { KeepsProjects = true }));
|
||||
// An account that may not edit only looks, with proxies: it is offered no workspace copy it could not push.
|
||||
Assert.SequenceEqual([SyncAction.OpenWithProxies], SyncText.Actions(Entry(SyncStatus.ProxiesOnly, local: null), Viewer with { KeepsProjects = true }));
|
||||
Assert.SequenceEqual([SyncAction.OpenWithProxies], SyncText.Actions(Entry(SyncStatus.RemoteOnly, local: null), Viewer with { KeepsProjects = true }));
|
||||
Assert.True(SyncText.IsEnabled(SyncAction.OpenInWorkspace, projects), "a server that keeps projects opens them");
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Sync.OpenInWorkspace"), SyncText.ToolTip(Entry(SyncStatus.RemoteOnly, local: null), SyncAction.OpenInWorkspace, projects));
|
||||
// An older server's row says why its workspace action is disabled; the other actions are not.
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Tests.Editor;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Imaging.Decoders;
|
||||
using Chronos.Core.Localization;
|
||||
@@ -143,7 +144,10 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
var told = new List<WorkspaceHomeChange>();
|
||||
host.HomeChanged += told.Add;
|
||||
|
||||
var source = new WorkspaceSequenceSource(host.Sync, projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine, new WorkspaceServerHome(null));
|
||||
// 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,
|
||||
new WorkspaceServerHome(() => signedIn, () => signedIn));
|
||||
var content = await source.LoadAsync(bed.Ct);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
var ui = new RecordingUi();
|
||||
@@ -160,6 +164,19 @@ public sealed class ServerHomeTests(TestContext context)
|
||||
Assert.Empty(await source.ListJobsAsync(bed.Ct));
|
||||
var refused = await Assert.ThrowsAsync<EditorException>(() => source.SubmitAsync(session.RenderRequests(session.Project.Export)[0], bed.Ct));
|
||||
Assert.Equal(Loc.L("Editor.Error.SignedOut"), refused.Message);
|
||||
// Signed in since: the render goes to the server on that sign-in's connection; signed in anew, on the new one's.
|
||||
var first = new FakeRemoteSequenceApi(await bed.RowAsync(), []);
|
||||
signedIn = first;
|
||||
await source.SubmitAsync(session.RenderRequests(session.Project.Export)[0], bed.Ct);
|
||||
Assert.Equal(1, first.Posted.Count);
|
||||
var second = new FakeRemoteSequenceApi(await bed.RowAsync(), []);
|
||||
signedIn = second;
|
||||
await source.SubmitAsync(session.RenderRequests(session.Project.Export)[0], bed.Ct);
|
||||
Assert.Equal((1, 1), (first.Posted.Count, second.Posted.Count));
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(TestTiming.Budget(10));
|
||||
while (!first.Disposed && DateTime.UtcNow < until) await Task.Delay(20, bed.Ct);
|
||||
Assert.True(first.Disposed, "the old sign-in's connection closes");
|
||||
signedIn = null;
|
||||
|
||||
// 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");
|
||||
|
||||
Reference in new issue
Block a user