fix(galaxy): include undeployed areas in browse + re-root orphaned objects
The hierarchy query returned deployed objects only (deployed_package_id <> 0), so areas whose containing area is undeployed were orphaned and hidden from /browse — on wonder, only the lone deployed root area surfaced. Include category-13 Area objects regardless of deployment, and in GalaxyHierarchyIndex re-root any object whose parent is absent from the set (e.g. a deleted container area) so nothing disappears under a phantom parent id.
This commit is contained in:
@@ -75,6 +75,35 @@ public sealed class GalaxyHierarchyIndexTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies an object whose parent is absent from the set (e.g. a deleted/undeployed
|
||||
/// container area) is re-rooted under sentinel 0 rather than vanishing under a phantom
|
||||
/// parent id that browse never reaches from the root.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ChildrenByParent_OrphanWithMissingParent_AppearsAsRoot()
|
||||
{
|
||||
GalaxyObject realRoot = new() { GobjectId = 1, ParentGobjectId = 0, IsArea = true, ContainedName = "RealRoot" };
|
||||
GalaxyObject orphanArea = new() { GobjectId = 2, ParentGobjectId = 5008, IsArea = true, ContainedName = "Orphan" };
|
||||
GalaxyObject orphanChild = new() { GobjectId = 3, ParentGobjectId = 2, ContainedName = "Child" };
|
||||
|
||||
GalaxyHierarchyIndex index = GalaxyHierarchyIndex.Build([realRoot, orphanArea, orphanChild]);
|
||||
|
||||
// Both the real root and the orphan (its parent 5008 is absent) surface under root.
|
||||
Assert.True(index.ChildrenByParent.TryGetValue(0, out IReadOnlyList<GalaxyObjectView>? roots));
|
||||
Assert.NotNull(roots);
|
||||
Assert.Contains(roots!, view => view.Object.GobjectId == 1);
|
||||
Assert.Contains(roots!, view => view.Object.GobjectId == 2);
|
||||
|
||||
// The orphan keeps its own deployed children nested beneath it.
|
||||
Assert.True(index.ChildrenByParent.TryGetValue(2, out IReadOnlyList<GalaxyObjectView>? underOrphan));
|
||||
Assert.Single(underOrphan!);
|
||||
Assert.Equal(3, underOrphan![0].Object.GobjectId);
|
||||
|
||||
// Nothing buckets under the phantom parent id.
|
||||
Assert.False(index.ChildrenByParent.ContainsKey(5008));
|
||||
}
|
||||
|
||||
/// <summary>Verifies <see cref="GalaxyHierarchyIndex.ObjectViewsByTagName"/> is OrdinalIgnoreCase and supports O(1) lookups.</summary>
|
||||
[Fact]
|
||||
public void ObjectViewsByTagName_IsCaseInsensitive_AndLookupsAreO1()
|
||||
|
||||
Reference in New Issue
Block a user