use ryo_plugin_loader::{MutationCategory, PluginLoader, TransformDef, CURRENT_API_VERSION};
use std::path::Path;
const TEST_PLUGIN_PATH: &str = "../../plugins/test-bool-simplify/target/wasm32-wasip1/release/test_bool_simplify_component.wasm";
#[test]
#[ignore = "Requires WASM plugin to be built first: cd plugins/test-bool-simplify && cargo build --release --target wasm32-wasip1"]
fn test_load_bool_simplify_plugin() {
let loader = PluginLoader::new().expect("Failed to create PluginLoader");
let plugin_path = Path::new(env!("CARGO_MANIFEST_DIR")).join(TEST_PLUGIN_PATH);
let wasm_bytes = std::fs::read(&plugin_path)
.unwrap_or_else(|e| panic!("Failed to read plugin at {:?}: {}", plugin_path, e));
let plugin = loader.load(&wasm_bytes).expect("Failed to load plugin");
assert_eq!(plugin.manifest.api_version, CURRENT_API_VERSION);
assert_eq!(plugin.manifest.name, "bool-simplify");
assert_eq!(
plugin.manifest.description,
"Simplify boolean comparisons: x == true -> x"
);
assert!(matches!(plugin.manifest.category, MutationCategory::Idiom));
assert_eq!(plugin.manifest.tier, 1);
assert!(matches!(
plugin.manifest.transform,
TransformDef::Template(_)
));
assert!(!plugin.additional_patterns.is_empty());
println!("Successfully loaded plugin: {}", plugin.manifest.name);
println!(" Description: {}", plugin.manifest.description);
println!(" Pattern: {}", plugin.manifest.pattern);
println!(" Additional patterns: {}", plugin.additional_patterns);
}