//! Resource integration tests

use anyhow::Result;
use std::fs;

#[test]
fn test_public_asset_integration() -> Result<()> {
    let temp_project = crate::create_test_project()?;
    let project_root = temp_project.path();

    // Create mock feature with assets
    let feature_dir = project_root.join("features/test-assets");
    let assets_dir = feature_dir.join("assets");
    fs::create_dir_all(&assets_dir)?;

    // Create test asset files
    fs::write(assets_dir.join("style.css"), "/* test styles */")?;
    fs::write(assets_dir.join("script.js"), "console.log('test');")?;

    // Create feature manifest with asset resources
    let manifest = r#"
[feature]
name = "test-assets"
version = "0.1.0"
source = "test"
description = "Test assets feature"

[[resources.public]]
from = "assets/style.css"
to = "public/css/feature.css"

[[resources.public]]
from = "assets/script.js"
to = "public/js/feature.js"
"#;

    fs::write(feature_dir.join("feature.toml"), manifest)?;

    // Test resource integration (would use ResourceIntegrator)
    // Verify assets are copied to correct locations

    Ok(())
}

#[test]
fn test_i18n_resource_integration() -> Result<()> {
    let temp_project = crate::create_test_project()?;
    let project_root = temp_project.path();

    // Create feature with i18n resources
    let feature_dir = project_root.join("features/test-i18n");
    let i18n_dir = feature_dir.join("i18n");
    fs::create_dir_all(i18n_dir.join("en"))?;
    fs::create_dir_all(i18n_dir.join("es"))?;

    // Create translation files
    fs::write(i18n_dir.join("en/feature.ftl"), "welcome = Welcome")?;
    fs::write(i18n_dir.join("es/feature.ftl"), "welcome = Bienvenido")?;

    // Test i18n integration
    // This would use ResourceIntegrator to copy translation files

    Ok(())
}

#[test]
fn test_content_resource_integration() -> Result<()> {
    let temp_project = crate::create_test_project()?;
    let project_root = temp_project.path();

    // Create feature with content resources
    let feature_dir = project_root.join("features/test-content");
    let content_dir = feature_dir.join("content");
    fs::create_dir_all(&content_dir)?;

    // Create content files
    fs::write(content_dir.join("docs.md"), "# Feature Documentation")?;
    fs::write(content_dir.join("tutorial.md"), "# Tutorial")?;

    // Test content integration
    // Verify content is copied to site/content

    Ok(())
}
