use super::*;
#[test]
fn extract_router_text_supports_message_with_content_array() {
let raw = r#"{"type":"step_start","timestamp":1}
{"type":"message","timestamp":2,"part":{"type":"message","content":[{"type":"text","text":"```json\n{\"executor\":\"opencode\",\"complexity\":\"medium\",\"reason\":\"ok\"}\n```"}]}}
{"type":"step_finish","timestamp":3,"part":{"type":"step-finish","reason":"stop"}}"#;
let text = extract_router_text(raw).expect("should extract text");
assert!(
text.contains("executor"),
"extracted text should include JSON"
);
}
#[test]
fn extract_router_text_ignores_leading_system_init() {
let raw = r#"{"type":"system","subtype":"init","cwd":"/"}
{"type":"text","timestamp":2,"text":"{\"executor\":\"opencode\",\"complexity\":\"medium\",\"reason\":\"ndjson\"}"}
{"type":"step_finish","timestamp":3}"#;
let text = extract_router_text(raw).expect("should extract text even with leading init");
let parsed: serde_json::Value =
serde_json::from_str(&text).expect("extracted text must be JSON");
assert_eq!(parsed["executor"], "opencode");
assert_eq!(parsed["complexity"], "medium");
}