80 lines
3.1 KiB
Python
80 lines
3.1 KiB
Python
"""Executable and static gates for the vanilla HUX Wave A runtime bridge."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
RUNTIME = ROOT / "dockerfiles" / "hermes-webui-hux" / "runtime"
|
|
|
|
|
|
def test_hux_wave_a_vanilla_runtime_and_coverage():
|
|
result = subprocess.run(
|
|
[
|
|
"node",
|
|
"--test",
|
|
"--experimental-test-coverage",
|
|
"--test-coverage-lines=95",
|
|
"--test-coverage-functions=95",
|
|
"--test-coverage-branches=95",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/runtime/wave_a_contract.js",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/runtime/wave_a_activity_memory.js",
|
|
"testing/tests/test_hermes_hux_ui_runtime_wave_a.js",
|
|
],
|
|
cwd=ROOT,
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
|
|
|
|
def test_wave_a_runtime_is_dependency_free_scoped_and_not_live_wired():
|
|
contract = (RUNTIME / "wave_a_contract.js").read_text(encoding="utf-8")
|
|
renderer = (RUNTIME / "wave_a_activity_memory.js").read_text(encoding="utf-8")
|
|
styles = (RUNTIME / "wave_a_activity_memory.css").read_text(encoding="utf-8")
|
|
combined = contract + renderer
|
|
assert "require('../foundation.js')" in contract
|
|
assert "require('../shell.js')" in renderer
|
|
assert "/conversations/${conversationId}/events?after_seq=0&limit=200" in renderer
|
|
assert "context.client.request('/memory')" in renderer
|
|
assert "'If-Match': String(item.revision)" in renderer
|
|
assert "'Idempotency-Key': idempotencyKey" in renderer
|
|
assert "credentials: 'same-origin'" in contract and "cache: 'no-store'" in contract
|
|
assert "item.detail" not in renderer
|
|
assert "raw.detail" not in renderer
|
|
assert "dangerouslySetInnerHTML" not in combined and "innerHTML" not in combined
|
|
for forbidden in (
|
|
"React",
|
|
"lucide",
|
|
"tailwind",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"document.cookie",
|
|
):
|
|
assert forbidden not in combined
|
|
assert ".hux-wave-a" in styles
|
|
assert "body" not in styles and ":root" not in styles
|
|
assert "prefers-reduced-motion" in styles
|
|
dockerfile = (ROOT / "dockerfiles/Dockerfile.hermes-webui").read_text(encoding="utf-8")
|
|
assert "COPY dockerfiles/hermes-webui-hux/runtime/wave_a_contract.js" in dockerfile
|
|
assert "COPY dockerfiles/hermes-webui-hux/runtime/wave_a_activity_memory.js" in dockerfile
|
|
bootstrap = (ROOT / "dockerfiles/hermes-webui-hux/bootstrap.js").read_text(encoding="utf-8")
|
|
assert "root.HermesHuxWaveA.createWaveARuntime" in bootstrap
|
|
assert "normalizeContext(sessionReader())" in bootstrap
|
|
|
|
|
|
def test_wave_a_runtime_files_remain_bounded_and_isolated():
|
|
sources = {
|
|
RUNTIME / "wave_a_activity_memory.css",
|
|
RUNTIME / "wave_a_activity_memory.js",
|
|
RUNTIME / "wave_a_contract.js",
|
|
}
|
|
assert all(path.is_file() for path in sources)
|
|
for path in sources:
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|