use archlens_domain::{ CodeElement, CodeElementKind, CodeGraph, FilePath, ModuleName, Relationship, RelationshipKind, ports::DiagramRenderer, }; use archlens_html::HtmlRenderer; fn make_graph() -> CodeGraph { let mut graph = CodeGraph::new(); graph.add_element( CodeElement::new( "OrderService", CodeElementKind::Class, FilePath::new("src/app/s.rs").unwrap(), 1, ) .unwrap() .with_module(ModuleName::new("App").unwrap()), ); graph.add_element( CodeElement::new( "Order", CodeElementKind::Class, FilePath::new("src/domain/o.rs").unwrap(), 1, ) .unwrap() .with_module(ModuleName::new("Domain").unwrap()), ); graph.add_relationship( Relationship::new("OrderService", "Order", RelationshipKind::Composition).unwrap(), ); graph.qualify() } #[test] fn html_output_is_self_contained() { let renderer = HtmlRenderer::new(); let output = renderer.render(&make_graph()).unwrap(); let content = output.files()[0].content(); assert!( content.starts_with(""), "should be full HTML doc" ); assert!(content.contains(""), "should be complete HTML"); assert!( !content.contains("src="), "should not have external src= links" ); } #[test] fn html_output_embeds_graph_data_as_json() { let renderer = HtmlRenderer::new(); let output = renderer.render(&make_graph()).unwrap(); let content = output.files()[0].content(); assert!( content.contains("OrderService"), "graph data should contain node names" ); assert!( content.contains("Domain"), "graph data should contain module names" ); } #[test] fn html_output_includes_interactive_js() { let renderer = HtmlRenderer::new(); let output = renderer.render(&make_graph()).unwrap(); let content = output.files()[0].content(); assert!( content.contains("cytoscape") || content.contains("graph") || content.contains("nodes"), "should include graph visualization JS" ); }