merge: desktop settings fixes (V-4, V-6, V-7, V-30, V-31, V-32, V-34, ENG-08)
Merge branch fix2/desktop-settings into the verification branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
34 files changed
+1132
-171
No files matched your search
@@ -106,6 +106,47 @@ public sealed class ArchiveModuleTests(TestContext context)
|
||||
await UntilImagesAsync(server, editor, archive.Id, "garden");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SettingsADesktopChangedInArchiveJsonReachUploadsAndTheAdminPanel()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var archive = server.Services.GetRequiredService<ServerArchive>();
|
||||
var polling = server.Services.GetRequiredService<ArchivePolling>();
|
||||
// Nothing changed: the served archive (the one an administrator's edit put there) is not replaced by a row read again.
|
||||
var served = archive.Current;
|
||||
await polling.PollAsync(context.Cancellation);
|
||||
Assert.True(ReferenceEquals(served, archive.Current), "a poll that registered nothing keeps the served archive");
|
||||
|
||||
// A desktop sharing the archive changed its folder template and proxy size in archive.json.
|
||||
var path = new ArchivePaths(archive.Root).ManifestPath;
|
||||
var manifest = ManifestStore.ReadArchive(path);
|
||||
ManifestStore.WriteArchive(path, manifest with
|
||||
{
|
||||
LayoutTemplates = manifest.LayoutTemplates with { Folder = "{camera}/{date}" },
|
||||
ProxyPolicy = manifest.ProxyPolicy with { LongEdge = 2560 },
|
||||
});
|
||||
|
||||
await polling.PollAsync(context.Cancellation);
|
||||
|
||||
// Uploads (the index row) and the admin panel (the served archive) follow it.
|
||||
Assert.Equal(("{camera}/{date}", 2560), (archive.Current.FolderTemplate, archive.Current.ProxyLongEdge));
|
||||
var row = Assert.NotNull(await server.Database.Archives.GetAsync(archive.Id, context.Cancellation));
|
||||
Assert.Equal(("{camera}/{date}", 2560), (row.FolderTemplate, row.ProxyLongEdge));
|
||||
|
||||
// The admin panel opens before the next poll: its form, which saves every field, starts from the desktop's change.
|
||||
ManifestStore.WriteArchive(path, ManifestStore.ReadArchive(path) with { LayoutTemplates = manifest.LayoutTemplates with { Folder = "{year}/{camera}" } });
|
||||
var admin = await server.AdminAsync();
|
||||
using (var read = await admin.GetAsync("/api/v1/archive/settings"))
|
||||
Assert.Equal("{year}/{camera}", (await read.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto)).FolderTemplate);
|
||||
Assert.Equal("{year}/{camera}", archive.Current.FolderTemplate);
|
||||
|
||||
// A refresh that read the archive before an administrator saved an edit never puts it back over that edit.
|
||||
var before = archive.Current;
|
||||
archive.Current = before with { Name = "Edited" };
|
||||
Assert.False(archive.TryReplace(before, before with { Name = "Stale" }), "the edit saved meanwhile stays");
|
||||
Assert.Equal("Edited", archive.Current.Name);
|
||||
}
|
||||
|
||||
private static async Task UntilIndexedAsync(TestServer server, Guid archiveId, string folder)
|
||||
{
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(30);
|
||||
|
||||
Reference in new issue
Block a user