dashboard: surface lazy-load errors via BrowseLoadState.Error
This commit is contained in:
@@ -232,6 +232,11 @@
|
|||||||
private async Task LoadChildrenAsync(DashboardBrowseNode node)
|
private async Task LoadChildrenAsync(DashboardBrowseNode node)
|
||||||
{
|
{
|
||||||
BrowseLevelResult result = BrowseService.GetChildren(node.Object.GobjectId, new BrowseFilterArgs());
|
BrowseLevelResult result = BrowseService.GetChildren(node.Object.GobjectId, new BrowseFilterArgs());
|
||||||
|
if (!string.IsNullOrEmpty(result.Error))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(result.Error);
|
||||||
|
}
|
||||||
|
|
||||||
node.Children.Clear();
|
node.Children.Clear();
|
||||||
foreach (DashboardBrowseNode child in result.Nodes)
|
foreach (DashboardBrowseNode child in result.Nodes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,6 +82,21 @@ public sealed class DashboardBrowseServiceTests
|
|||||||
Assert.Equal(12UL, after.CacheSequence);
|
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()
|
private static IReadOnlyList<GalaxyObject> CreateObjects()
|
||||||
{
|
{
|
||||||
// Fixture: an Area "Plant" (id 1, parent 0, IsArea=true) containing one
|
// Fixture: an Area "Plant" (id 1, parent 0, IsArea=true) containing one
|
||||||
|
|||||||
Reference in New Issue
Block a user