Windows test of 1.1.0: stale screen tests, Jobs fixes; 1.1.1 #71

Merged
Alby96 merged 3 commits from win-test-1.1 into main 2026-11-16 15:31:17 +01:00
7 changed files with 74 additions and 5 deletions
Showing only changes of commit 28a9afdd7c - Show all commits

No files matched your search

+61
View File
@@ -20,6 +20,8 @@ public static class ArchiveScenes
await archive.LoadAsync();
var db = shell.Services.Database ?? throw new InvalidOperationException("The sample index is not open.");
var locations = archive.SelectedArchive is { } selected ? await db.Sequences.ListLocationsAsync(selected.Id) : [];
// What the Reorganize view wrote leaves with it, so the sample's sizes stay the same for the views after it.
RemoveSampleFiles();
switch (view)
{
case "overview":
@@ -35,6 +37,9 @@ public static class ArchiveScenes
break;
case "reorganize":
archive.ViewIndex = 0;
// The dry run reads each sequence's sidecar, which the sample index has none of: without them every
// sequence would show "cannot be read" and Apply would stay off.
if (archive.SelectedArchive is { } reorganized) await WriteSampleSidecarsAsync(db, reorganized.RootPath, locations);
await archive.OpenReorganizeDialogAsync();
if (archive.Dialog is ReorganizeDialogViewModel reorganize)
{
@@ -60,4 +65,60 @@ public static class ArchiveScenes
throw new ArgumentOutOfRangeException(nameof(view), view, "Unknown Archive view.");
}
}
/// <summary>
/// A minimal sidecar for each sample sequence that has none yet: its id, title and camera, and one small stand-in photo in
/// its originals taken at its first capture, which the templates' dates and file names come from.
/// </summary>
private static async Task WriteSampleSidecarsAsync(Data.ChronosDatabase db, string root, IReadOnlyList<Data.Repositories.SequenceLocation> locations)
{
// A file is recorded before it is written, so one half written goes too.
var paths = new Core.Archiving.ArchivePaths(root);
byte[] photo = [0xFF, 0xD8, 0xFF, 0xD9];
var sha256 = Convert.ToHexStringLower(System.Security.Cryptography.SHA256.HashData(photo));
foreach (var location in locations)
{
var folder = paths.Sequence(location.Folder);
if (System.IO.File.Exists(folder.ManifestPath) || await db.Sequences.GetAsync(location.Id) is not { } sequence) continue;
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(folder.ManifestPath)!);
const string file = Core.Archiving.ArchiveLayout.OriginalsFolder + "/IMG_0001.JPG";
var frames = new List<Core.Archiving.SidecarFrame>();
if (sequence.FirstCapture is { } first)
{
var onDisk = System.IO.Path.Combine(folder.Folder, file);
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(onDisk)!);
SampleFiles.Add(onDisk);
System.IO.File.WriteAllBytes(onDisk, photo);
frames.Add(new Core.Archiving.SidecarFrame { Id = Guid.CreateVersion7(), File = file, Size = photo.Length, Sha256 = sha256, CapturedAt = first });
}
SampleFiles.Add(folder.ManifestPath);
Core.Archiving.ManifestStore.WriteSequence(folder.ManifestPath, new Core.Archiving.SequenceManifest
{
Id = sequence.Id,
Title = sequence.Title,
Camera = new Core.Archiving.SidecarCamera { Make = sequence.CameraMake, Model = sequence.CameraModel },
Frames = frames,
});
}
}
/// <summary>The files <see cref="WriteSampleSidecarsAsync"/> wrote that are still on disk.</summary>
private static readonly List<string> SampleFiles = [];
/// <summary>Deletes the files the Reorganize view wrote for its dry run.</summary>
private static void RemoveSampleFiles()
{
foreach (var path in SampleFiles)
{
try
{
System.IO.File.Delete(path);
}
catch (Exception ex) when (ex is System.IO.IOException or UnauthorizedAccessException)
{
Core.Diagnostics.Log.Warning("capture", $"{path} of the sample stays", ex);
}
}
SampleFiles.Clear();
}
}
+1 -1
View File
@@ -694,7 +694,7 @@
<Grid Height="36">
<!-- The server name gives way first (it ends in an ellipsis), so Forget fits at 1200 px in longer languages. -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="120" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="170" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="Auto" />
@@ -100,7 +100,7 @@ public sealed class ArchiveScreenSmokeTests
Assert.NotEmpty(reorganize.Rows, "the dry run lists the sequences that change");
Assert.Null(reorganize.ErrorText);
await app.ExpectAsync<ArchiveView>("archive-reorganize");
Assert.True(ButtonFor(app, reorganize.ApplyCommand).IsEnabled, "Apply follows the dry run");
Assert.True(ButtonFor(app, reorganize.ApplyCommand).IsEnabled, "Apply follows the dry run: " + reorganize.ApplyToolTip);
Assert.True(ButtonFor(app, reorganize.CloseCommand).IsDefault, "Enter takes the safe way out");
foreach (var box in app.FindAll<CheckBox>().Where(c => c.IsVisible)) Assert.NotNull(box.ToolTip, "every template switch says what it does");
AssertNoErrorShown(app);
@@ -149,7 +149,7 @@ public sealed class ArchiveScreenSmokeTests
// The dialogs' templates exist once they are laid out: render first, then look inside.
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
await app.ExpectAsync<ArchiveView>("archive-rebuild-ar");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, archive.SelectedArchive!.RootPath).FlowDirection, "the archive folder reads left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, AppEnvironment.Shown(archive.SelectedArchive!.RootPath)).FlowDirection, "the archive folder reads left to right");
await ArchiveScenes.ShowAsync(app.Shell, "reorganize");
var reorganize = Assert.NotNull(archive.Dialog as ReorganizeDialogViewModel);
@@ -299,7 +299,14 @@ public sealed class ArchiveScreenSmokeTests
UiLanguage.Apply(language);
window.UpdateLayout();
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
// A language switch builds the tree's rows again; they may arrive a few layout passes later.
var years = TreeItems(app).Where(i => ((ArchiveTreeRowViewModel)i.DataContext).IsYear).ToList();
for (var until = DateTime.UtcNow.AddSeconds(TestTiming.Budget(5)); years.Count == 0 && DateTime.UtcNow < until;)
{
await Task.Delay(50);
window.UpdateLayout();
years = TreeItems(app).Where(i => ((ArchiveTreeRowViewModel)i.DataContext).IsYear).ToList();
}
Assert.True(years.Count > 0, $"{language}: year rows show");
foreach (var item in years)
{
@@ -50,7 +50,8 @@ public sealed class ServerScreenSmokeTests
var sunrise = Row(table, "Sunrise over Superga");
Assert.Equal(SyncStatus.ProxiesOnly, sunrise.Entry.Status);
Assert.Equal(Loc.L("Server.Sync.Proxies"), sunrise.LocalText);
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals], Actions(sunrise));
// A server without projects: open with proxies; the workspace is offered, disabled with the reason (phase 5b).
Assert.SequenceEqual([SyncAction.OpenWithProxies, SyncAction.DownloadOriginals, SyncAction.OpenInWorkspace], Actions(sunrise));
Assert.SequenceEqual([SyncAction.Upload], Actions(Row(table, "Clouds over the Langhe")));
var conflict = Row(table, "Holy grail · Monviso");
Assert.Equal(StatusKind.Warning, conflict.StateKind);
@@ -83,7 +83,7 @@ public sealed class ScreenSmokeTests
Assert.Equal(0, shell.Library.SelectionCount);
shell.Navigate(SectionKey.Jobs);
Assert.Equal(9, shell.Jobs.Rows.Count);
Assert.Equal(10, shell.Jobs.Rows.Count, string.Join(" | ", shell.Jobs.Rows.Select(r => r.AccessibleName)));
Assert.True(shell.IsJobActive, "running jobs show in the job bar");
shell.Jobs.Rows[0].IsExpanded = true;
await app.ExpectAsync<JobsView>("jobs");
Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 90 KiB