Fix visual report chapter navigation (#505)
Co-authored-by: Alex Kenley <Alex.Kenley@threatvectorsecurity.com>
This commit is contained in:
38
tests/test_visual_report.py
Normal file
38
tests/test_visual_report.py
Normal 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"}
|
||||
Reference in New Issue
Block a user