"""Runs the plain-node image viewer (TmfViewerMath) test (tests/js/test_image_viewer.js). Same thin pytest wrapper pattern as test_vision_overlay_js.py: shells out to ``node`` and asserts the script's own exit code. Skips (does not fail) when node is not installed. Covers gitea:Adriano/TieMeasureFlow#122. """ 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_image_viewer.js" def test_image_viewer_js_behaviour(): node = shutil.which("node") if not node: pytest.skip("node non installato: test JS del visualizzatore immagine 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_image_viewer.js fallito (exit {result.returncode})\n" f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" )