use fido::debug_log;
use std::fs;
use std::path::Path;
#[test]
fn test_logging_integration() {
debug_log::clear_debug_log();
assert!(
Path::new(debug_log::DEBUG_LOG_FILE).exists(),
"Log file should exist"
);
let metadata = fs::metadata(debug_log::DEBUG_LOG_FILE).expect("Should read metadata");
assert_eq!(metadata.len(), 0, "Log file should be empty after clear");
debug_log::log_modal_state(false, false, false, "None");
debug_log::log_key_event("Char('r')", "main_view");
debug_log::log_debug("render_posts_tab_with_data: START");
debug_log::log_debug("Rendering thread modal (full post modal)");
let contents =
fs::read_to_string(debug_log::DEBUG_LOG_FILE).expect("Should be able to read log file");
assert!(
contents.contains("MODAL_STATE"),
"Should contain modal state log"
);
assert!(
contents.contains("KEY_EVENT"),
"Should contain key event log"
);
assert!(
contents.contains("render_posts_tab_with_data: START"),
"Should contain render start log"
);
assert!(
contents.contains("Rendering thread modal"),
"Should contain thread modal log"
);
assert!(contents.contains("[20"), "Should contain timestamp");
let line_count = contents.lines().count();
assert_eq!(line_count, 4, "Should have 4 log lines");
let _ = fs::remove_file(debug_log::DEBUG_LOG_FILE);
}