Titano: Library completion, remote editing, accessibility and RTL pass, remaining translations #3
@@ -22,6 +22,9 @@ public sealed class SyncServerTests(TestContext context)
|
|||||||
private const string Window41 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":41}}}""";
|
private const string Window41 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":41}}}""";
|
||||||
private const string Window33 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":33}}}""";
|
private const string Window33 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":33}}}""";
|
||||||
|
|
||||||
|
/// <summary>How long any wait may take on a loaded runner; every wait ends as soon as what it waits for happened.</summary>
|
||||||
|
private static readonly TimeSpan Deadline = TimeSpan.FromSeconds(60);
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task ASequenceUploadedFromOnePcDownloadsIdenticallyOnAnother()
|
public async Task ASequenceUploadedFromOnePcDownloadsIdenticallyOnAnother()
|
||||||
{
|
{
|
||||||
@@ -147,12 +150,16 @@ public sealed class SyncServerTests(TestContext context)
|
|||||||
var hub = server.Services.GetRequiredService<EventHub>();
|
var hub = server.Services.GetRequiredService<EventHub>();
|
||||||
await UntilAsync(() => Task.FromResult(agent.Snapshot is not null && hub.SubscriberCount > 0), "the agent's first comparison and event socket");
|
await UntilAsync(() => Task.FromResult(agent.Snapshot is not null && hub.SubscriberCount > 0), "the agent's first comparison and event socket");
|
||||||
|
|
||||||
// Someone edits the project on the server (web or another PC).
|
// Someone edits the project on the server (web or another PC). The comparison its event starts writes the
|
||||||
|
// settings on this PC before the link that records the agreement: wait for the comparison, not for the settings.
|
||||||
|
var compared = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
studio.Sync.Changed += _ => compared.TrySetResult();
|
||||||
using (var patch = await http.PatchAsJsonAsync($"/api/v1/sequences/{remoteId}",
|
using (var patch = await http.PatchAsJsonAsync($"/api/v1/sequences/{remoteId}",
|
||||||
new UpdateSequenceRequest(null, null, null, null, Window33, null), ProtocolJson.Default.UpdateSequenceRequest))
|
new UpdateSequenceRequest(null, null, null, null, Window33, null), ProtocolJson.Default.UpdateSequenceRequest))
|
||||||
await patch.ExpectAsync(HttpStatusCode.OK);
|
await patch.ExpectAsync(HttpStatusCode.OK);
|
||||||
|
|
||||||
await UntilAsync(async () => ProjectSettings.FromJson((await studio.Db.Sequences.GetAsync(local.Id))!.SettingsJson ?? "{}").Exposure.DeflickerWindow.Manual == 33,
|
await SignalAsync(compared.Task, "the comparison of the edit");
|
||||||
|
Assert.Equal(33, ProjectSettings.FromJson((await studio.Db.Sequences.GetAsync(local.Id))!.SettingsJson ?? "{}").Exposure.DeflickerWindow.Manual,
|
||||||
"the edit reached this PC");
|
"the edit reached this PC");
|
||||||
Assert.Equal(SyncStatus.InSync, (await studio.EntryAsync("Harbour sunset")).Status);
|
Assert.Equal(SyncStatus.InSync, (await studio.EntryAsync("Harbour sunset")).Status);
|
||||||
}
|
}
|
||||||
@@ -244,11 +251,23 @@ public sealed class SyncServerTests(TestContext context)
|
|||||||
|
|
||||||
private async Task UntilAsync(Func<Task<bool>> condition, string what)
|
private async Task UntilAsync(Func<Task<bool>> condition, string what)
|
||||||
{
|
{
|
||||||
var until = DateTime.UtcNow.AddSeconds(60);
|
var until = DateTime.UtcNow + Deadline;
|
||||||
while (!await condition())
|
while (!await condition())
|
||||||
{
|
{
|
||||||
if (DateTime.UtcNow > until) Assert.Fail("Timed out waiting for " + what);
|
if (DateTime.UtcNow > until) Assert.Fail("Timed out waiting for " + what);
|
||||||
await Task.Delay(50, context.Cancellation);
|
await Task.Delay(50, context.Cancellation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SignalAsync(Task signal, string what)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await signal.WaitAsync(Deadline, context.Cancellation);
|
||||||
|
}
|
||||||
|
catch (TimeoutException)
|
||||||
|
{
|
||||||
|
Assert.Fail("Timed out waiting for " + what);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user