The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): cover the connection card on the shared gateway (currently failing)
yoniebans86d54697312d
diff --git a/tests/gateway/fixtures/tui_desktop_routes_peer.py b/tests/gateway/fixtures/tui_desktop_routes_peer.pyindex 3d5e802e1cf..a86cd5ded81 100644--- a/tests/gateway/fixtures/tui_desktop_routes_peer.py+++ b/tests/gateway/fixtures/tui_desktop_routes_peer.py@@ -214,7 +214,36 @@ async def _control_refusals(authority, ws, reader, sid, marker, receipt):receipt['refused'] = True-MODES = {'react': _react, 'control': _control, 'control_refusals': _control_refusals, 'commands': _commands}+async def _connection_card(authority, ws, reader, sid, marker, receipt):+ """RT-2: the manage_connections card's calls reach the session's own open operation."""+ from pathlib import Path+ from tests.gateway.fixtures.local_recovery_probe import rpc+ from gateway.run import _profile_runtime_scope+ from tools.connectors import live+ from tools.connectors.operation import ConnectionOperation, Target++ owner = {'type': 'session', 'session_id': sid}+ with _profile_runtime_scope(Path(authority.profile_id)):+ operation = ConnectionOperation([Target('linear', 'mcp', 'install')], session_key=authority.sessions[sid].route)+ live.open(operation)+ status = await rpc(ws, 'connectors.operation.status', owner=owner, op_id=operation.op_id)+ assert status.get('result', {}).get('op_id') == operation.op_id, status+ assert (await rpc(ws, 'connectors.operation.wake', owner=owner, op_id=operation.op_id)).get('result') == {'status': 'ok'}+ answered = await rpc(ws, 'connection.respond', owner=owner, op_id=operation.op_id,+ result={'targets': [{'name': 'linear', 'status': 'skipped'}]})+ assert answered.get('result') == {'status': 'ok', 'settled': True}, answered+ assert operation.settled and operation.target('linear').state.value == 'skipped'+ retried = await rpc(ws, 'connectors.connect', owner=owner, connectors=['linear'], reconnect=True)+ assert _error(retried) == 'unknown_operation', retried+ missing = await rpc(ws, 'connection.respond', owner=owner, op_id='no-such-op', result={'targets': []})+ assert _error(missing) == 'unknown_operation', missing+ denied = await _call(reader, 'connection.respond', owner=owner, op_id='no-such-op', result={'targets': []})+ assert _error(denied) == 'permission_denied', denied+ receipt['card'] = True+++MODES = {'react': _react, 'control': _control, 'control_refusals': _control_refusals, 'commands': _commands,+ 'connection_card': _connection_card}if __name__ == '__main__':diff --git a/tests/gateway/test_canonical_tui_desktop_routes.py b/tests/gateway/test_canonical_tui_desktop_routes.pyindex bf5da933573..1fddc46effa 100644--- a/tests/gateway/test_canonical_tui_desktop_routes.py+++ b/tests/gateway/test_canonical_tui_desktop_routes.py@@ -37,6 +37,10 @@ def test_a_criterion_button_that_cannot_act_is_refused(tmp_path):assert probe(tmp_path, 'control_refusals')['refused']+def test_the_connection_card_drives_the_sessions_open_operation(tmp_path):+ assert probe(tmp_path, 'connection_card')['card']++@pytest.mark.platforms("posix")def test_exec_quick_and_plugin_commands_run_for_a_controlling_viewer(tmp_path):assert probe(tmp_path, 'commands')['commands']diff --git a/tests/gateway/test_local_desktop_ui.py b/tests/gateway/test_local_desktop_ui.pyindex 4d5aedf5e1c..ffecb7b1f62 100644--- a/tests/gateway/test_local_desktop_ui.py+++ b/tests/gateway/test_local_desktop_ui.py@@ -126,3 +126,22 @@ def test_restore_puts_the_agents_callbacks_back(window):for attr in local_desktop_ui.CALLBACK_ATTRS:assert getattr(window.agent, attr) is Noneassert local_desktop_ui._turns == {}+++def test_the_connection_card_opens_and_updates_on_the_owning_session(window, monkeypatch):+ from tools.connectors import live+ from tools.connectors.contract import Actor, TargetState+ from tools.connectors.operation import ConnectionOperation, Target++ monkeypatch.setattr(live, "_open", {})+ local_viewer_events.wire(window.turn, window.agent)+ operation = ConnectionOperation([Target("linear", "mcp", "install")], session_key="agent:main:local:dm:1")+ live.open(operation)+ assert window.agent.connection_callback(operation.request_payload()) is None+ assert window.published[-1][0] == "connection.request"+ assert window.published[-1][1]["op_id"] == operation.op_id+ operation.transition("linear", TargetState.skipped, Actor.user)+ session_id, event_type, payload = window.streamed[-1]+ assert (session_id, event_type) == ("canon", "connection.update")+ assert payload["owner"] == {"type": "session", "session_id": "canon"}+ assert payload["targets"][0]["state"] == "skipped"