Skip to content

Commit

Permalink
Add tests duplicate title tags (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgberkeley authored Aug 1, 2024
1 parent a3459b2 commit 018d052
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pcweb/pages/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def exec_blocks(doc, href):
"docs/substates/overview.md": "Substates Overview",
"docs/ui/overview.md": "UI Overview",
"docs/wrapping-react/overview.md": "Wrapping React Overview",
"docs/events/special_events.md": "Special Events",
"docs/recipes-overview.md": "Recipes Overview",
"docs/events/special_events.md": "Special Events Docs",
"docs/library/graphing/general/tooltip.md": "Graphing Tooltip",
"docs/recipes/content/grid.md": "Grid Recipe",
}

def get_component(doc: str, title: str):
Expand Down Expand Up @@ -153,6 +156,7 @@ def get_component(doc: str, title: str):
return
clist = [title, *get_components_from_metadata(d)]
chakra_components[category].append(clist)
title2 = "Chakra " + title2
return multi_docs(path=route, comp=d, component_list=clist, title=title2)
if doc.startswith("docs/library/graphing"):
if should_skip_compile(doc):
Expand Down
35 changes: 35 additions & 0 deletions tests/test_titles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Integration tests for all titles in Reflex."""

from pathlib import Path
from collections import Counter
import sys
import pytest

sys.path.append(str(Path(__file__).resolve().parent.parent))


@pytest.fixture
def routes_fixture():
from pcweb.pages import routes
yield routes


def test_unique_titles(routes_fixture):
assert routes_fixture is not None

titles = []
for route in routes_fixture:
if hasattr(route, 'title'):
titles.append(route.title)

# Count occurrences of each title
title_counts = Counter(titles)

# Find duplicate titles
duplicates = [title for title, count in title_counts.items() if count > 1]

# Assert that there are no duplicates
assert len(duplicates) == 0, f"Duplicate titles found: {duplicates}"

print(f"Test passed. All {len(titles)} titles are unique.")

0 comments on commit 018d052

Please sign in to comment.