fix(admin-ui): align task orientation and navigation with page policies

This commit is contained in:
Joseph Doherty
2026-11-13 21:42:30 -05:00
parent 28add408c4
commit cb3400c13c
38 changed files with 1996 additions and 58 deletions
@@ -15,24 +15,20 @@ namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
/// user can get there.
/// </summary>
/// <remarks>
/// Source scan rather than a rendering assertion: the repo has no bUnit (the central
/// <c>PackageVersion</c> for it is referenced by no project), and razor layout markup — unlike
/// a page's <c>@page</c>/<c>@attribute</c> directives — does not survive into class metadata
/// any form a reflection guard can read. So this proves the link and its gate are *written*;
/// that the gate actually admits an Administrator and hides the item from a Designer is
/// live-verified on the docker-dev rig, per this repo's Razor convention.
/// This source guard preserves the exact package policy expression. Rendered policy visibility
/// is independently covered by NavigationPolicyRenderTests; neither replaces route authorization.
/// </remarks>
[Trait("Category", "Unit")]
public sealed class SecretsNavLinkTests
{
private const string NavItem = "<NavRailItem Href=\"/admin/secrets\"";
private static string ReadMainLayoutSource()
private static string ReadMainLayoutSource([System.Runtime.CompilerServices.CallerFilePath] string sourceFile = "")
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
var dir = new DirectoryInfo(Path.GetDirectoryName(sourceFile)!);
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ZB.MOM.WW.OtOpcUa.slnx")))
dir = dir.Parent;
dir.ShouldNotBeNull("could not locate the repository root (no ZB.MOM.WW.OtOpcUa.slnx above the test binary)");
dir.ShouldNotBeNull("could not locate the repository root (no ZB.MOM.WW.OtOpcUa.slnx above the test source)");
return File.ReadAllText(Path.Combine(
dir!.FullName, "src", "Server", "ZB.MOM.WW.OtOpcUa.AdminUI",
@@ -62,7 +58,7 @@ public sealed class SecretsNavLinkTests
{
var source = ReadMainLayoutSource();
var open = source.IndexOf("<AuthorizeView Policy=", StringComparison.Ordinal);
var open = source.IndexOf("<AuthorizeView Policy=\"@ZB.MOM.WW.Secrets.Ui.SecretsAuthorization.ManagePolicy\"", StringComparison.Ordinal);
var item = source.IndexOf(NavItem, StringComparison.Ordinal);
var close = source.IndexOf("</AuthorizeView>", open + 1, StringComparison.Ordinal);