Merge branch 'review2-p5a-fix2-desktop' into review2-p5a-int2
# Conflicts: # i18n/en/Editor.resx # i18n/en/Tooltips.resx # i18n/it/Tooltips.it.resx # src/Chronos.Data/Workspaces/WorkspaceSync.cs # tests/Chronos.Data.Tests/Workspaces/WorkspaceRecoveryTests.cs
This commit is contained in:
commit
47c660735f
30 files changed
+1021
-110
No files matched your search
@@ -78,6 +78,80 @@ public abstract class WorkspaceConflictTests(TestContext context) : DatabaseTest
|
||||
ProjectSettings.FromJson(v.SettingsJson) is { Stack.Mode: StackSetting.StarTrails, Exposure.ExposureOffsetEv: 1.0 }), "the values taken over stay in a version");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TakingTheLibrarysValuesOverUnsavedChangesSendsNoVersion()
|
||||
{
|
||||
var (fx, _, two, id, shown) = await AskedAsync(await FixtureAsync());
|
||||
// Unsaved too: a setting only this side changed.
|
||||
await EditAsync(two, id, s => s with { Motion = s.Motion with { TargetShutterAngle = s.Motion.TargetShutterAngle.WithManual(90) } }, fx.Ct);
|
||||
var history = await fx.Home.HistoryAsync(id, null, 10, fx.Ct);
|
||||
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict);
|
||||
Assert.Empty(two.Unpushed(id), "no version of the working state is made, so none repeating the head is sent");
|
||||
Assert.Equal(WorkspaceState.Modified, settled.Status.State, "the change only this side made waits, unsaved as it was");
|
||||
var working = (await two.OpenAsync(id, fx.Ct)).Working;
|
||||
Assert.Equal((0.5, StackSetting.Median, 90.0), (working.Exposure.ExposureOffsetEv, working.Stack.Mode, working.Motion.TargetShutterAngle.Resolve(0)));
|
||||
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
|
||||
Assert.Empty((await two.PushAsync(id, fx.Home, fx.Ct)).Pushed);
|
||||
Assert.Equal(history.Count, (await fx.Home.HistoryAsync(id, null, 10, fx.Ct)).Count, "the library's history holds no empty version");
|
||||
|
||||
// The value taken over stays in a version file set aside, outside the versions to send.
|
||||
var replaced = Path.Combine(two.Store.Find(id)!.VersionsDirectory, WorkspaceProject.ReplacedFolder);
|
||||
Assert.Contains(Directory.GetFiles(replaced).Select(ProjectSidecars.ReadVersion), v => ProjectSettings.FromJson(v.SettingsJson).Exposure.ExposureOffsetEv == 1.0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AConflictListsTheWorkingStatesValueAndOneAnswerSettlesIt()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (_, one) = fx.Workspace("one");
|
||||
var (_, two) = fx.Workspace("two");
|
||||
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
||||
await fx.CheckoutAsync(two, id);
|
||||
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
||||
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await one.PushAsync(id, fx.Home, fx.Ct);
|
||||
// This side saved 0.8 as a version, then went on to 1 without saving.
|
||||
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
|
||||
await two.CommitAsync(id, "warmer", cancellationToken: fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
|
||||
|
||||
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
||||
var difference = shown.Differences.Single();
|
||||
Assert.Equal(("exposure.exposureOffsetEv", 1.0, 0.5), (difference.Path, Number(difference.Mine), Number(difference.Theirs)),
|
||||
"this side's value is the one the editor shows");
|
||||
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict, "one answer settles what was shown");
|
||||
Assert.Equal(0.5, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv);
|
||||
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
|
||||
Assert.Equal("warmer", two.Unpushed(id).Single().Note, "the saved version is replayed, nothing more");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task KeepMineKeepsTheWorkingStatesValueItListed()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (_, one) = fx.Workspace("one");
|
||||
var (_, two) = fx.Workspace("two");
|
||||
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
||||
await fx.CheckoutAsync(two, id);
|
||||
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
||||
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await one.PushAsync(id, fx.Home, fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
|
||||
await two.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
|
||||
|
||||
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
||||
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.KeepMine, shown: shown, cancellationToken: fx.Ct);
|
||||
Assert.Null(settled.Status.Conflict);
|
||||
Assert.Equal(1.0, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv, "the value listed as this side's is kept");
|
||||
}
|
||||
|
||||
private static double? Number(string? json) => json is null ? null : double.Parse(json, System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
[Test]
|
||||
public async Task KeepMineIsAskedAgainWhenTheLibraryMovedOnASettingThisSideChanged()
|
||||
{
|
||||
|
||||
@@ -159,8 +159,7 @@ public abstract class WorkspaceRecoveryTests(TestContext context) : DatabaseTest
|
||||
Assert.Equal(WorkspaceState.InSync, (await one.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
||||
var head = Settings(await fx.Home.HeadAsync(id, fx.Ct));
|
||||
Assert.Equal((1.0, StackSetting.Mean), (head.Exposure.ExposureOffsetEv, head.Stack.Mode));
|
||||
// Taking the server's first saves the unsaved offset as a version, kept aside for its undo: replayed it holds the
|
||||
// server's values only, so it is not sent.
|
||||
// The unsaved offset taken over is kept aside, never sent: the home holds exactly these versions, in order.
|
||||
Assert.SequenceEqual(["first", "other", "second"], (await NotesAsync(fx, id)).Skip(1));
|
||||
Assert.Contains(Directory.GetFiles(Path.Combine(one.Store.Project(id).VersionsDirectory, WorkspaceProject.ReplacedFolder)),
|
||||
f => ProjectSidecars.ReadVersion(f) is { Note: null } saved && Settings(saved).Exposure.ExposureOffsetEv == 2.0);
|
||||
|
||||
Reference in new issue
Block a user