use just the page part of the path in breadcrumbs
rather than showing the full path (e.g. /foo/bar/baz) in breadcrumbs when the page doesn't have a Title, show just the leaf (baz) Closes #4
This commit is contained in:
@@ -3,7 +3,7 @@ import pytest
|
||||
from werkzeug.http import dump_cookie
|
||||
|
||||
from incorporealcms.pages import (generate_parent_navs, instance_resource_path_to_request_path, render,
|
||||
request_path_to_instance_resource_path)
|
||||
request_path_to_breadcrumb_display, request_path_to_instance_resource_path)
|
||||
|
||||
|
||||
def test_generate_page_navs_index(app):
|
||||
@@ -15,13 +15,13 @@ def test_generate_page_navs_index(app):
|
||||
def test_generate_page_navs_subdir_index(app):
|
||||
"""Test that dir pages have navs to the root and themselves."""
|
||||
with app.app_context():
|
||||
assert generate_parent_navs('pages/subdir/index.md') == [('incorporeal.org', '/'), ('/subdir/', '/subdir/')]
|
||||
assert generate_parent_navs('pages/subdir/index.md') == [('incorporeal.org', '/'), ('subdir', '/subdir/')]
|
||||
|
||||
|
||||
def test_generate_page_navs_subdir_real_page(app):
|
||||
"""Test that real pages have navs to the root, their parent, and themselves."""
|
||||
with app.app_context():
|
||||
assert generate_parent_navs('pages/subdir/page.md') == [('incorporeal.org', '/'), ('/subdir/', '/subdir/'),
|
||||
assert generate_parent_navs('pages/subdir/page.md') == [('incorporeal.org', '/'), ('subdir', '/subdir/'),
|
||||
('Page', '/subdir/page')]
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_generate_page_navs_subdir_with_title_parsing_real_page(app):
|
||||
assert generate_parent_navs('pages/subdir-with-title/page.md') == [
|
||||
('incorporeal.org', '/'),
|
||||
('SUB!', '/subdir-with-title/'),
|
||||
('/subdir-with-title/page', '/subdir-with-title/page')
|
||||
('page', '/subdir-with-title/page')
|
||||
]
|
||||
|
||||
|
||||
@@ -162,3 +162,12 @@ def test_request_resource_request_page(app):
|
||||
"""Test that a request can resolve to a resource and back to a request."""
|
||||
with app.test_request_context():
|
||||
instance_resource_path_to_request_path(request_path_to_instance_resource_path('no-title')) == 'no-title'
|
||||
|
||||
|
||||
def test_request_path_to_breadcrumb_display_patterns():
|
||||
"""Test various conversions from request path to leaf nodes for display in the breadcrumbs."""
|
||||
assert request_path_to_breadcrumb_display('/foo') == 'foo'
|
||||
assert request_path_to_breadcrumb_display('/foo/') == 'foo'
|
||||
assert request_path_to_breadcrumb_display('/foo/bar') == 'bar'
|
||||
assert request_path_to_breadcrumb_display('/foo/bar/') == 'bar'
|
||||
assert request_path_to_breadcrumb_display('/') == ''
|
||||
|
||||
Reference in New Issue
Block a user