Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ public async Task<ComplexFormComponent> CreateComplexFormComponent(ComplexFormCo
return await repo.FindComplexFormComponent(addEntryComponentChange.EntityId);
}

if (between is not null)
// The orderable diff sends (null, null) for singletons; skip the move so
// revisits in one sync don't bump Order via PickOrder.
if (between is { Previous: not null } or { Next: not null })
{
await MoveComplexFormComponent(existing, between);
}
Expand Down
16 changes: 16 additions & 0 deletions backend/FwLite/MiniLcm.Tests/ComplexFormComponentTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ public async Task CreateComplexFormComponent_ReplayingReturnedObject_IsIdempoten
again.Should().BeEquivalentTo(created);
}

[Fact]
public async Task CreateComplexFormComponent_BetweenWithNoAnchors_DoesNotReorderExisting()
{
// Sync can revisit the same CFC with (null, null) — once via SyncComplexForms,
// again via SyncComplexFormComponents. The second call must not reorder.
var first = await Api.CreateComplexFormComponent(
ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry));
var second = await Api.CreateComplexFormComponent(
ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry),
new BetweenPosition<ComplexFormComponent>(null, null));

second.Order.Should().Be(first.Order);
var entry = await Api.GetEntry(_complexFormEntryId);
entry!.Components.Should().ContainSingle().Which.Order.Should().Be(first.Order);
}

[Fact]
public async Task CreateComplexFormComponent_UsingTheSameComponentWithSenseDoesNothing()
{
Expand Down
Loading