@@ -391,3 +391,84 @@ def test_channel_message_handler_session_check_error(mock_env):
391391 mock_table .get_item .side_effect = Exception ("DB error" )
392392 # Should return early due to error
393393 channel_message_handler (mock_event , "evt123" , mock_body , mock_client )
394+
395+
396+ def test_feedback_handler_unknown_action (mock_env ):
397+ """Test feedback_handler with unknown action"""
398+ from app .slack .slack_handlers import feedback_handler
399+
400+ mock_ack = Mock ()
401+ mock_body = {"actions" : [{"action_id" : "unknown_action" , "value" : "{}" }]}
402+ mock_client = Mock ()
403+
404+ feedback_handler (mock_ack , mock_body , mock_client )
405+ mock_ack .assert_called_once ()
406+
407+
408+ def test_feedback_handler_not_latest_message (mock_env ):
409+ """Test feedback_handler when not latest message"""
410+ from app .slack .slack_handlers import feedback_handler
411+
412+ mock_ack = Mock ()
413+ mock_body = {"actions" : [{"action_id" : "feedback_yes" , "value" : '{"ck": "conv-key", "mt": "123"}' }]}
414+ mock_client = Mock ()
415+
416+ with patch ("app.slack.slack_handlers._is_latest_message" , return_value = False ):
417+ feedback_handler (mock_ack , mock_body , mock_client )
418+ mock_ack .assert_called_once ()
419+
420+
421+ def test_channel_message_handler_no_session (mock_env ):
422+ """Test channel_message_handler when no session found"""
423+ from app .slack .slack_handlers import channel_message_handler
424+
425+ mock_client = Mock ()
426+ mock_event = {"text" : "follow up" , "channel" : "C789" , "thread_ts" : "123" , "user" : "U456" }
427+ mock_body = {"event_id" : "evt123" }
428+
429+ with patch ("app.core.config.table" ) as mock_table :
430+ mock_table .get_item .return_value = {} # No session
431+ channel_message_handler (mock_event , "evt123" , mock_body , mock_client )
432+
433+
434+ def test_channel_message_handler_feedback_path (mock_env ):
435+ """Test channel_message_handler feedback path"""
436+ from app .slack .slack_handlers import channel_message_handler
437+
438+ mock_client = Mock ()
439+ mock_event = {"text" : "feedback: channel feedback" , "channel" : "C789" , "thread_ts" : "123" , "user" : "U456" }
440+ mock_body = {"event_id" : "evt123" }
441+
442+ with patch ("app.core.config.table" ) as mock_table :
443+ mock_table .get_item .return_value = {"Item" : {"session_id" : "session123" }}
444+ # Just test that the function runs without error
445+ channel_message_handler (mock_event , "evt123" , mock_body , mock_client )
446+
447+
448+ def test_dm_message_handler_normal_message (mock_env ):
449+ """Test dm_message_handler with normal message"""
450+ from app .slack .slack_handlers import dm_message_handler
451+
452+ mock_client = Mock ()
453+ mock_event = {"text" : "normal message" , "user" : "U456" , "channel" : "D789" , "ts" : "123" , "channel_type" : "im" }
454+ mock_body = {"event_id" : "evt123" }
455+
456+ with patch ("app.slack.slack_handlers._trigger_async_processing" ) as mock_trigger :
457+ dm_message_handler (mock_event , "evt123" , mock_body , mock_client )
458+ mock_trigger .assert_called_once ()
459+
460+
461+ def test_app_mention_handler_normal_mention (mock_env ):
462+ """Test app_mention_handler with normal mention"""
463+ from app .slack .slack_handlers import app_mention_handler
464+
465+ mock_ack = Mock ()
466+ mock_client = Mock ()
467+ mock_event = {"text" : "<@U123> normal question" , "user" : "U456" , "channel" : "C789" , "ts" : "123" }
468+ mock_body = {"event_id" : "evt123" }
469+
470+ with patch ("app.slack.slack_handlers._is_duplicate_event" , return_value = False ), patch (
471+ "app.slack.slack_handlers._trigger_async_processing"
472+ ) as mock_trigger :
473+ app_mention_handler (mock_event , mock_ack , mock_body , mock_client )
474+ mock_trigger .assert_called_once ()
0 commit comments