about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-09-27 14:39:53 +0000
committerPjotr <wrk@bosa.lan>2026-09-27 14:39:53 +0000
commitbec3b5fd138cf3364837f490bd113d84a43d2ecb (patch)
treec7cffe0cc92fd260b74ef71a82d35ef0aeebb0b3
parent422898f093e32097150f4a412732b4b46735ee40 (diff)
downloadgn-bnw-bec3b5fd138cf3364837f490bd113d84a43d2ecb.tar.gz
test: catch the layout_svg_no data1=false failure mode and asset downloads
Strengthen the example-workflow test: layout_svg_no.php must embed
the real SVG ('var data1 = ['), never 'var data1 = false' (the
json_encode(file(...)) failure that crashes the page with
'data1.join is not a function' in the browser).  Add checks for the
rendered SVG being downloadable via /bnw-data/ and for the page
script assets (d3.v4.min.js, jquery, font-awesome, accordion,
create_table.js) downloading with real content.  22 checks pass.
-rw-r--r--test/bnw_http_tests.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/test/bnw_http_tests.py b/test/bnw_http_tests.py
index 92bb9f30..d4eca699 100644
--- a/test/bnw_http_tests.py
+++ b/test/bnw_http_tests.py
@@ -228,7 +228,38 @@ def t15_example_workflow(example, oldkey):
         return False
     key = m.group(1)
     r2 = request(f"/layout_svg_no.php?My_key={key}")
-    return r2.status == 200 and ("svg" in r2.body or "network" in r2.body)
+    # 'var data1 = false' means the SVG file was not found server-side
+    # (json_encode(file(...)) returning false), which crashes the page
+    # with 'data1.join is not a function' in the browser.
+    return (r2.status == 200
+            and "var data1 = [" in r2.body
+            and "var data1 = false" not in r2.body)
+
+
+def t16_svg_download():
+    """the rendered network SVG is downloadable via /bnw-data/"""
+    import re
+    r = request("/example.php?My_key=example2%7ChQG")
+    m = re.search(r'layout_svg_no\.php\?My_key=([A-Za-z]{3})', r.body)
+    if not m:
+        return False
+    r2 = request(f"/bnw-data/{m.group(1)}network_no_edge.svg")
+    return r2.status == 200 and "<svg" in r2.body
+
+
+def t17_script_assets():
+    """the javascript/css assets referenced by the pages download
+    with real content (d3.v4.min.js, jquery, font-awesome, ...)"""
+    ok = True
+    for asset, marker, minlen in [
+            ("scripts/d3.v4.min.js", "d3", 50000),
+            ("scripts/jquery.min.js", "jQuery", 20000),
+            ("scripts/font-awesome.css", "font-family", 5000),
+            ("scripts/accordion.js", "function", 200),
+            ("scripts/create_table.js", "function", 200)]:
+        r = request("/" + asset)
+        ok = ok and r.status == 200 and marker in r.body and len(r.body) >= minlen
+    return ok
 
 
 TESTS = [
@@ -252,6 +283,8 @@ TESTS = [
         ("t15 example workflow (example_chl)", partial(t15_example_workflow, "example_chl", "bWR")),
         ("t15 example workflow (example_time_series)", partial(t15_example_workflow, "example_time_series", "TEb")),
         ("t15 example workflow (examplecar15node)", partial(t15_example_workflow, "examplecar15node", "eIA")),
+    ("t16 network svg downloadable",              t16_svg_download),
+    ("t17 script assets download with content",   t17_script_assets),
 ]