Keypad bindings in the UI (/keypad.html, after the Design canvas' GridBinding): the keypads drawn as can.json has them, a key or knob picked by a tap or by pressing it, what it drives (a screen action or an output), the output's mode, what it does in an open menu, its LEDs; saved per car in data/drive/bindings.json over the profile's (GET/PUT/DELETE /api/keypad/bindings, checked on the way in), drive mode takes them when it loads
This commit is contained in:
1 parent
d6af65f4ef
commit
e82b2236b5
7 files changed
+325
-8
No files matched your search
@@ -194,6 +194,24 @@ class AppTest < Minitest::Test
|
||||
assert_equal({ "interfaces" => {}, "nodes" => {}, "signals" => {}, "frames" => [], "available" => false, "simulated" => false, "actions" => [], "time" => nil }, json_body(request.get("/api/can", **logged_in_env)))
|
||||
end
|
||||
|
||||
# The keypads' bindings: the profile's until this car saves its own, checked on the way in.
|
||||
def test_keypad_bindings_saved_over_the_profile
|
||||
assert_equal 401, request.get("/api/keypad/bindings").status
|
||||
body = json_body(request.get("/api/keypad/bindings", **logged_in_env))
|
||||
refute body["saved"]
|
||||
assert body["bindings"].any? { |b| b["input"] == "pad.K1" }
|
||||
own = [{ "input" => "pad.K1", "output" => "relays.2", "mode" => "pulse", "pulse_s" => "2", "led" => "red", "junk" => 1 }]
|
||||
body = json_body(request.put("/api/keypad/bindings", input: JSON.generate(bindings: own), **logged_in_env))
|
||||
assert_equal [{ "input" => "pad.K1", "output" => "relays.2", "mode" => "pulse", "pulse_s" => 2.0, "led" => "red" }], body["bindings"]
|
||||
assert_equal body["bindings"], Maptool::App.bindings
|
||||
assert_equal 400, request.put("/api/keypad/bindings", input: JSON.generate(bindings: [{ "input" => "pad.K1", "mode" => "blink" }]), **logged_in_env).status
|
||||
assert_equal 400, request.put("/api/keypad/bindings", input: JSON.generate(bindings: [{ "input" => "pad.K1", "led" => "pink" }]), **logged_in_env).status
|
||||
refute json_body(request.delete("/api/keypad/bindings", **logged_in_env))["saved"]
|
||||
assert Maptool::App.bindings.size > 1
|
||||
ensure
|
||||
FileUtils.rm_f(Maptool::App::BINDINGS_PATH)
|
||||
end
|
||||
|
||||
# MQTT messages land in the tracker / ITS-G5 parts of /api/live.
|
||||
def test_live_routes_topics_into_the_snapshot
|
||||
app = Maptool::App
|
||||
|
||||
Reference in new issue
Block a user