#[test]
fn test_verbosity_affects_output() {
let quiet_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Quiet);
let full_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Full);
let long_text = "a".repeat(200);
let json = format!(
r#"{{"type":"assistant","message":{{"content":[{{"type":"text","text":"{long_text}"}}]}}}}"#
);
let quiet_output = quiet_parser.parse_event(&json).unwrap();
let full_output = full_parser.parse_event(&json).unwrap();
assert!(quiet_output.len() < full_output.len());
}
#[test]
fn test_tool_use_shows_input_in_verbose_mode() {
let verbose_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Verbose)
.with_terminal_mode(TerminalMode::Full);
let json = r#"{"type":"assistant","message":{"content":[{"type":"tool_use","name":"Read","input":{"file_path":"/test.rs"}}]}}"#;
let output = verbose_parser.parse_event(json).unwrap();
assert!(output.contains("Tool"));
assert!(output.contains("Read"));
assert!(output.contains("file_path=/test.rs"));
}
#[test]
fn test_tool_use_shows_input_in_normal_mode() {
let normal_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Normal)
.with_terminal_mode(TerminalMode::Full);
let json = r#"{"type":"assistant","message":{"content":[{"type":"tool_use","name":"Read","input":{"file_path":"/test.rs"}}]}}"#;
let output = normal_parser.parse_event(json).unwrap();
assert!(output.contains("Tool"));
assert!(output.contains("Read"));
assert!(output.contains("file_path=/test.rs"));
}
#[test]
fn test_tool_use_hides_input_in_quiet_mode() {
let quiet_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Quiet);
let json = r#"{"type":"assistant","message":{"content":[{"type":"tool_use","name":"Read","input":{"file_path":"/test.rs"}}]}}"#;
let output = quiet_parser.parse_event(json).unwrap();
assert!(output.contains("Tool"));
assert!(output.contains("Read"));
assert!(!output.contains("file_path=/test.rs"));
}
#[test]
fn test_parser_uses_custom_display_name_prefix() {
let parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Normal)
.with_terminal_mode(TerminalMode::Full)
.with_display_name("ccs-glm");
let json = r#"{"type":"system","subtype":"init","session_id":"abc123"}"#;
let output = parser.parse_event(json).unwrap();
assert!(output.contains("[ccs-glm]"));
}
#[test]
fn test_debug_verbosity_is_recognized() {
let debug_parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Debug)
.with_terminal_mode(TerminalMode::Full);
assert!(debug_parser.verbosity.is_debug());
}
#[test]
fn test_claude_tool_result_single_truncation_summary() {
let lines: Vec<String> = (1..=60).map(|i| format!("/path/file{i}.rs")).collect();
let result_content = lines.join("\n");
let result_json = serde_json::to_string(&result_content).unwrap();
let json = format!(
r#"{{"type":"assistant","message":{{"content":[{{"type":"tool_result","content":{result_json}}}]}}}}"#
);
let parser = ClaudeParser::new(Colors { enabled: false }, Verbosity::Normal);
if let Some(out) = parser.parse_event(&json) {
let more_count = out.matches("more lines").count();
assert!(
more_count <= 1,
"expected at most one 'more lines' summary, got {more_count}\noutput:\n{out}"
);
}
}
#[test]
fn test_opencode_tool_output_single_truncation_summary() {
let lines: Vec<String> = (1..=60).map(|i| format!("/path/file{i}.rs")).collect();
let output_content = lines.join("\n");
let output_json = serde_json::to_string(&output_content).unwrap();
let json = format!(
r#"{{"type":"tool_use","timestamp":1,"sessionID":"ses","part":{{"type":"tool","tool":"grep","state":{{"status":"completed","input":{{"pattern":"TODO"}},"output":{output_json}}}}}}}"#
);
let parser = OpenCodeParser::new(Colors { enabled: false }, Verbosity::Normal);
if let Some(out) = parser.parse_event(&json) {
let more_count = out.matches("more lines").count();
assert!(
more_count <= 1,
"OpenCode: expected at most one 'more lines' summary, got {more_count}\noutput:\n{out}"
);
}
}
#[test]
fn test_codex_turn_completed_uses_shared_token_format() {
let parser = CodexParser::new(Colors { enabled: false }, Verbosity::Normal);
let json =
r#"{"type":"response.completed","response":{"usage":{"input_tokens":100,"output_tokens":50}}}"#;
if let Some(out) = parser.parse_event(json) {
assert!(
out.contains("in:100"),
"turn_completed should use shared token format with in: label, got: {out}"
);
assert!(
!out.contains("(in:"),
"turn_completed must not use old parenthetical format, got: {out}"
);
}
}