-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix docs breadcrumb overview routes #6441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| """Tests for docs breadcrumbs.""" | ||
|
|
||
| import importlib | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import reflex as rx | ||
|
|
||
| sys.path.append(str(Path(__file__).resolve().parent.parent)) | ||
|
|
||
|
|
||
| def test_enterprise_parent_breadcrumb_uses_overview_route(monkeypatch): | ||
| """Parent breadcrumbs should link to a real overview route when needed.""" | ||
| docpage_module = importlib.import_module("reflex_docs.templates.docpage.docpage") | ||
| monkeypatch.setattr( | ||
| docpage_module, | ||
| "_REGISTERED_DOC_ROUTES", | ||
| { | ||
| "/enterprise/overview/", | ||
| "/enterprise/ag-grid/", | ||
| "/enterprise/ag-grid/pivot-mode/", | ||
| }, | ||
| raising=False, | ||
| ) | ||
|
|
||
| rendered = str( | ||
| docpage_module.breadcrumb("/enterprise/ag-grid/pivot-mode/", rx.box()) | ||
| ) | ||
|
|
||
| assert 'to:"/enterprise/overview/"' in rendered | ||
| assert 'to:"/enterprise/ag-grid/"' in rendered | ||
| assert 'to:"/enterprise/ag-grid/pivot-mode/"' in rendered | ||
|
Comment on lines
+26
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The assertions match against Reflex's internal component serialization string (e.g. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
href(e.g./enterprisewith no trailing slash) while every other return in this function returns the fully-normalizedroute(e.g./enterprise/). When a path segment has no matching route and no…/overview/variant, the resulting breadcrumb link will be missing a trailing slash, producing an inconsistent URL relative to all other crumbs. Returningroutekeeps the output uniform.