Test del helper di salvataggio immagine e fix pulizia backslash nel nome

Refs #119

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 21:18:20 +01:00
parent df67a32a82
commit 25b0741003
3 changed files with 199 additions and 1 deletions
@@ -0,0 +1,35 @@
"""Runs the plain-node save-image helper test (tests/js/test_save_image.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#119.
"""
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_save_image.js"
def test_save_image_js_behaviour():
node = shutil.which("node")
if not node:
pytest.skip("node non installato: test JS del salvataggio 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_save_image.js fallito (exit {result.returncode})\n"
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
)