use crate::brain::agent::QueuedUserMessage;
#[test]
fn an_empty_queue_injects_nothing() {
assert!(QueuedUserMessage::join(&[]).is_none());
}
#[test]
fn a_system_entry_keeps_its_compact_display() {
let queued = vec![QueuedUserMessage::system(
"[System: the background task you started has finished. Command: cargo test …]".to_string(),
"🔧 background task finished: cargo test".to_string(),
)];
let joined = QueuedUserMessage::join(&queued).expect("one entry joins");
assert_eq!(
joined.display_text, "🔧 background task finished: cargo test",
"the transcript must never receive the scaffolding"
);
assert!(
joined.context_text.contains("Command: cargo test"),
"the model still needs the full result"
);
}
#[test]
fn a_typed_message_reads_the_same_on_both_sides() {
let queued = vec![QueuedUserMessage::plain("do the thing".to_string())];
let joined = QueuedUserMessage::join(&queued).expect("one entry joins");
assert_eq!(joined.context_text, "do the thing");
assert_eq!(joined.display_text, "do the thing");
}
#[test]
fn mixed_entries_join_each_half_independently() {
let queued = vec![
QueuedUserMessage::plain("also check the logs".to_string()),
QueuedUserMessage::system(
"[System: task finished. Output: …50 lines…]".to_string(),
"🔧 background task finished: cargo clippy".to_string(),
),
];
let joined = QueuedUserMessage::join(&queued).expect("joins");
assert_eq!(
joined.display_text,
"also check the logs\n🔧 background task finished: cargo clippy"
);
assert_eq!(
joined.context_text,
"also check the logs\n[System: task finished. Output: …50 lines…]"
);
}
#[test]
fn ordering_is_preserved_on_both_halves() {
let queued = vec![
QueuedUserMessage::plain("first".to_string()),
QueuedUserMessage::plain("second".to_string()),
QueuedUserMessage::plain("third".to_string()),
];
let joined = QueuedUserMessage::join(&queued).expect("joins");
assert_eq!(joined.display_text, "first\nsecond\nthird");
assert_eq!(joined.context_text, "first\nsecond\nthird");
}