Erst schauen, dann klicken: aktiver Reiter, offene Tische, Klick nur im Fenster; Tests ohne echten Client

Live 30.10. the bot clicked the Practice tab it was already on and the
user saw clicks beside the window. Lobby: read the active tab (.active-tab,
measured) and click only if needed, then verify it switched; never Join a
table whose window is open (fill and self-heal). A real mouse click is only
sent when the point and its scattered end lie inside the target window
(KlickAusserhalb, a FensterNichtVorn), and not at all without a lobby
window. Two mcp_server_spec tests patched the wrong name and clicked the
real lobby with the real mouse whenever CoinPoker ran - they now patch
lobby_adapter and demand an opened table; tests/lauf.py blocks the real
debug port for every spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 11:01:09 +01:00
co-authored by Claude Opus 5.5
parent 26531d7299
commit bbadd2b2f3
8 changed files with 255 additions and 18 deletions
+30 -6
View File
@@ -269,17 +269,41 @@ class TestLobbyAndTableTools(unittest.TestCase):
mock_kill.assert_called_once_with(111, signal.SIGTERM)
self.assertIn("1 Tischfenster geschlossen", res)
def _lobby(self, reiter, tisch_id):
"""Eine Attrappe der Lobby an der Stelle, die tisch_oeffnen wirklich benutzt
(lobby_adapter.cdp_ausfuehren) - live 30.10.: über mcp_server.cdp_ausfuehren ersetzt,
klickte dieser Test mit der echten Maus in die echte Lobby."""
import lobby_adapter
joins = []
def cdp(args):
if args[0] == "--eval" and "active-tab" in args[1]:
return json.dumps(reiter)
if args[0] == "--eval" and "table-row" in args[1] and "querySelectorAll" in args[1]:
return json.dumps([{"id": tisch_id, "players": "5/6"}])
if args[0] == "--eval" and "data-table-id" in args[1]:
joins.append(args[1])
return "Join geklickt"
raise AssertionError(f"unerwarteter CDP-Aufruf {args[0]}")
return joins, [patch.object(lobby_adapter, "cdp_ausfuehren", side_effect=cdp),
patch.object(lobby_adapter.time, "sleep"),
patch.object(lobby_adapter.fenster, "tischfenster", return_value=[]),
patch.object(lobby_adapter.fenster, "fenster_fuer", return_value=None),
patch.object(lobby_adapter, "_geoeffnet", return_value=True)]
def test_open_practice_table_benannt(self):
tische_json = json.dumps([{"id": "Big Ben 1662221", "players": "5/6"}])
with patch.object(mcp_server, "cdp_ausfuehren", side_effect=["", tische_json, "geklickt"]):
joins, p = self._lobby("Practice Games", "Big Ben 1662221")
with p[0], p[1], p[2], p[3], p[4]:
res = mcp_server.open_practice_table(name="Big Ben 1662221")
self.assertIn("Big Ben 1662221", res)
self.assertIn("geöffnet: Big Ben 1662221", res)
self.assertEqual(len(joins), 1)
def test_open_cash_table_benannt(self):
tische_json = json.dumps([{"id": "31st NL 0.05-0.10 (D) 1662347", "players": "5/6"}])
with patch.object(mcp_server, "cdp_ausfuehren", side_effect=["", tische_json, "geklickt"]):
joins, p = self._lobby("Cash Games", "31st NL 0.05-0.10 (D) 1662347")
with p[0], p[1], p[2], p[3], p[4]:
res = mcp_server.open_cash_table(name="1662347")
self.assertIn("1662347", res)
self.assertIn("geöffnet: 31st NL 0.05-0.10 (D) 1662347", res)
self.assertEqual(len(joins), 1)
def test_korpus_werkzeug(self):
with patch.object(mcp_server.korpus_modul, "sichere", return_value=(1024, "/pfad/main.log")):