Fix visual report chapter navigation (#505)

Co-authored-by: Alex Kenley <Alex.Kenley@threatvectorsecurity.com>
This commit is contained in:
Alexander Kenley
2026-06-01 23:26:13 +10:00
committed by GitHub
parent 6ad617931d
commit 07d92556a3
2 changed files with 82 additions and 8 deletions

View File

@@ -0,0 +1,38 @@
from bs4 import BeautifulSoup
from src.visual_report import generate_visual_report
def test_visual_report_toc_links_match_rendered_heading_ids():
report = """
# Automated Crypto Trading Bot Strategies
### **1.0 Introduction & Research Scope**
Intro body.
### **2.0 Determining the "Best" Configuration**
Configuration body.
"""
html = generate_visual_report(
"crypto bot strategies",
report,
sources=[],
stats={},
session_id="rp-test",
)
soup = BeautifulSoup(html, "html.parser")
links = soup.select(".toc-sidebar nav a")
assert [link.get_text(strip=True) for link in links] == [
"1.0 Introduction & Research Scope",
'2.0 Determining the "Best" Configuration',
]
for link in links:
target_id = link["href"].removeprefix("#")
target = soup.find(id=target_id)
assert target is not None
assert target.name in {"h2", "h3"}