Owner review 2, R8. Round 2's checkers left five desktop problems: - A workspace copy whose project.chronos a newer Chronos wrote (a format this one does not know) was listed as damaged and offered for Discard. It is now listed as "Newer Chronos" with its own tooltip, named from what of its file still reads. It never opens, is never checked out over, and Remove local copy refuses it with a sentence that says why. - Discard of any copy moved only the files Chronos knows. It now moves every file and folder of the copy aside (only the media are deleted) and removes the folder only when nothing else came into it. - Discarding a damaged copy asked to type its folder's GUID. It now asks for the name the copy is still known by (its file, else the library's index; the project's name, else the sequence's title), else for the number of its files. The heading never shows the id. - A conflict at a path where the working state had gone back to the base value listed the local version's value. The conflict now lists the working state's value in every case. Where the working state already holds the library's value there is nothing to ask: that path takes the library's value in the replayed versions too, so they agree. - EditorSession.ReloadAsync, ResolveConflict and TakeOverAsync threw NewerSettingsException on every reload when an edit was not stored yet and the stored project became a newer Chronos's. The edit is now kept in versions/.replaced (outside the chain, never sent), a toast says so, the pending save is dropped and the newer settings are shown read-only. When the edit cannot be kept aside, the editor stays as it is and nothing is dropped. The SequenceViewModel wiring now has a view-model test: the copy's facts in Open in workspace, the refused-folder toast and its Choose folder action, and the picker for a newer copy and a damaged one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
5.0 KiB
C#
99 lines
5.0 KiB
C#
using System.IO;
|
|
using Chronos.Core.Project;
|
|
using Chronos.Data.Projects;
|
|
using Chronos.Data.Workspaces;
|
|
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);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task AnEditNotStoredYetIsKeptAsideWhenANewerChronossSettingsArrive()
|
|
{
|
|
await using var bed = await WorkspaceTestBed.CreateAsync(context);
|
|
var host = bed.Host();
|
|
var projectId = await bed.CheckoutAsync(host);
|
|
var (source, session) = await bed.OpenAsync(host, projectId);
|
|
await using (session)
|
|
{
|
|
var kept = new List<string>();
|
|
session.EditSetAside += kept.Add;
|
|
Assert.True(session.Edit(p => Exposure(p, 0.4)));
|
|
Assert.True(await session.FlushAsync());
|
|
Assert.NotNull(await host.CommitAsync(projectId, bed.Ct));
|
|
var folder = host.Store.Find(projectId)!;
|
|
var stored = folder.ReadBundle();
|
|
// A sync took a newer Chronos's settings while one more edit waited for its save (made during the sync).
|
|
folder.WriteBundle(stored with { Project = Exposure(stored.Project, 1.5) with { Version = ProjectSettings.CurrentVersion + 1 } });
|
|
Assert.True(session.Edit(p => p with { ExcludedFrames = [2] }));
|
|
Assert.False(await session.FlushAsync(), "the working state no longer takes it");
|
|
|
|
await session.ReloadAsync();
|
|
|
|
Assert.True(session.IsReadOnly);
|
|
Assert.True(session.Project.IsNewerFormat, "the newer settings are taken");
|
|
Assert.Equal(1.5, session.Project.Exposure.ExposureOffsetEv);
|
|
Assert.True(await session.FlushAsync(), "nothing retried that could never be stored");
|
|
Assert.False(session.HasPendingSave);
|
|
Assert.Null(session.LastSaveError);
|
|
var path = Assert.NotNull(kept.SingleOrDefault(), "the edit is kept aside, and said");
|
|
Assert.Equal(Path.Combine(folder.VersionsDirectory, WorkspaceProject.ReplacedFolder), Path.GetDirectoryName(path));
|
|
var aside = ProjectSidecars.ReadVersion(path);
|
|
var placed = ProjectSettings.FromJson(ProjectContent.Place(aside.SettingsJson, source.Photos));
|
|
Assert.Equal(0.4, placed.Exposure.ExposureOffsetEv);
|
|
Assert.SequenceEqual([2], placed.ExcludedFrames, "the edit as it was, by photo");
|
|
Assert.False(folder.Versions().Any(v => v.Id == aside.Id), "outside the chain: never sent");
|
|
Assert.Empty(host.Sync.Unpushed(projectId).Where(v => v.Id == aside.Id));
|
|
|
|
// Read again: no throw, nothing more kept aside, the editor as it is.
|
|
await session.ReloadAsync();
|
|
Assert.Count(1, kept);
|
|
Assert.Equal(1.5, session.Project.Exposure.ExposureOffsetEv);
|
|
Assert.True(await session.FlushAsync());
|
|
}
|
|
}
|
|
}
|