feat: implement all P1/P2/P3/P4 improvements from issue backlog
P1 correctness: - filter test files by default (--include-tests to opt in) - per-module diagrams show cross-module dependency arrows - qualified type names (Module::TypeName) fix false edges from duplicate names P2 output richness: - method parameter types and return types in class diagrams (Rust + Python) - Python pyproject.toml project analyzer (--level project for monorepos) P3 unique value: - boundary rules in archlens.toml ([rules] allow/deny, --strict enforcement) P4 nice to have: - dependency weight labels on module arrows (--no-weights to disable) - --watch mode with 500ms debounce - D2 renderer adapter (--format d2) - interactive self-contained HTML viewer (--format html) - git-aware incremental analysis (--since <ref>)
This commit is contained in:
78
crates/adapters/html-viewer/tests/html_renderer_tests.rs
Normal file
78
crates/adapters/html-viewer/tests/html_renderer_tests.rs
Normal file
@@ -0,0 +1,78 @@
|
||||
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("<!DOCTYPE html>"),
|
||||
"should be full HTML doc"
|
||||
);
|
||||
assert!(content.contains("</html>"), "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"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user