diff --git a/Redot-Documentation-Tests/ClassDocumentationComponentTests.cs b/Redot-Documentation-Tests/ClassDocumentationComponentTests.cs index de29268..479f1b6 100644 --- a/Redot-Documentation-Tests/ClassDocumentationComponentTests.cs +++ b/Redot-Documentation-Tests/ClassDocumentationComponentTests.cs @@ -161,6 +161,42 @@ await renderer.Dispatcher.InvokeAsync(async () => Assert.Empty(renderer.Errors); } + [Fact] + public async Task ClassPage_RendersNavigationForSectionsAndOverloadedMembers() + { + await using var services = CreateServices(); + var catalog = services.GetRequiredService(); + var manager = services.GetRequiredService(); + var navigation = services.GetRequiredService(); + navigation.NavigateTo("/en/26.1/Classes/Node?source=search"); + var node = new ClassDocumentationEntry + { + Name = "Node", + Methods = + [ + new ClassDocumentationCallable { Name = "add_child" }, + new ClassDocumentationCallable { Name = "add_child" } + ] + }; + catalog.Publish(new ClassDocumentationSnapshot(manager.LatestStableVersion, "1234567890abcdef", + DateTimeOffset.UtcNow, new Dictionary { ["Node"] = node })); + + await using var renderer = new TestRenderer(services); + int id = await renderer.Dispatcher.InvokeAsync(() => renderer.RenderAsync(typeof(ClassDocViewer), + ParameterView.FromDictionary(new Dictionary + { ["VersionSlug"] = "26.1", ["ClassName"] = "Node" }))); + + string rendered = await renderer.Dispatcher.InvokeAsync(() => renderer.Text(id)); + string[] hrefs = await renderer.Dispatcher.InvokeAsync(() => renderer.Hrefs(id).ToArray()); + Assert.Contains("desktop-toc", await renderer.Dispatcher.InvokeAsync(() => renderer.CssClasses(id).ToArray())); + Assert.Contains("mobile-toc", await renderer.Dispatcher.InvokeAsync(() => renderer.CssClasses(id).ToArray())); + Assert.Contains("

", rendered); + Assert.Contains("/en/26.1/Classes/Node?source=search#methods", hrefs); + Assert.Contains("/en/26.1/Classes/Node?source=search#method-add-child", hrefs); + Assert.Contains("/en/26.1/Classes/Node?source=search#method-add-child-2", hrefs); + Assert.Empty(renderer.Errors); + } + [Theory] [InlineData(null)] [InlineData("Node")] diff --git a/Redot-Documentation-Tests/ClassDocumentationRendererTests.cs b/Redot-Documentation-Tests/ClassDocumentationRendererTests.cs index 769cb3d..6dc95b6 100644 --- a/Redot-Documentation-Tests/ClassDocumentationRendererTests.cs +++ b/Redot-Documentation-Tests/ClassDocumentationRendererTests.cs @@ -1,5 +1,7 @@ using System.Text.RegularExpressions; +using HtmlAgilityPack; using Redot_Documentation.ClassDocumentation; +using Redot_Documentation.Components.Layout; using Redot_Documentation.Versioning; namespace Redot_Documentation_Tests; @@ -39,7 +41,60 @@ public void RenderPage_RendersSignaturesStatusesAndStableAnchors() Assert.Contains("id=\"method-add-child\"", html); Assert.Contains("href=\"/en/latest/Classes/Object\"", html); Assert.Contains("class-status-experimental", html); - Assert.Contains("Node child", html); + Assert.Contains("Node child", html); + } + + [Fact] + public void RenderPage_HighlightsSignaturesAndCollectsMatchingMemberHeadings() + { + var renderer = new ClassDocumentationRenderer(); + ClassDocumentationSnapshot snapshot = CreateSnapshot(); + ClassDocumentationEntry node = snapshot.Classes["Node"] with + { + Description = "A useful class.", + Members = [new ClassDocumentationMember { Name = "enabled", Type = "bool", Default = "true" }], + Methods = + [ + new ClassDocumentationCallable + { + Name = "add_child", ReturnType = "void", Qualifiers = "virtual const", + Parameters = [new ClassDocumentationParameter("child", "Node", "Node(1, 2)", null, false)] + }, + new ClassDocumentationCallable + { + Name = "add_child", ReturnType = "void", + Parameters = [new ClassDocumentationParameter("unsafe", "String", "\"