diff --git a/src/ZB.MOM.WW.MxGateway.Server/Dashboard/Components/Pages/BrowsePage.razor b/src/ZB.MOM.WW.MxGateway.Server/Dashboard/Components/Pages/BrowsePage.razor index 282e436..bda9020 100644 --- a/src/ZB.MOM.WW.MxGateway.Server/Dashboard/Components/Pages/BrowsePage.razor +++ b/src/ZB.MOM.WW.MxGateway.Server/Dashboard/Components/Pages/BrowsePage.razor @@ -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) { diff --git a/src/ZB.MOM.WW.MxGateway.Tests/Dashboard/DashboardBrowseServiceTests.cs b/src/ZB.MOM.WW.MxGateway.Tests/Dashboard/DashboardBrowseServiceTests.cs index 9df9b44..d749e08 100644 --- a/src/ZB.MOM.WW.MxGateway.Tests/Dashboard/DashboardBrowseServiceTests.cs +++ b/src/ZB.MOM.WW.MxGateway.Tests/Dashboard/DashboardBrowseServiceTests.cs @@ -82,6 +82,21 @@ public sealed class DashboardBrowseServiceTests Assert.Equal(12UL, after.CacheSequence); } + /// Verifies that returns an + /// empty node list with a non-empty Error when the cache has not yet loaded + /// (i.e. is false). + [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 CreateObjects() { // Fixture: an Area "Plant" (id 1, parent 0, IsArea=true) containing one