Positions crossing copies could still land on other photos in three windows: - A push translated a row snapshot's settings against local frames listed later, after a manifest round trip: an import of earlier photos meanwhile moved the row's positions, and the server stored shifted exclusions, hero and keyframes. SyncPositions now reads this copy's row with its frames as one state (frames listed between two reads of the row at the same frames version) and translates that row's settings, at the settings version being pushed. The conflict comparison and ApplyLocallyAsync compare against that same row. When the copy was edited since, or its frames keep changing, nothing is sent or applied and the next comparison translates again (Keep mine reports a changed conflict; PushAll sends an edit saved meanwhile). - The manifest read the sequence row, then paged its frames: an upload committed in between paired settings of one frames version with frames of the next. The server now lists them again while the frames version moved during the listing, then inside a transaction holding the row (on SQLite, on that transaction's connection, so no second pooled connection waits behind the write lock). The client also refuses to translate against a manifest whose frames are not each listed once at 0..n-1. - Server capture times were fetched only when something was unhashed, so the same parked photo was written with or without capturedAt. They are now fetched whenever the two frame lists differ; an equal project then compares equal, and an entry can be placed on a photo that arrives unhashed. CompareOriginals counted unhashed server frames one-to-one against this PC's photos, so two copies of one photo in a folder the server adopted left Download on offer forever while the download fetched nothing. A photo on either side is now there when any photo of the other side matches it, as downloads and uploads find them. Paged frame listings keep each frame once (an insertion between pages lists one again). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
350 lines
20 KiB
C#
350 lines
20 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Json;
|
|
using Titano.Data;
|
|
using Titano.Protocol;
|
|
using Titano.Server.Api;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.Server.Tests.Api;
|
|
|
|
[Category("server")]
|
|
public sealed class SequenceTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public async Task ConcurrentSettingsEditsConflict()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (alberto, _, _) = await server.UserAsync("alberto", "editor");
|
|
var (giulia, _, _) = await server.UserAsync("giulia", "editor");
|
|
using var created = await alberto.PostAsJsonAsync("/api/v1/sequences", new CreateSequenceRequest("Harbour sunset", null), ProtocolJson.Default.CreateSequenceRequest);
|
|
await created.ExpectAsync(HttpStatusCode.Created);
|
|
var sequence = await created.ReadAsync(ProtocolJson.Default.SequenceDto);
|
|
Assert.Equal(0, sequence.SettingsVersion);
|
|
|
|
using (var first = await alberto.PatchAsJsonAsync($"/api/v1/sequences/{sequence.Id}",
|
|
new UpdateSequenceRequest(null, ["sunset", "harbour"], 4, null, """{"deflicker":{"strength":0.8}}""", 0), ProtocolJson.Default.UpdateSequenceRequest))
|
|
{
|
|
await first.ExpectAsync(HttpStatusCode.OK);
|
|
var updated = await first.ReadAsync(ProtocolJson.Default.SequenceDto);
|
|
Assert.Equal(1, updated.SettingsVersion);
|
|
Assert.SequenceEqual(["harbour", "sunset"], updated.Tags);
|
|
Assert.Equal(4, updated.Rating);
|
|
}
|
|
|
|
using (var stale = await giulia.PatchAsJsonAsync($"/api/v1/sequences/{sequence.Id}",
|
|
new UpdateSequenceRequest(null, null, null, null, """{"deflicker":{"strength":0.2}}""", 0), ProtocolJson.Default.UpdateSequenceRequest))
|
|
{
|
|
var error = await stale.ExpectErrorAsync(HttpStatusCode.Conflict, "settings_conflict");
|
|
Assert.Equal("1", error.Details);
|
|
}
|
|
|
|
// The ETag of a fresh read works as If-Match.
|
|
using var read = await giulia.GetAsync($"/api/v1/sequences/{sequence.Id}");
|
|
var etag = Assert.NotNull(read.Headers.ETag);
|
|
using var request = new HttpRequestMessage(HttpMethod.Patch, $"/api/v1/sequences/{sequence.Id}")
|
|
{
|
|
Content = JsonContent.Create(new UpdateSequenceRequest(null, null, null, null, """{"deflicker":{"strength":0.2}}""", null), ProtocolJson.Default.UpdateSequenceRequest),
|
|
};
|
|
request.Headers.IfMatch.Add(etag);
|
|
using (var retried = await giulia.SendAsync(request))
|
|
{
|
|
await retried.ExpectAsync(HttpStatusCode.OK);
|
|
Assert.Equal(2, (await retried.ReadAsync(ProtocolJson.Default.SequenceDto)).SettingsVersion);
|
|
}
|
|
|
|
using var notModified = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/sequences/{sequence.Id}");
|
|
notModified.Headers.IfNoneMatch.Add(etag);
|
|
using (var changed = await giulia.SendAsync(notModified)) await changed.ExpectAsync(HttpStatusCode.OK);
|
|
|
|
using var invalid = await giulia.PatchAsJsonAsync($"/api/v1/sequences/{sequence.Id}",
|
|
new UpdateSequenceRequest(null, null, null, null, "{ broken", null), ProtocolJson.Default.UpdateSequenceRequest);
|
|
await invalid.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_settings");
|
|
}
|
|
|
|
[Test]
|
|
public async Task SettingsWrittenAgainstFramesThatChangedAreRefused()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var first = await Uploads.UploadAsync(editor, Uploads.Photo(2000, 41), "a.CR3", sessionKey: "k");
|
|
using var read = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}");
|
|
var sequence = await read.ReadAsync(ProtocolJson.Default.SequenceDto);
|
|
// Another photo arrives after this client read the frames its positions name.
|
|
await Uploads.UploadAsync(editor, Uploads.Photo(2000, 42), "b.CR3", sessionKey: "k");
|
|
|
|
using (var stale = await editor.PatchAsJsonAsync($"/api/v1/sequences/{sequence.Id}",
|
|
new UpdateSequenceRequest(null, null, null, null, """{"excludedFrames":[0]}""", sequence.SettingsVersion, ExpectedFramesVersion: sequence.FramesVersion),
|
|
ProtocolJson.Default.UpdateSequenceRequest))
|
|
{
|
|
var error = await stale.ExpectErrorAsync(HttpStatusCode.Conflict, "frames_conflict");
|
|
Assert.Equal((sequence.FramesVersion + 1).ToString(System.Globalization.CultureInfo.InvariantCulture), error.Details);
|
|
}
|
|
|
|
using var fresh = await editor.PatchAsJsonAsync($"/api/v1/sequences/{sequence.Id}",
|
|
new UpdateSequenceRequest(null, null, null, null, """{"excludedFrames":[1]}""", sequence.SettingsVersion, ExpectedFramesVersion: sequence.FramesVersion + 1),
|
|
ProtocolJson.Default.UpdateSequenceRequest);
|
|
await fresh.ExpectAsync(HttpStatusCode.OK);
|
|
Assert.Equal(sequence.SettingsVersion + 1, (await fresh.ReadAsync(ProtocolJson.Default.SequenceDto)).SettingsVersion);
|
|
}
|
|
|
|
[Test]
|
|
public async Task TheManifestCarriesHashesAndAnEtag()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var a = Uploads.Photo(2000, 31);
|
|
var b = Uploads.Photo(2000, 32);
|
|
var first = await Uploads.UploadAsync(editor, a, "a.CR3", sessionKey: "k");
|
|
await Uploads.UploadAsync(editor, b, "b.CR3", sessionKey: "k");
|
|
|
|
using var response = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}/manifest");
|
|
await response.ExpectAsync(HttpStatusCode.OK);
|
|
var manifest = await response.ReadAsync(ProtocolJson.Default.SequenceManifest);
|
|
Assert.SequenceEqual([Uploads.Sha(a), Uploads.Sha(b)], manifest.Frames.Select(f => f.Sha256));
|
|
Assert.Equal(2, manifest.FramesVersion);
|
|
|
|
using var cached = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/sequences/{first.SequenceId}/manifest");
|
|
cached.Headers.IfNoneMatch.Add(response.Headers.ETag!);
|
|
using (var unchanged = await editor.SendAsync(cached)) await unchanged.ExpectAsync(HttpStatusCode.NotModified);
|
|
|
|
await Uploads.UploadAsync(editor, Uploads.Photo(2000, 33), "c.CR3", sessionKey: "k");
|
|
using var again = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/sequences/{first.SequenceId}/manifest");
|
|
again.Headers.IfNoneMatch.Add(response.Headers.ETag!);
|
|
using var changed = await editor.SendAsync(again);
|
|
await changed.ExpectAsync(HttpStatusCode.OK);
|
|
Assert.Count(3, (await changed.ReadAsync(ProtocolJson.Default.SequenceManifest)).Frames);
|
|
}
|
|
|
|
[Test]
|
|
public async Task TheManifestListsTheFramesOfOneFramesVersion()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
await FramesOfOneVersionAsync(server);
|
|
}
|
|
|
|
/// <summary>The manifest's frames are read again while frames are committed, then under the row lock (also run on PostgreSQL).</summary>
|
|
internal static async Task FramesOfOneVersionAsync(TestServer server)
|
|
{
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var first = await Uploads.UploadAsync(editor, Uploads.Photo(2000, 51), "a.CR3", sessionKey: "k");
|
|
var db = server.Database;
|
|
var id = first.SequenceId;
|
|
var start = (await db.Sequences.GetAsync(id))!.FramesVersion;
|
|
|
|
// Frames are committed while the first listing is read: it is read again.
|
|
var listings = new List<int>();
|
|
var snapshot = await SequenceEndpoints.SnapshotAsync(db, id, async (_, sequence, ct) =>
|
|
{
|
|
listings.Add(sequence.FramesVersion);
|
|
if (listings.Count == 1) await db.Sequences.RefreshStatsAsync(id, ct);
|
|
return [];
|
|
}, CancellationToken.None);
|
|
Assert.SequenceEqual([start, start + 1], listings);
|
|
Assert.Equal(start + 1, Assert.NotNull(snapshot).Sequence.FramesVersion);
|
|
|
|
// Commits keep landing: the last listing is read while none can.
|
|
Task? waiting = null;
|
|
listings.Clear();
|
|
var locked = await SequenceEndpoints.SnapshotAsync(db, id, async (on, sequence, ct) =>
|
|
{
|
|
listings.Add(sequence.FramesVersion);
|
|
if (listings.Count <= 3)
|
|
{
|
|
await db.Sequences.RefreshStatsAsync(id, ct);
|
|
return [];
|
|
}
|
|
// Listed on the transaction that holds the row (on SQLite, the only connection that may while it writes).
|
|
Assert.True(on is TitanoTransaction, "the frames are listed inside the locking transaction");
|
|
Assert.Count(1, await on.Frames.ListBySequenceAsync(id, cancellationToken: ct));
|
|
waiting = db.Sequences.RefreshStatsAsync(id, ct);
|
|
await Task.WhenAny(waiting, Task.Delay(300, ct));
|
|
Assert.False(waiting.IsCompleted, "a commit of frames waits until the frames are listed");
|
|
return [];
|
|
}, CancellationToken.None);
|
|
await Assert.NotNull(waiting);
|
|
Assert.SequenceEqual([start + 1, start + 2, start + 3, start + 4], listings);
|
|
Assert.Equal(start + 4, Assert.NotNull(locked).Sequence.FramesVersion);
|
|
Assert.Equal(start + 5, (await db.Sequences.GetAsync(id))!.FramesVersion);
|
|
Assert.Null(await SequenceEndpoints.SnapshotAsync(db, Guid.NewGuid(), (_, _, _) => Task.FromResult(new List<ManifestFrame>()), CancellationToken.None));
|
|
}
|
|
|
|
[Test]
|
|
public async Task ListingFiltersAndPagesWithACursor()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
for (var i = 0; i < 5; i++)
|
|
{
|
|
using var created = await editor.PostAsJsonAsync("/api/v1/sequences", new CreateSequenceRequest($"Shoot {i}", null), ProtocolJson.Default.CreateSequenceRequest);
|
|
await created.ExpectAsync(HttpStatusCode.Created);
|
|
}
|
|
var seen = new List<string>();
|
|
string? cursor = null;
|
|
long? total = null;
|
|
do
|
|
{
|
|
using var page = await editor.GetAsync($"/api/v1/sequences?sort=title&limit=2{(cursor is null ? string.Empty : "&cursor=" + Uri.EscapeDataString(cursor))}");
|
|
await page.ExpectAsync(HttpStatusCode.OK);
|
|
var items = await page.ReadAsync(ProtocolJson.Default.PageSequenceDto);
|
|
total ??= items.Total;
|
|
seen.AddRange(items.Items.Select(s => s.DisplayTitle));
|
|
cursor = items.NextCursor;
|
|
}
|
|
while (cursor is not null);
|
|
Assert.Equal(5L, total);
|
|
Assert.SequenceEqual(["Shoot 0", "Shoot 1", "Shoot 2", "Shoot 3", "Shoot 4"], seen);
|
|
|
|
using (var search = await editor.GetAsync("/api/v1/sequences?q=shoot%203")) Assert.Count(1, (await search.ReadAsync(ProtocolJson.Default.PageSequenceDto)).Items);
|
|
using (var badCursor = await editor.GetAsync("/api/v1/sequences?cursor=bm9wZQ")) await badCursor.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_cursor");
|
|
using var badStatus = await editor.GetAsync("/api/v1/sequences?status=shiny");
|
|
await badStatus.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_filter");
|
|
}
|
|
|
|
[Test]
|
|
public async Task DeletingPlansFirstAndMovesTheFolderToTrash()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var (other, _, _) = await server.UserAsync("giulia", "editor");
|
|
var frame = await Uploads.UploadAsync(editor, Uploads.Photo(3000, 34));
|
|
var sequence = (await server.Database.Sequences.GetAsync(frame.SequenceId))!;
|
|
var folder = Path.Combine(server.Options.ArchivePath, sequence.Folder);
|
|
|
|
using (var notOwner = await other.DeleteAsync($"/api/v1/sequences/{sequence.Id}")) await notOwner.ExpectErrorAsync(HttpStatusCode.Forbidden, "forbidden");
|
|
using (var plan = await editor.DeleteAsync($"/api/v1/sequences/{sequence.Id}?dryRun=true"))
|
|
{
|
|
var dryRun = await plan.ReadAsync(ProtocolJson.Default.SequenceDeletePlan);
|
|
Assert.True(dryRun.DryRun);
|
|
Assert.Equal(1, dryRun.FrameCount);
|
|
Assert.Equal($".titano/trash/{sequence.Id:N}", dryRun.TrashFolder);
|
|
}
|
|
Assert.True(Directory.Exists(folder), "a dry run changes nothing");
|
|
Assert.NotNull(await server.Database.Sequences.GetAsync(sequence.Id));
|
|
|
|
using (var deleted = await editor.DeleteAsync($"/api/v1/sequences/{sequence.Id}")) await deleted.ExpectAsync(HttpStatusCode.OK);
|
|
Assert.False(Directory.Exists(folder));
|
|
Assert.True(Directory.Exists(Path.Combine(server.Options.TrashPath, sequence.Id.ToString("N"))), "the files are kept in the trash");
|
|
Assert.Null(await server.Database.Sequences.GetAsync(sequence.Id));
|
|
using var gone = await editor.GetAsync($"/api/v1/sequences/{sequence.Id}");
|
|
await gone.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found");
|
|
}
|
|
|
|
[Test]
|
|
public async Task ASequenceAJobWorksOnIsNotDeleted()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var frame = await Uploads.UploadAsync(editor, Uploads.Photo(3000, 35));
|
|
var sequence = (await server.Database.Sequences.GetAsync(frame.SequenceId))!;
|
|
await server.Database.Jobs.EnqueueAsync(new Titano.Core.Model.Job
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = Titano.Core.Model.JobKind.Render,
|
|
TargetIds = [sequence.Id],
|
|
State = Titano.Core.Model.JobState.Running,
|
|
NodeId = "node#0",
|
|
Created = DateTimeOffset.UtcNow,
|
|
Started = DateTimeOffset.UtcNow,
|
|
});
|
|
|
|
using (var plan = await editor.DeleteAsync($"/api/v1/sequences/{sequence.Id}?dryRun=true")) await plan.ExpectErrorAsync(HttpStatusCode.Conflict, "sequence_busy");
|
|
using (var deleted = await editor.DeleteAsync($"/api/v1/sequences/{sequence.Id}")) await deleted.ExpectErrorAsync(HttpStatusCode.Conflict, "sequence_busy");
|
|
Assert.True(Directory.Exists(Path.Combine(server.Options.ArchivePath, sequence.Folder)));
|
|
Assert.NotNull(await server.Database.Sequences.GetAsync(sequence.Id));
|
|
}
|
|
|
|
[Test]
|
|
public async Task ADeleteThatCannotMoveSaysWhy()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var a = (await server.Database.Sequences.GetAsync((await Uploads.UploadAsync(editor, Uploads.Photo(3000, 36), "a.jpg", sessionKey: "a")).SequenceId))!;
|
|
var b = (await server.Database.Sequences.GetAsync((await Uploads.UploadAsync(editor, Uploads.Photo(3000, 37), "b.jpg", sessionKey: "b")).SequenceId))!;
|
|
Assert.NotEqual(a.Folder, b.Folder);
|
|
var archive = new Titano.Core.Archiving.ArchivePaths(server.Options.ArchivePath);
|
|
|
|
// The folder of b now holds a sidecar naming another sequence (copied over by hand): the index is out of date.
|
|
var sidecar = archive.Sequence(b.Folder).ManifestPath;
|
|
Directory.CreateDirectory(Path.GetDirectoryName(sidecar)!);
|
|
File.WriteAllText(sidecar, $$"""{"schemaVersion":1,"id":"{{a.Id}}"}""");
|
|
await RefusedAsync(editor, b.Id, "sidecar_mismatch");
|
|
Directory.Delete(archive.Sequence(a.Folder).Folder, recursive: true);
|
|
await RefusedAsync(editor, a.Id, "folder_missing");
|
|
Assert.NotNull(await server.Database.Sequences.GetAsync(a.Id));
|
|
Assert.NotNull(await server.Database.Sequences.GetAsync(b.Id));
|
|
|
|
// A sequence still waiting for its first photo has no folder: only its row goes.
|
|
using var created = await editor.PostAsJsonAsync("/api/v1/sequences", new CreateSequenceRequest("Waiting", null), ProtocolJson.Default.CreateSequenceRequest);
|
|
var empty = await created.ReadAsync(ProtocolJson.Default.SequenceDto);
|
|
using (var deleted = await editor.DeleteAsync($"/api/v1/sequences/{empty.Id}")) Assert.Null((await deleted.ReadAsync(ProtocolJson.Default.SequenceDeletePlan)).TrashFolder);
|
|
Assert.Null(await server.Database.Sequences.GetAsync(empty.Id));
|
|
|
|
static async Task RefusedAsync(HttpClient client, Guid id, string code)
|
|
{
|
|
using var response = await client.DeleteAsync($"/api/v1/sequences/{id}");
|
|
var error = await response.ExpectErrorAsync(HttpStatusCode.Conflict, code);
|
|
Assert.NotEqual(code, error.Message, "the code has a sentence");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task FramesAndStatsArePaged()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var first = await Uploads.UploadAsync(editor, Uploads.Photo(1000, 40), "f0.jpg", sessionKey: "p");
|
|
for (var i = 1; i < 4; i++) await Uploads.UploadAsync(editor, Uploads.Photo(1000 + i, 40 + i), $"f{i}.jpg", sessionKey: "p");
|
|
var id = first.SequenceId;
|
|
using var page1 = await editor.GetAsync($"/api/v1/sequences/{id}/frames?limit=2");
|
|
var frames = await page1.ReadAsync(ProtocolJson.Default.PageFrameDto);
|
|
Assert.SequenceEqual([0, 1], frames.Items.Select(f => f.Index));
|
|
using var page2 = await editor.GetAsync($"/api/v1/sequences/{id}/frames?limit=2&cursor={Uri.EscapeDataString(frames.NextCursor!)}");
|
|
Assert.SequenceEqual([2, 3], (await page2.ReadAsync(ProtocolJson.Default.PageFrameDto)).Items.Select(f => f.Index));
|
|
|
|
using var stats = await editor.GetAsync($"/api/v1/sequences/{id}/stats");
|
|
var dto = await stats.ReadAsync(ProtocolJson.Default.SequenceStatsDto);
|
|
Assert.Equal(4, dto.FrameCount);
|
|
Assert.Equal(4L, dto.ByFormat.Sum(f => f.Count));
|
|
using var analysis = await editor.GetAsync($"/api/v1/sequences/{id}/analysis");
|
|
Assert.Equal("analysis", (await analysis.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found")).Details);
|
|
}
|
|
|
|
[Test]
|
|
public async Task CardsAndFramesCarryTheDecodeTierFields()
|
|
{
|
|
await using var server = await TestServer.StartAsync(context);
|
|
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
|
var first = await Uploads.UploadAsync(editor, Uploads.Photo(1000, 50), "t0.CR3", sessionKey: "t");
|
|
await Uploads.UploadAsync(editor, Uploads.Photo(1001, 51), "t1.CR3", sessionKey: "t");
|
|
var db = server.Database;
|
|
// The follow-up jobs of the upload (thumbnails, proxies, light analysis) rewrite the rows: let them finish first.
|
|
for (var waited = 0; waited < 600; waited++)
|
|
{
|
|
if ((await db.Jobs.ListAsync(Titano.Core.Model.JobState.Queued)).Items.Count == 0
|
|
&& (await db.Jobs.ListAsync(Titano.Core.Model.JobState.Running)).Items.Count == 0) break;
|
|
await Task.Delay(50, context.Cancellation);
|
|
}
|
|
// What a light analysis on the server records for CR3s it reads only through their previews.
|
|
var frames = await db.Frames.ListBySequenceAsync(first.SequenceId);
|
|
await db.Frames.UpdateTiersAsync([.. frames.Select(f => new Titano.Data.Repositories.FrameTierFields(f.Id, Titano.Core.Model.FrameFlags.PreviewOnly, 1620, 1080))]);
|
|
var sequence = (await db.Sequences.GetAsync(first.SequenceId))!;
|
|
await db.Sequences.UpsertAsync(sequence with { PreviewOnlyCount = 2 });
|
|
|
|
// The Library cards read the count (the chip), the remote editor the preview size (the output cap).
|
|
using var list = await editor.GetAsync("/api/v1/sequences");
|
|
await list.ExpectAsync(HttpStatusCode.OK);
|
|
Assert.Contains("\"previewOnlyCount\":2", await list.Content.ReadAsStringAsync());
|
|
using var listed = await editor.GetAsync("/api/v1/sequences");
|
|
Assert.Equal(2, (await listed.ReadAsync(ProtocolJson.Default.PageSequenceDto)).Items.Single(s => s.Id == first.SequenceId).PreviewOnlyCount);
|
|
using var page = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}/frames");
|
|
await page.ExpectAsync(HttpStatusCode.OK);
|
|
var json = await page.Content.ReadAsStringAsync();
|
|
Assert.Contains("\"previewWidth\":1620", json);
|
|
Assert.Contains("\"previewHeight\":1080", json);
|
|
using var typed = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}/frames");
|
|
var dtos = (await typed.ReadAsync(ProtocolJson.Default.PageFrameDto)).Items;
|
|
Assert.True(dtos.All(f => (f.PreviewWidth, f.PreviewHeight, f.Flags) == (1620, 1080, (long)Titano.Core.Model.FrameFlags.PreviewOnly)), "frame DTOs");
|
|
}
|
|
}
|