use intent_engine::dashboard::cli_notifier::{CliNotifier, NotificationMessage};
#[tokio::test]
async fn test_notifications_enabled_by_default() {
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
let notifier = CliNotifier::with_port(65001);
notifier.notify_task_changed(Some(1), "created", None).await;
}
#[tokio::test]
async fn test_notifications_disabled_via_env_value_1() {
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "1");
let notifier = CliNotifier::with_port(65002);
notifier.notify_task_changed(Some(1), "created", None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
}
#[tokio::test]
async fn test_notifications_disabled_via_env_value_true() {
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "true");
let notifier = CliNotifier::with_port(65003);
notifier.notify_task_changed(Some(1), "created", None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
}
#[tokio::test]
async fn test_notifications_disabled_via_env_value_true_uppercase() {
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "TRUE");
let notifier = CliNotifier::with_port(65004);
notifier.notify_task_changed(Some(1), "created", None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
}
#[tokio::test]
async fn test_notifications_not_disabled_with_other_values() {
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "0");
let notifier = CliNotifier::with_port(65005);
notifier.notify_task_changed(Some(1), "created", None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
}
#[tokio::test]
async fn test_notification_message_types() {
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
let notifier = CliNotifier::with_port(65006);
notifier
.notify_task_changed(Some(42), "updated", Some("/test/path".to_string()))
.await;
notifier.notify_event_added(42, 1, None).await;
notifier.notify_workspace_changed(Some(42), None).await;
let message = NotificationMessage::TaskChanged {
task_id: Some(42),
operation: "deleted".to_string(),
project_path: Some("/test/path".to_string()),
};
notifier.notify(message).await;
}
#[tokio::test]
async fn test_disabled_notifications_with_all_message_types() {
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "1");
let notifier = CliNotifier::with_port(65007);
notifier
.notify_task_changed(Some(42), "created", None)
.await;
notifier.notify_event_added(42, 1, None).await;
notifier.notify_workspace_changed(Some(42), None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
}
#[tokio::test]
async fn test_env_var_checked_per_notification() {
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
let notifier = CliNotifier::with_port(65008);
notifier.notify_task_changed(Some(1), "created", None).await;
std::env::set_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS", "1");
notifier.notify_task_changed(Some(2), "created", None).await;
std::env::remove_var("IE_DISABLE_DASHBOARD_NOTIFICATIONS");
notifier.notify_task_changed(Some(3), "created", None).await;
}
#[test]
fn test_notifier_creation() {
let _notifier = CliNotifier::new();
}
#[test]
fn test_notifier_with_custom_port() {
let _notifier = CliNotifier::with_port(8080);
}