// Tests for mecha10_cli::sim::catalog

use mecha10_cli::sim::catalog::*;

#[test]
fn test_parse_catalog() {
    let json = r#"{
        "version": "0.1.0",
        "environments": [
            {
                "id": "test_env",
                "path": "test/test.tscn",
                "name": "Test Environment",
                "description": "Test",
                "tags": ["test"],
                "required_sensors": ["lidar"],
                "robot_platforms": ["rover"],
                "difficulty": "easy"
            }
        ]
    }"#;

    let catalog: EnvironmentCatalog = serde_json::from_str(json).unwrap();

    assert_eq!(catalog.version, "0.1.0");
    assert_eq!(catalog.environments.len(), 1);
    assert_eq!(catalog.environments[0].id, "test_env");
}

#[test]
fn test_environment_compatibility() {
    let env = Environment {
        id: "test".to_string(),
        path: "test.tscn".to_string(),
        name: "Test".to_string(),
        description: "Test".to_string(),
        tags: vec![],
        required_sensors: vec!["lidar".to_string(), "camera".to_string()],
        optional_sensors: vec![],
        robot_platforms: vec!["rover".to_string()],
        task_nodes: vec![],
        difficulty: "easy".to_string(),
        dimensions: vec![],
        features: EnvironmentFeatures::default(),
        curriculum_stage: 0,
        estimated_duration_s: 0,
        reward_config: HashMap::new(),
    };

    // Has all required sensors
    assert!(env.is_compatible_with_sensors(&["lidar".to_string(), "camera".to_string(), "imu".to_string()]));

    // Missing camera
    assert!(!env.is_compatible_with_sensors(&["lidar".to_string()]));

    // Platform compatibility
    assert!(env.is_compatible_with_platform("rover"));
    assert!(!env.is_compatible_with_platform("arm"));
}
