d40c74870e
toggleSign() usciva subito a display vuoto: il segno del calibro, che arriva prima delle cifre, veniva scartato. Ora '-'/'+' impostano il segno in modo esplicito (non toggle) quando arrivano da tastiera/HID; toggleSign() (bottone manuale +/-) funziona anche a vuoto. _trackBurst riconosce l'inizio di una raffica solo dal secondo carattere: prima ripuliva il display in ritardo, concatenando cifre digitate a mano. Ora la raffica ripulisce il display fino al proprio inizio quando la pausa prima di essa è > 300ms. Parte intera oltre 6 cifre: rifiutata con evento numpad-error invece di essere troncata in silenzio. Test node in tests/js/test_numpad.js, lanciato da pytest (tests/test_numpad_js.py, skip se node manca). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""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}"
|
|
)
|