Explain a greyed "Keyboard" button: show the reason on tap and log it

On a fresh install features.text_input is false, so the Keyboard button of the
Remote tab was greyed out, with the reason only in a title tooltip that cannot
be read on a tablet.

- The button now uses aria-disabled instead of disabled (same look); tapping
  it shows the reason in a toast instead of doing nothing.
- The server logs "text entry enabled" or "text entry unavailable: <reason>"
  at startup.
- README (fr/en): text entry is listed as optional and off by default in the
  installation steps, and the possible reasons are documented.

tests/test_ui_text_button.py (real Chromium) and a startup-log test in
tests/test_text.py cover it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis
2026-10-26 19:05:39 +01:00
parent 2892e39c71
commit 2fdb8f4ea0
9 changed files with 104 additions and 14 deletions
+14
View File
@@ -252,6 +252,20 @@ class TextTyperTest(unittest.IsolatedAsyncioTestCase):
self.assertEqual(keyboard.down, set())
class TextTyperStartupLogTest(unittest.TestCase):
"""L'état de la saisie est journalisé au démarrage : sans cela, un bouton grisé n'a aucune trace côté PC."""
def test_disabled_in_config_is_logged_with_the_setting_name(self) -> None:
with self.assertLogs("mediadeck.text", level="INFO") as logs:
typer(enabled=False)
self.assertIn("features.text_input", "\n".join(logs.output))
def test_enabled_is_logged(self) -> None:
with self.assertLogs("mediadeck.text", level="INFO") as logs:
typer(enabled=True)
self.assertIn("text entry enabled", "\n".join(logs.output))
class VirtualInputKeysTest(unittest.TestCase):
class Device:
def __init__(self) -> None:
+42
View File
@@ -0,0 +1,42 @@
"""Bouton « Clavier » grisé : toucher le bouton doit dire pourquoi (une infobulle est invisible sur une tablette).
Régression visée : sur une installation neuve `features.text_input` est faux, le bouton était seulement grisé et
la raison n'apparaissait que dans son attribut title. Ignoré sans Chromium.
"""
import json
import unittest
from aiohttp.test_utils import TestServer
from uidriver import CHROMIUM, Browser, make_app
STATE = """(() => {
const b = document.getElementById('text-open');
return JSON.stringify({ariaDisabled: b.getAttribute('aria-disabled'), disabled: b.disabled,
opacity: getComputedStyle(b).opacity, dialogOpen: document.getElementById('text-dialog').open});
})()"""
@unittest.skipUnless(CHROMIUM, "Chromium is required")
class TextButtonTest(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self) -> None:
self.server = TestServer(make_app())
await self.server.start_server()
self.browser = Browser()
await self.browser.start()
await self.browser.open(f"http://127.0.0.1:{self.server.port}/?token=player", 1280, 800)
await self.browser.wait_for("document.getElementById('track-title').textContent !== ''")
await self.browser.evaluate("document.querySelector('[data-tab=remote]').click()")
async def asyncTearDown(self) -> None:
await self.browser.close()
await self.server.close()
async def test_tapping_the_greyed_button_shows_the_reason_and_opens_nothing(self) -> None:
state = json.loads(await self.browser.evaluate(STATE))
self.assertEqual(state["ariaDisabled"], "true")
self.assertLess(float(state["opacity"]), 0.5) # toujours grisé
await self.browser.evaluate("document.getElementById('text-open').click()")
await self.browser.wait_for("document.querySelector('.toast') && document.querySelector('.toast').textContent.includes('features.text_input')")
self.assertFalse(json.loads(await self.browser.evaluate(STATE))["dialogOpen"])
+2 -1
View File
@@ -35,7 +35,8 @@ def state(scenario: str) -> dict[str, Any]:
"type": "state", "version": "test",
"mpris": {"players": players, "active": PLAYER["name"] if players else None, "available": True},
"audio": {"available": True, "default": "hdmi", "max_volume": 1.0, "sinks": SINKS},
"input": {"available": True, "reason": None, "keys": [], "text": {"available": False, "reason": None}},
"input": {"available": True, "reason": None, "keys": [],
"text": {"available": False, "reason": "disabled in config (features.text_input)"}},
"system": {"power": True, "admin": True, "launchers": [], "media": media},
}