using System.Diagnostics; using System.Runtime.CompilerServices; namespace ZB.MOM.WW.Theme.Tests; /// /// Theme-008: nav-state.js must not stack toggle listeners when Blazor's enhanced-navigation DOM /// sync strips its marker attribute. Runs nav-state.test.js under Node (a DOM stub, no /// jsdom); silently passes only when Node is not installed. /// 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. } Assert.NotNull(node); using (node) { var output = node.StandardOutput.ReadToEnd() + node.StandardError.ReadToEnd(); node.WaitForExit(); Assert.True(node.ExitCode == 0, output); } } }