Submit GUI commands with fetch fallback
This commit is contained in:
+23
-1
@@ -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,27 @@ 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" method="post"', html)
|
||||
self.assertIn('type="submit"', html)
|
||||
self.assertIn('data-working-label="Sending command..."', html)
|
||||
self.assertIn('data-success-label="Command sent."', html)
|
||||
self.assertIn('data-network-failed-label="Could not reach the bridge.', html)
|
||||
self.assertIn('data-action-status', html)
|
||||
self.assertIn('data-state-chip', html)
|
||||
self.assertIn('data-timer', 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)
|
||||
self.assertIn("commandErrorMessage", script)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user