"""Runs the plain-node numpad.js behaviour test (tests/js/test_numpad.js). There is no browser/JS test harness in this project yet, so this is a thin pytest wrapper: it shells out to ``node`` and asserts the script's own exit code. Skips (does not fail) when node is not installed, since numpad.js's logic still gets exercised by whatever picks this up where node is present. Covers gitea:Adriano/TieMeasureFlow#11 and #27. """ import shutil import subprocess from pathlib import Path import pytest FLASK_APP_DIR = Path(__file__).resolve().parent.parent JS_TEST = Path(__file__).resolve().parent / "js" / "test_numpad.js" def test_numpad_js_hid_sign_and_burst_behaviour(): node = shutil.which("node") if not node: pytest.skip("node non installato: test JS di numpad.js saltato") result = subprocess.run( [node, str(JS_TEST)], cwd=str(FLASK_APP_DIR), capture_output=True, text=True, timeout=30, ) assert result.returncode == 0, ( f"tests/js/test_numpad.js fallito (exit {result.returncode})\n" f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" )