2026-02-08 20:18:46 +00:00
|
|
|
//! 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();
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// 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)?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Create test asset files
|
|
|
|
|
fs::write(assets_dir.join("style.css"), "/* test styles */")?;
|
|
|
|
|
fs::write(assets_dir.join("script.js"), "console.log('test');")?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// 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"
|
|
|
|
|
"#;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
fs::write(feature_dir.join("feature.toml"), manifest)?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Test resource integration (would use ResourceIntegrator)
|
|
|
|
|
// Verify assets are copied to correct locations
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_i18n_resource_integration() -> Result<()> {
|
|
|
|
|
let temp_project = crate::create_test_project()?;
|
|
|
|
|
let project_root = temp_project.path();
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// 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"))?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Create translation files
|
|
|
|
|
fs::write(i18n_dir.join("en/feature.ftl"), "welcome = Welcome")?;
|
|
|
|
|
fs::write(i18n_dir.join("es/feature.ftl"), "welcome = Bienvenido")?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Test i18n integration
|
|
|
|
|
// This would use ResourceIntegrator to copy translation files
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_content_resource_integration() -> Result<()> {
|
|
|
|
|
let temp_project = crate::create_test_project()?;
|
|
|
|
|
let project_root = temp_project.path();
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// 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)?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Create content files
|
|
|
|
|
fs::write(content_dir.join("docs.md"), "# Feature Documentation")?;
|
|
|
|
|
fs::write(content_dir.join("tutorial.md"), "# Tutorial")?;
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
// Test content integration
|
|
|
|
|
// Verify content is copied to site/content
|
2026-02-08 20:37:49 +00:00
|
|
|
|
2026-02-08 20:18:46 +00:00
|
|
|
Ok(())
|
2026-02-08 20:37:49 +00:00
|
|
|
}
|