fix(theme): nav-state.js tracks wired sections in a WeakSet so enhanced navigation cannot stack toggle listeners; bump 0.5.2 (scadaproj#48)
Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ZB.MOM.WW.Theme.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Theme-008: nav-state.js must not stack toggle listeners when Blazor's enhanced-navigation DOM
|
||||
/// sync strips its marker attribute. Runs <c>nav-state.test.js</c> under Node (a DOM stub, no
|
||||
/// jsdom); silently passes only when Node is not installed.
|
||||
/// </summary>
|
||||
public class NavStateScriptTests
|
||||
{
|
||||
private static string Here([CallerFilePath] string path = "") => Path.GetDirectoryName(path)!;
|
||||
|
||||
[Fact]
|
||||
public void NavState_does_not_stack_listeners_or_persist_the_transient_reveal()
|
||||
{
|
||||
var script = Path.GetFullPath(Path.Combine(Here(), "..", "..", "src", "ZB.MOM.WW.Theme", "wwwroot", "js", "nav-state.js"));
|
||||
var test = Path.Combine(Here(), "nav-state.test.js");
|
||||
|
||||
Process? node;
|
||||
try
|
||||
{
|
||||
node = Process.Start(new ProcessStartInfo("node", $"\"{test}\" \"{script}\"")
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
});
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
return; // Node not available on this machine.
|
||||
}
|
||||
|
||||
using (node!)
|
||||
{
|
||||
var output = node.StandardOutput.ReadToEnd() + node.StandardError.ReadToEnd();
|
||||
node.WaitForExit();
|
||||
Assert.True(node.ExitCode == 0, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user