From cf4e5b4327a6eab01a226d8cb28f8b70c69d64a2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 08:58:20 +0200 Subject: [PATCH] Heimdall complete page: run its real script under Node in tests A committed harness (Fixtures/complete-page-harness.cjs) executes the served page's inline script against a simulated browser; tests pin that the fragment is dropped before the post, an error status never submits, and the code is read only from the fragment. Node is required on PATH; a missing Node fails, it does not skip. Co-Authored-By: Claude Opus 5.5 --- .../Bifrost.Web.Tests.csproj | 1 + .../Fixtures/complete-page-harness.cjs | 64 +++++++++++ .../HeimdallCompletePageScriptTests.cs | 107 ++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 tests/Bifrost.Web.Tests/Fixtures/complete-page-harness.cjs create mode 100644 tests/Bifrost.Web.Tests/HeimdallCompletePageScriptTests.cs diff --git a/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj b/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj index 77670c1..1e94198 100644 --- a/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj +++ b/tests/Bifrost.Web.Tests/Bifrost.Web.Tests.csproj @@ -22,6 +22,7 @@ + diff --git a/tests/Bifrost.Web.Tests/Fixtures/complete-page-harness.cjs b/tests/Bifrost.Web.Tests/Fixtures/complete-page-harness.cjs new file mode 100644 index 0000000..aeaf092 --- /dev/null +++ b/tests/Bifrost.Web.Tests/Fixtures/complete-page-harness.cjs @@ -0,0 +1,64 @@ +// Runs the complete page's real inline script against a simulated browser, once per scenario, and prints +// what it did as JSON: the ordered events, and the address and form values at the moment of the submit. +// Usage: node complete-page-harness.cjs +const fs = require("fs"); +const vm = require("vm"); + +const html = fs.readFileSync(process.argv[2], "utf8"); +const scripts = [...html.matchAll(/