diff --git a/tests/test_export.py b/tests/test_export.py index 6f4421df..bb5e4ba5 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -3,7 +3,7 @@ import tempfile from pathlib import Path from graphify.build import build_from_json from graphify.cluster import cluster -from graphify.export import to_json, to_cypher, to_graphml, to_html +from graphify.export import to_json, to_cypher, to_graphml, to_html, to_canvas FIXTURES = Path(__file__).parent / "fixtures" @@ -125,3 +125,18 @@ def test_to_html_contains_nodes_and_edges(): content = out.read_text() assert "RAW_NODES" in content assert "RAW_EDGES" in content + + +def test_to_canvas_file_paths_relative_to_vault(): + """Node file paths in canvas must be vault-root-relative (just fname.md), not hardcoded.""" + G = make_graph() + communities = cluster(G) + with tempfile.TemporaryDirectory() as tmp: + out = Path(tmp) / "graph.canvas" + to_canvas(G, communities, str(out)) + data = json.loads(out.read_text()) + file_nodes = [n for n in data["nodes"] if n.get("type") == "file"] + assert file_nodes, "canvas should contain file nodes" + for node in file_nodes: + assert "/" not in node["file"], f"file path should not contain '/': {node['file']}" + assert node["file"].endswith(".md") diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 92442b81..14a7ad86 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -117,3 +117,9 @@ def test_status_shows_both_hooks(tmp_path): assert "post-commit" in result assert "post-checkout" in result assert result.count("installed") >= 2 + + +def test_hook_skips_head_on_exe(): + """Hook script must skip shebang extraction for .exe binaries (Windows).""" + from graphify.hooks import _PYTHON_DETECT + assert "*.exe) _SHEBANG=" in _PYTHON_DETECT or '*.exe)' in _PYTHON_DETECT