Files
scadaproj/ZB.MOM.WW.Theme/tests/ZB.MOM.WW.Theme.Tests/NavStateScriptTests.cs
T

43 lines
1.4 KiB
C#

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);
}
}
}