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>
350 lines
20 KiB
C#
350 lines
20 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Json;
|
|
using Chronos.Data;
|
|
using Chronos.Protocol;
|
|
using Chronos.Server.Api;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.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 ChronosTransaction, "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($".chronos/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 Chronos.Core.Model.Job
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = Chronos.Core.Model.JobKind.Render,
|
|
TargetIds = [sequence.Id],
|
|
State = Chronos.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 Chronos.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(Chronos.Core.Model.JobState.Queued)).Items.Count == 0
|
|
&& (await db.Jobs.ListAsync(Chronos.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 Chronos.Data.Repositories.FrameTierFields(f.Id, Chronos.Core.Model.FrameFlags.PreviewOnly, 1620, 1080, f.Format))]);
|
|
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)Chronos.Core.Model.FrameFlags.PreviewOnly)), "frame DTOs");
|
|
}
|
|
}
|