test(app): editor history, saver retry, merge, preview re-solve and capture scenes

- Tests for undo after adopted changes, run ending, saver retries and stop,
  the local source refusing unsaved writes, re-solves without decoding and equal
  to a fresh preparation, 1:1 pictures, waveform, crop margins and the values of
  the Optimise toast; the Windows smoke test checks Render, Batch, the waveform,
  1:1, the window title and the hidden idle job bar.
- The capture sample has a manual value and camera keyframes; the capture adds
  the overlays, the waveform, the Optimise toast and Export.html's tool state.
- Crop margins live in a WPF-free class; a discarded change stops retrying.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 10:44:21 +00:00
1 parent 25e85aee57
commit fa5699e6f3
15 files changed
+462 -53

No files matched your search

@@ -112,6 +112,76 @@ public sealed class SchedulingTests
Assert.Equal(1, saved);
}
[Test]
public async Task AFailedWriteIsRetriedUntilStored()
{
var attempts = 0;
var stored = new List<int?>();
var failures = new List<int>();
var saver = new ProjectSaver(p =>
{
if (++attempts <= 2) throw new System.IO.IOException("offline");
stored.Add(p.HeroFrame);
return Task.CompletedTask;
}, TimeSpan.Zero);
saver.Failed += (_, count) => failures.Add(count);
// Without a delay the first write happens at once and fails; the flush retries at once and fails again.
saver.Schedule(new ProjectSettings { HeroFrame = 7 });
Assert.False(await saver.FlushAsync());
Assert.True(saver.HasPendingChanges, "kept pending after a failure");
Assert.NotNull(saver.LastError);
Assert.True(await saver.FlushAsync().WaitAsync(TimeSpan.FromSeconds(10)), "a flush skips the retry delay");
Assert.SequenceEqual([(int?)7], stored);
Assert.SequenceEqual([1, 2], failures, "failures in a row are counted");
Assert.False(saver.HasPendingChanges);
Assert.Null(saver.LastError);
}
[Test]
public async Task ARetryWritesTheNewestChange()
{
var fail = true;
var stored = new List<int?>();
var saver = new ProjectSaver(p =>
{
if (fail) throw new System.IO.IOException("offline");
stored.Add(p.HeroFrame);
return Task.CompletedTask;
}, TimeSpan.Zero);
saver.Schedule(new ProjectSettings { HeroFrame = 1 });
Assert.False(await saver.FlushAsync());
saver.Schedule(new ProjectSettings { HeroFrame = 2 });
fail = false;
Assert.True(await saver.FlushAsync());
Assert.SequenceEqual([(int?)2], stored, "the newer project contains the failed one");
}
[Test]
public async Task StopDropsThePendingChange()
{
var saved = 0;
var saver = new ProjectSaver(_ =>
{
saved++;
throw new System.IO.IOException("offline");
}, TimeSpan.Zero);
saver.Schedule(new ProjectSettings { HeroFrame = 1 });
Assert.False(await saver.FlushAsync());
var attempts = saved;
saver.Stop();
Assert.True(await saver.FlushAsync().WaitAsync(TimeSpan.FromSeconds(10)), "nothing pending after a stop");
saver.Schedule(new ProjectSettings { HeroFrame = 2 });
Assert.False(saver.HasPendingChanges, "a stopped saver takes no new change");
Assert.Equal(attempts, saved);
}
[Test]
public async Task FlushWithNothingPendingIsStored()
{
var saver = new ProjectSaver(_ => Task.CompletedTask, TimeSpan.FromMinutes(5));
Assert.True(await saver.FlushAsync().WaitAsync(TimeSpan.FromSeconds(10)));
}
[Test]
public async Task AChangeDuringAWriteIsWrittenAfterIt()
{