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

@@ -2,6 +2,7 @@ using System.IO;
using System.Text.Json;
using Titano.App.Editor;
using Titano.Core.Advice;
using Titano.Core.Analysis;
using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Protocol;
@@ -61,29 +62,62 @@ public sealed class EditorSessionTests
{
source.ExternalEdit = p => p with { Camera = p.Camera with { OffsetY = -0.2 } };
session.Edit(p => p with { HeroFrame = 5 });
await session.FlushAsync();
Assert.True(await session.FlushAsync());
Assert.Equal(5, session.Project.HeroFrame);
Assert.Equal(-0.2, session.Project.Camera.OffsetY, "their change shows up in the editor");
Assert.True(session.Undo());
Assert.Null(session.Project.HeroFrame);
Assert.Equal(-0.2, session.Project.Camera.OffsetY, "undo keeps their change");
Assert.True(await session.FlushAsync());
Assert.Equal(-0.2, source.Stored.Camera.OffsetY, "and the undone project stored over it keeps it too");
Assert.True(session.Redo());
Assert.Equal(-0.2, session.Project.Camera.OffsetY);
}
}
[Test]
public async Task AFailedSaveIsReportedAndRetriedByTheNextChange()
public async Task AdviceFromAReloadSurvivesUndo()
{
var (session, source) = Open(deep: false);
await using (session)
{
session.Edit(p => p with { HeroFrame = 2 });
Assert.True(await session.FlushAsync());
// The deep analysis finished: its advice is stored, the editor reads it back.
source.Content = EditorFixture.Content(EditorFixture.Sunset, deep: true) with { Sequence = session.Content.Sequence };
var advice = Advisor.Recommend(source.Content.Light, source.Content.Deep, SequenceContext.FromFrames(source.Content.Frames));
source.Stored = Advisor.Apply(source.Stored, advice);
await session.ReloadAsync();
Assert.True(session.Project.Exposure.Deflicker.HasAdvice);
Assert.True(session.Undo());
Assert.Null(session.Project.HeroFrame);
Assert.True(session.Project.Exposure.Deflicker.HasAdvice, "undo does not wipe the advice");
Assert.True(await session.FlushAsync());
Assert.True(source.Stored.Exposure.Deflicker.HasAdvice, "nor does the save that follows");
}
}
[Test]
public async Task AFailedSaveStaysPendingUntilItIsStored()
{
var (session, source) = Open();
await using (session)
{
Exception? reported = null;
session.SaveFailed += ex => reported = ex;
var reported = 0;
session.SaveFailed += _ => reported++;
source.FailNextSave = new IOException("share offline");
session.Edit(p => p with { HeroFrame = 1 });
await session.FlushAsync();
Assert.NotNull(reported);
session.Edit(p => p with { HeroFrame = 2 });
await session.FlushAsync();
Assert.Equal(2, source.Stored.HeroFrame);
Assert.False(await session.FlushAsync(), "the flush reports the failure");
Assert.Equal(1, reported);
Assert.True(session.HasPendingSave, "closing the window must not drop the edit");
Assert.NotNull(session.LastSaveError);
Assert.Null(source.Stored.HeroFrame);
Assert.True(await session.FlushAsync(), "the retry stores it without another edit");
Assert.Equal(1, source.Stored.HeroFrame);
Assert.False(session.HasPendingSave);
Assert.Null(session.LastSaveError);
}
}