Skip to content

The agent that grows with you

test(gateway): cover goal-card criterion buttons that cannot act (currently failing)

yoniebans202ee719e6b3
diff --git a/tests/gateway/fixtures/tui_desktop_routes_peer.py b/tests/gateway/fixtures/tui_desktop_routes_peer.py
index 3b712b1fff2..3d5e802e1cf 100644
--- a/tests/gateway/fixtures/tui_desktop_routes_peer.py
+++ b/tests/gateway/fixtures/tui_desktop_routes_peer.py
@@ -192,7 +192,29 @@ async def _commands(authority, ws, reader, sid, marker, receipt):
receipt['commands'] = True
-MODES = {'react': _react, 'control': _control, 'commands': _commands}
+async def _control_refusals(authority, ws, reader, sid, marker, receipt):
+ """RT-8: a criterion button that cannot act is a refusal the card shows, never a success envelope."""
+ from tests.gateway.fixtures.local_recovery_probe import rpc
+
+ async def control(action, **args):
+ return await rpc(ws, 'session.control', session_id=sid, action=action, args=args)
+
+ def refused(reply, reason):
+ assert 'result' not in reply, reply
+ assert _error(reply) == reason and reply['error']['data'].get('detail'), reply
+
+ refused(await control('subgoal.add', text='write the release notes'), 'goal_not_active')
+ refused(await control('subgoal.clear'), 'goal_not_active')
+ assert 'result' in await rpc(ws, 'slash.exec', session_id=sid, command='goal ship the owned fixture')
+ added = await control('subgoal.add', text='cite the changelog')
+ assert added['result']['control']['goal']['subgoals'] == ['cite the changelog'], added
+ refused(await control('subgoal.remove', index=2), 'invalid_params')
+ read = await rpc(ws, 'session.control.read', session_id=sid)
+ assert read['result']['control']['goal']['subgoals'] == ['cite the changelog'], read
+ receipt['refused'] = True
+
+
+MODES = {'react': _react, 'control': _control, 'control_refusals': _control_refusals, 'commands': _commands}
if __name__ == '__main__':
diff --git a/tests/gateway/test_canonical_tui_desktop_routes.py b/tests/gateway/test_canonical_tui_desktop_routes.py
index 092a4d2d28e..bf5da933573 100644
--- a/tests/gateway/test_canonical_tui_desktop_routes.py
+++ b/tests/gateway/test_canonical_tui_desktop_routes.py
@@ -33,6 +33,10 @@ def test_session_control_buttons_run_the_typed_command_handlers(tmp_path):
assert probe(tmp_path, 'control')['controlled']
+def test_a_criterion_button_that_cannot_act_is_refused(tmp_path):
+ assert probe(tmp_path, 'control_refusals')['refused']
+
+
@pytest.mark.platforms("posix")
def test_exec_quick_and_plugin_commands_run_for_a_controlling_viewer(tmp_path):
assert probe(tmp_path, 'commands')['commands']