Submit GUI commands without page navigation

This commit is contained in:
2026-08-03 02:04:17 +02:00
parent d7d472d9e1
commit 0da5377ff2
9 changed files with 346 additions and 37 deletions
+19 -1
View File
@@ -103,7 +103,8 @@ class UiRenderTest(unittest.TestCase):
html = render_page([action], "en")
self.assertIn('class="cmd cmd-on"', html)
self.assertNotIn('Already active until automatic turn-off', html)
self.assertNotIn('class="cmd cmd-on" type="submit" disabled', html)
self.assertIn('data-disabled-label="Already active until automatic turn-off"', html)
def test_camera_card_uses_friendly_display_name(self):
action = DummyAction()
@@ -121,6 +122,23 @@ class UiRenderTest(unittest.TestCase):
self.assertIn("SNAPSHOT_REFRESH_DELAY_MS = 5000", script)
self.assertIn("window.setTimeout", script)
def test_command_forms_expose_ajax_status_metadata(self):
html = render_page([DummyAction()], "en")
self.assertIn('class="command-form"', html)
self.assertIn('data-working-label="Sending command..."', html)
self.assertIn('data-success-label="Command sent."', html)
self.assertIn('data-action-status', html)
self.assertIn('data-state-chip', html)
def test_command_submit_uses_fetch_without_page_navigation(self):
script = Path("frigate_camera_control_bridge/static/app.js").read_text(encoding="utf-8")
self.assertIn("handleCommandSubmit(form, event)", script)
self.assertIn('form.classList.contains("command-form")', script)
self.assertIn('headers: { Accept: "application/json" }', script)
self.assertIn("event.preventDefault()", script)
if __name__ == "__main__":
unittest.main()