use super::logging_responder::LoggingResponder;
use crate::commands::{CommandResponse, Responder};
use swiftide::chat_completion::ChatMessage;
#[tokio::test]
async fn test_logging_responder_formatting() {
let responder = LoggingResponder::new();
let chat_message = ChatMessage::Assistant(
Some(
r#"Here's a message with "quotes" and \n newlines and a JSON: {"key": "value"}"#
.to_string(),
),
None,
);
responder.agent_message(chat_message).await;
let command_response =
CommandResponse::BackendMessage(r#"Message with "quotes" and \n newlines"#.to_string());
responder.send(command_response).await;
responder
.system_message(r#"System message with "quotes" and \n newlines"#)
.await;
responder
.update(r#"Update with "quotes" and \n newlines"#)
.await;
let log = responder.get_log();
println!("Log output:\n{log}");
assert!(log.contains(r#"Assistant(Some("Here's a message with "quotes" and "#));
assert!(log.contains(r#"newlines and a JSON: {"key": "value"}")"#));
assert!(log.contains(r"BackendMessage("));
assert!(log.contains(r#"Message with "quotes" and "#));
assert!(log.contains("newlines"));
assert!(log.contains(r#"System message with "quotes" and "#));
assert!(log.contains("newlines"));
}