use std::process::Command;
#[test]
fn init_then_build_renders_the_scaffolded_site_with_custom_component() {
let tmp = std::env::temp_dir().join(format!("docgen_init_build_{}", std::process::id()));
let _ = std::fs::remove_dir_all(&tmp);
std::fs::create_dir_all(&tmp).unwrap();
let st = Command::new(env!("CARGO_BIN_EXE_docgen"))
.arg("init")
.arg(&tmp)
.arg("--force")
.status()
.unwrap();
assert!(st.success());
assert!(tmp.join("docgen.toml").is_file());
assert!(tmp.join("docs/index.md").is_file());
assert!(tmp.join("components/note/template.html").is_file());
let st = Command::new(env!("CARGO_BIN_EXE_docgen"))
.arg("build")
.arg(&tmp)
.status()
.unwrap();
assert!(st.success());
let home = std::fs::read_to_string(tmp.join("dist/index.html")).unwrap();
assert!(home.contains("docgen-callout--warning")); assert!(home.contains("Heads up"));
assert!(home.contains("docgen-note")); assert!(home.contains("a project component")); assert!(home.contains("— My Docs</title>")); assert!(tmp.join("dist/components.css").is_file());
let guide = std::fs::read_to_string(tmp.join("dist/guide/index.html")).unwrap();
assert!(guide.contains(r#"href="/index""#));
assert!(guide.contains(r#"src="/islands/mermaid.js""#));
let _ = std::fs::remove_dir_all(&tmp);
}