Files
Chronos/tests/Chronos.App.Tests/Workspace/WorkspaceNewerFormatTests.cs
T
Alby96andClaude Opus 5.5 43b092bd5d fix(workspace): newer-format editor stays usable; media learn the home's photo names
A pull onto a newer Chronos's settings made the editor throw: ProjectHistory.Replace
rebased every undo and redo snapshot through ProjectMerge, which refuses to merge a
newer format when both sides changed, so any non-empty undo stack broke the reload
after a sync that had succeeded. Replace now drops the steps instead when either side
(or a step) is of a newer format: the project is shown read-only and undo never brings
back values from before the newer settings.

The media learnt the home's hashes and conversion aliases only inside a replay, so a
status or Save version before that compared a SHA-named base with photo-named media
and read a false Modified or saved a version that only re-keyed photos. Now:
- ProjectContent.SameChoices also compares the texts as placed on the frames, hashed
  or not (Bound), so status and commit without a home agree with the base;
- a status asked of the home teaches the media its names (written under the lease, or
  when the lease is free), and so does a checkout of a project already here;
- WorkspaceStatus.MediaOutdated reports frames moved at the home, or names the media
  could not learn yet, and the project menu offers Update media for it (tooltip text
  updated in en and it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 11:19:21 +01:00

50 lines
2.3 KiB
C#

using Chronos.Core.Project;
using Chronos.Testing;
namespace Chronos.App.Tests.Workspace;
/// <summary>
/// The editor of a workspace project whose home moved to settings of a newer Chronos (owner review 2, R8): shown read-only,
/// never merged with this Chronos's, the editor usable whatever its undo steps hold.
/// </summary>
[Category("workspace")]
public sealed class WorkspaceNewerFormatTests(TestContext context)
{
private static ProjectSettings Exposure(ProjectSettings p, double ev) => p with { Exposure = p.Exposure with { ExposureOffsetEv = ev } };
[Test]
public async Task AnEditorWithUndoStepsTakesANewerChronossSettingsReadOnly()
{
await using var bed = await WorkspaceTestBed.CreateAsync(context);
var host = bed.Host();
var projectId = await bed.CheckoutAsync(host);
var (_, session) = await bed.OpenAsync(host, projectId);
await using (session)
{
// Edited, saved and kept as a version: every edit is stored, the undo steps stay.
Assert.True(session.Edit(p => Exposure(p, 0.4)));
Assert.True(session.Edit(p => p with { ExcludedFrames = [2] }));
Assert.True(await session.FlushAsync());
Assert.NotNull(await host.CommitAsync(projectId, bed.Ct));
Assert.True(session.History.CanUndo);
// A pull with nothing of this PC's waiting moved the working state onto a newer Chronos's settings.
var folder = host.Store.Find(projectId)!;
var stored = folder.ReadBundle();
folder.WriteBundle(stored with { Project = Exposure(stored.Project, 1.5) with { Version = ProjectSettings.CurrentVersion + 1 } });
await session.ReloadAsync();
Assert.True(session.IsReadOnly);
Assert.True(session.Project.IsNewerFormat);
Assert.Equal(1.5, session.Project.Exposure.ExposureOffsetEv);
Assert.False(session.History.CanUndo, "no step brings this Chronos's values back over the newer ones");
Assert.False(session.Undo());
Assert.False(session.Edit(p => Exposure(p, 0.2)));
Assert.False(session.HasPendingSave);
// Read again (another analysis, another pull): the editor stays as it is.
await session.ReloadAsync();
Assert.Equal(1.5, session.Project.Exposure.ExposureOffsetEv);
}
}
}