use std::fs;
use std::path::PathBuf;

#[test]
fn scene_generator_html_exists_and_has_required_elements() {
    let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    let html_path = manifest_dir
        .join("frontend")
        .join("scene-generator")
        .join("sg_scene_generator.html");

    let source = fs::read_to_string(&html_path)
        .unwrap_or_else(|err| panic!("HTML file not found at {:?}: {}", html_path, err));

    assert!(source.contains("场景 Skill 生成器"), "missing title");
    assert!(source.contains("sourceDir"), "missing sourceDir input");
    assert!(source.contains("sceneId"), "missing sceneId input");
    assert!(source.contains("sceneName"), "missing sceneName input");
    assert!(source.contains("/analyze"), "missing /analyze endpoint");
    assert!(source.contains("/generate"), "missing /generate endpoint");
    assert!(
        source.contains("fetch("),
        "missing fetch for API calls"
    );

    assert!(
        source.contains("127.0.0.1") || source.contains("localhost"),
        "should reference localhost server"
    );
}
