From 85849783b3cb6ecb678c3e1354eb52e43c9556a1 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sat, 29 Aug 2026 13:11:47 +0300 Subject: [PATCH] Renders the navigation submenu entries under their parent label --- .../Common/DTO/Themes/ThemeNavEntryDto.cs | 8 +++- .../Core/Themes/ThemeTemplateEngineTests.cs | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeNavEntryDto.cs b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeNavEntryDto.cs index 3cab20a2..3afd00ce 100644 --- a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeNavEntryDto.cs +++ b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeNavEntryDto.cs @@ -18,4 +18,10 @@ public sealed record ThemeNavEntryDto( string? Url, string? CssClass, IReadOnlyList Children -); +) +{ + /// + /// Gets whether this entry is a submenu: it has child links instead of a direct URL. + /// + public bool IsSubmenu => Children.Count > 0; +} diff --git a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeTemplateEngineTests.cs b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeTemplateEngineTests.cs index e19b1753..f802258d 100644 --- a/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeTemplateEngineTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Web.UnitTests/Core/Themes/ThemeTemplateEngineTests.cs @@ -2,6 +2,7 @@ using Lumina.Presentation.Web.Common.DTO.Themes; using Lumina.Presentation.Web.Common.Primitives; using Lumina.Presentation.Web.Core.Themes; +using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes; using Lumina.Presentation.Web.Fixtures.Common.Models; using System; using System.Collections.Generic; @@ -19,6 +20,9 @@ public class ThemeTemplateEngineTests { private readonly ThemeTemplateEngine _sut; private readonly SectionModelFixture _sectionModelFixture = new(); + private readonly ThemeNavMenuDtoFixture _themeNavMenuDtoFixture = new(); + private readonly ThemeNavSectionDtoFixture _themeNavSectionDtoFixture = new(); + private readonly ThemeNavEntryDtoFixture _themeNavEntryDtoFixture = new(); /// /// Initializes a new instance of the class. @@ -120,6 +124,40 @@ public class ThemeTemplateEngineTests Assert.Equal("3", result.Value.Content); } + [Fact] + public void RenderPage_WhenMenuEntryHasChildren_ShouldRenderEntryLabelOnceWithNestedChildren() + { + // Arrange + ThemeNavMenuDto model = _themeNavMenuDtoFixture.Create( + siteName: "Lumina", + mobileSections: [], + menubarSections: + [ + _themeNavSectionDtoFixture.Create( + label: "Tools", + items: + [ + _themeNavEntryDtoFixture.Create( + label: "Language", + includeUrl: false, + children: + [ + _themeNavEntryDtoFixture.Create(label: "English", includeUrl: true, url: "/en", cssClass: "lang-set", includeCssClass: true), + _themeNavEntryDtoFixture.Create(label: "Francais", includeUrl: true, url: "/fr", cssClass: "lang-set", includeCssClass: true) + ]), + _themeNavEntryDtoFixture.Create(label: "Settings", includeUrl: true, url: "/settings", cssClass: "nav-link", includeCssClass: true) + ]) + ]); + string template = "{{#menubarSections}}{{label}}:{{#items}}{{#isSubmenu}}[{{label}}]{{#children}}{{label}},{{/children}}{{/isSubmenu}}{{^isSubmenu}}{{label}}{{/isSubmenu}}{{/items}}{{/menubarSections}}"; + + // Act + Result result = _sut.RenderPage(template, model); + + // Assert + Assert.True(result.IsSuccess); + Assert.Equal("Tools:[Language]English,Francais,Settings", result.Value.Content); + } + [Fact] public void RenderPage_WhenSectionIsTruthy_ShouldRenderChildren() {