[verified] feat: add live river dashboard

Add mapped river and ThaiWater sensor layers, PostgreSQL history charts, API endpoints, and dashboard tests.
This commit is contained in:
2026-08-09 16:59:25 +07:00
parent e5936d5717
commit ae5d0a13d7
11 changed files with 800 additions and 42 deletions
+46
View File
@@ -0,0 +1,46 @@
from pathlib import Path
DASHBOARD_PATH = Path(__file__).parents[1] / "src" / "static" / "dashboard.html"
def test_dashboard_contains_live_map_and_flow_visualization():
html = DASHBOARD_PATH.read_text(encoding="utf-8")
assert "id=\"station-map\"" in html
assert "id=\"river-flow\"" in html
assert "fetch('/stations')" in html or 'fetch("/stations")' in html
assert "fetch('/measurements/latest" in html or 'fetch(\"/measurements/latest' in html
assert "leaflet" in html.lower()
def test_dashboard_explains_flow_legend_and_refresh():
html = DASHBOARD_PATH.read_text(encoding="utf-8")
assert "Flow status" in html
assert "Last updated" in html
assert "Refresh" in html
def test_dashboard_uses_mapped_river_network_instead_of_station_connections():
html = DASHBOARD_PATH.read_text(encoding="utf-8")
river_network = DASHBOARD_PATH.with_name("ping-river-network.geojson")
assert river_network.exists()
assert "fetch('/static/ping-river-network.geojson')" in html
assert "mainBasin.map" not in html
def test_dashboard_loads_additional_thaiwater_sensors():
html = DASHBOARD_PATH.read_text(encoding="utf-8")
assert "fetch('/sensors/thaiwater')" in html
assert "Additional ThaiWater sensor" in html
def test_dashboard_loads_postgresql_history_chart():
html = DASHBOARD_PATH.read_text(encoding="utf-8")
assert "PostgreSQL history" in html
assert "/measurements/history/" in html
assert "history-chart" in html