@@ -220,12 +220,51 @@ def mock_query_one(selector, *args):
220220 tui_instance .worker = MagicMock ()
221221 tui_instance .worker .coder = mock_coder
222222
223+
223224 # Mock AgentService - unknown UUID should return None (no prefix)
224225 monkeypatch .setattr (
225226 "cecli.helpers.agents.service.AgentService.get_instance" ,
226227 lambda * args : MagicMock (sub_agents = {}, coder = mock_coder ),
227228 )
228229
230+
231+ # Test: error message for unknown agent should have agent_name=None
232+ msg = {
233+ "type" : "error" ,
234+ "message" : "Something went wrong!" ,
235+ "coder_uuid" : "unknown_uuid" ,
236+ }
237+ tui_instance .handle_output_message (msg )
238+ mock_status_bar .show_notification .assert_called_once_with (
239+ "Something went wrong!" ,
240+ severity = "error" ,
241+ timeout = 5 ,
242+ agent_name = None ,
243+ )
244+
245+
246+ def test_show_error_uses_query_one (tui_instance ):
247+ """
248+ Test that show_error uses query_one to get the status bar and show a notification.
249+ """
250+ mock_status_bar = MagicMock ()
251+ tui_instance .query_one = MagicMock (return_value = mock_status_bar )
252+
253+ # Import StatusBar for the assertion
254+ from cecli .tui .widgets import StatusBar
255+
256+ tui_instance .show_error ("A test error" , agent_name = "test_agent" )
257+
258+ # Assert query_one was called correctly
259+ tui_instance .query_one .assert_called_once_with ("#status-bar" , StatusBar )
260+
261+ # Assert show_notification was called on the result of query_one
262+ mock_status_bar .show_notification .assert_called_once_with (
263+ "A test error" ,
264+ severity = "error" ,
265+ timeout = 5 ,
266+ agent_name = "test_agent" ,
267+ )
229268 # Test: error message for unknown agent should have agent_name=None
230269 msg = {
231270 "type" : "error" ,
0 commit comments