Skip to main content
Glama
visual_integration_test.rs2.91 kB
//! Integration tests for visual terminal support. use terminal_mcp_core::Dimensions; use terminal_mcp_session::{Session, SessionMode}; #[test] fn test_create_headless_session() { // Create a headless session (default behavior) let session = Session::create( "echo".to_string(), vec!["Hello".to_string()], Dimensions::new(24, 80), ); assert!(session.is_ok(), "Failed to create headless session"); let session = session.unwrap(); assert_eq!(session.mode(), SessionMode::Headless); assert!(session.visual_handle().is_none()); } #[test] #[ignore = "Requires display and terminal emulator (run locally with --ignored)"] fn test_create_visual_session_auto() { // Try to create a visual session with auto-detect terminal let result = Session::create_with_mode( "echo".to_string(), vec!["Hello".to_string()], Dimensions::new(24, 80), SessionMode::Visual, None, // Auto-detect ); // May fail if no terminal emulator is available on the test system // We just check that it either succeeds or fails gracefully match result { Ok(session) => { assert_eq!(session.mode(), SessionMode::Visual); assert!(session.visual_handle().is_some()); let handle = session.visual_handle().unwrap(); assert!(!handle.terminal_name.is_empty()); println!("Visual session created with: {}", handle.terminal_name); } Err(e) => { // Expected to fail on headless CI environments println!("Visual session creation failed (expected on CI): {e}"); } } } #[test] #[ignore = "Requires display and terminal emulator (run locally with --ignored)"] fn test_create_visual_session_specific_terminal() { // Try to create with a specific terminal that likely doesn't exist let result = Session::create_with_mode( "echo".to_string(), vec!["Hello".to_string()], Dimensions::new(24, 80), SessionMode::Visual, Some("nonexistent-terminal".to_string()), ); // Should fail because terminal doesn't exist assert!(result.is_err(), "Should fail for nonexistent terminal"); } #[test] fn test_session_mode_backward_compatibility() { // Ensure old code using Session::create still works let session1 = Session::create("bash".to_string(), vec![], Dimensions::new(24, 80)); assert!(session1.is_ok()); // New code using create_with_mode for headless should work the same let session2 = Session::create_with_mode( "bash".to_string(), vec![], Dimensions::new(24, 80), SessionMode::Headless, None, ); assert!(session2.is_ok()); // Both should be in headless mode assert_eq!(session1.unwrap().mode(), SessionMode::Headless); assert_eq!(session2.unwrap().mode(), SessionMode::Headless); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aybelatchane/mcp-server-terminal'

If you have feedback or need assistance with the MCP directory API, please join our Discord server