From e3717706f83d494cb2b16837b07b421f47477daf Mon Sep 17 00:00:00 2001 From: serversdown Date: Thu, 29 Oct 2026 11:46:08 -0400 Subject: [PATCH] feat(webapp): the device-routing rules as pure functions, tested through Node One block of sfm_webapp.html (/* */) holds every rule that decides where a /device/ request goes or whether a series-specific control is live: seriesFromSerial, unitQuery, deviceUrl, confirmedSeries, controlsFor, changeSummary, downloadSummary. No DOM, no fetch, so the tests run it in Node. The safety rules it pins: a control follows the unit's own /device/info answer, never a typed serial alone, and stops counting when the serial is edited; Diagnostics only for a confirmed Series 3, Hang up only for Series 4; config and call-home writes off for both series until phases 4-5. Also a test that the page's inline scripts parse together (shared global scope). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44 --- sfm/sfm_webapp.html | 102 +++++++++++++++++ tests/test_webapp_device_routing.py | 171 ++++++++++++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 tests/test_webapp_device_routing.py diff --git a/sfm/sfm_webapp.html b/sfm/sfm_webapp.html index aa5c555..6e6caad 100644 --- a/sfm/sfm_webapp.html +++ b/sfm/sfm_webapp.html @@ -1438,6 +1438,108 @@ +", PAGE.read_text(), re.S) + js = tmp_path / "page.js" + js.write_text("\n;\n".join(scripts)) + r = subprocess.run([NODE, "--check", str(js)], capture_output=True, text=True, timeout=30) + assert r.returncode == 0, r.stderr