Tracker and ITS-G5 as separate overlays, Overlays grouped by category: the tracker gets a name/icon/color, charging from its USB power topic, a floating info card (per-device opacity), a trail of the last 1–24 h and optional position logging that survives restarts (LiveStore); hiking trails keep their main checkbox as an all-countries toggle
CI / check (push) Successful in 20s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-19 11:57:36 +01:00
1 parent 3fc8c75c60
commit 0e5f79f8e4
9 files changed
+801 -205

No files matched your search

+15 -7
View File
@@ -137,22 +137,30 @@ class AppTest < Minitest::Test
assert_equal 401, request.get("/api/live").status
end
# The car's last position stays (with its age); ITS stations expire.
def test_live_keeps_the_vehicle_and_drops_stale_its_stations
# MQTT messages land in the tracker / ITS-G5 parts of /api/live.
def test_live_routes_topics_into_the_snapshot
app = Maptool::App
now = Time.now.to_f
app.record_live(app::TRACKER_TOPIC, '{"latitude":48.1,"longitude":17.1,"speed":3}', at: now - 600)
app.record_live(app::ITS_TOPIC, '{"id":"old","msg":"CAM","lat":48,"lon":17}', at: now - app::ITS_STALE_AFTER - 5)
app.record_live(app::TRACKER_POWER_TOPIC, "ON")
app.record_live(app::ITS_TOPIC, '{"id":"new","msg":"DENM","lat":48.2,"lon":17.2}', at: now)
app.record_live(app::ITS_TOPIC, "not json")
body = json_body(request.get("/api/live", **logged_in_env))
assert_equal 48.1, body["vehicle"]["latitude"]
assert_in_delta 600, body["vehicle"]["age"], 2
refute body["vehicle"].key?("received_at")
assert_equal 48.1, body["tracker"]["latitude"]
assert_in_delta 600, body["tracker"]["age"], 2
assert_equal true, body["tracker"]["usb_power"]
assert_equal ["new"], body["its"].map { |s| s["id"] }
assert_equal "Tracker", body["settings"]["name"]
assert_equal false, body["available"] # no MQTT_URL in tests
end
def test_live_settings_require_login_and_save
assert_equal 401, request.put("/api/live/settings", params: { name: "x" }).status
body = json_body(request.put("/api/live/settings", params: { name: "Car", trail_hours: "2" }, **logged_in_env))
assert_equal "Car", body["name"]
assert_equal 2, body["trail_hours"]
ensure
app::LIVE_MUTEX.synchronize { app::LIVE.replace(vehicle: nil, its: {}) }
Maptool::App::LIVE_STORE.update_settings("name" => "Tracker", "trail_hours" => "1")
end
# --- auth guard ---