use super::*;
#[test]
fn projects_empty_state() {
let state = MissionControlState::default();
let cards = project_cards(&state);
assert_eq!(cards.len(), 1);
assert_eq!(cards[0].role, TranscriptCardRole::Empty);
assert!(cards[0].body.contains("Transcript will appear here"));
}
#[test]
fn maps_local_diagnostics_sessions_canceled_and_legacy_safely() {
let mut state = MissionControlState::default();
state.apply_output_event(&OutputEvent::Diagnostic {
level: "info".into(),
message: "note".into(),
});
state.apply_output_event(&OutputEvent::Diagnostic {
level: "warning".into(),
message: "careful".into(),
});
state.apply_output_event(&OutputEvent::Diagnostic {
level: "error".into(),
message: "bad".into(),
});
state.record_canceled_transcript("prompt text");
state.transcript.push_back("session • restored".to_string());
state
.transcript
.push_back("weird legacy prefix".to_string());
state.invalidate_transcript_cache();
let cards = project_cards(&state);
assert_eq!(
cards.iter().map(|card| card.role).collect::<Vec<_>>(),
vec![
TranscriptCardRole::Diagnostic,
TranscriptCardRole::Diagnostic,
TranscriptCardRole::Error,
TranscriptCardRole::Diagnostic,
TranscriptCardRole::Session,
TranscriptCardRole::Diagnostic,
]
);
assert_eq!(cards[3].title, "Canceled");
assert_eq!(cards[3].body, "prompt text");
assert_eq!(cards[5].title, "Legacy diagnostic");
}
#[test]
fn maps_hook_diagnostic_without_raw_prefix_in_body() {
let mut state = MissionControlState::default();
state.transcript.push_back("hook: tool warning".to_string());
let cards = project_cards(&state);
assert_eq!(cards[0].role, TranscriptCardRole::Diagnostic);
assert_eq!(cards[0].title, "Hook diagnostic");
assert_eq!(cards[0].body, "tool warning");
assert!(!cards[0].body.contains("hook:"));
}