dashboard: surface lazy-load errors via BrowseLoadState.Error

This commit is contained in:
Joseph Doherty
2026-05-28 13:15:26 -04:00
parent 310dfab8b4
commit 5932fe2fd3
2 changed files with 20 additions and 0 deletions
@@ -232,6 +232,11 @@
private async Task LoadChildrenAsync(DashboardBrowseNode node)
{
BrowseLevelResult result = BrowseService.GetChildren(node.Object.GobjectId, new BrowseFilterArgs());
if (!string.IsNullOrEmpty(result.Error))
{
throw new InvalidOperationException(result.Error);
}
node.Children.Clear();
foreach (DashboardBrowseNode child in result.Nodes)
{
@@ -82,6 +82,21 @@ public sealed class DashboardBrowseServiceTests
Assert.Equal(12UL, after.CacheSequence);
}
/// <summary>Verifies that <see cref="DashboardBrowseService.GetChildren"/> returns an
/// empty node list with a non-empty <c>Error</c> when the cache has not yet loaded
/// (i.e. <see cref="GalaxyHierarchyCacheEntry.HasData"/> is false).</summary>
[Fact]
public void GetChildren_CacheNotLoaded_ReturnsErrorResult()
{
StubGalaxyHierarchyCache cache = new(GalaxyHierarchyCacheEntry.Empty);
DashboardBrowseService service = new(cache);
BrowseLevelResult result = service.GetChildren(parentGobjectId: 1, new BrowseFilterArgs());
Assert.Empty(result.Nodes);
Assert.False(string.IsNullOrEmpty(result.Error));
}
private static IReadOnlyList<GalaxyObject> CreateObjects()
{
// Fixture: an Area "Plant" (id 1, parent 0, IsArea=true) containing one