diff --git a/datasette/templates/query.html b/datasette/templates/query.html index c65953fb..0882e142 100644 --- a/datasette/templates/query.html +++ b/datasette/templates/query.html @@ -28,7 +28,7 @@ {% block content %} -

{{ metadata.title or database }}{% if private %} 🔒{% endif %}

+

{{ metadata.title or database }}{% if canned_query and not metadata.title %}: {{ canned_query }}{% endif %}{% if private %} 🔒{% endif %}

{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %} diff --git a/tests/test_html.py b/tests/test_html.py index d1411afd..ebd91cf1 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1004,6 +1004,13 @@ def test_404_content_type(app_client): assert "text/html; charset=utf-8" == response.headers["content-type"] +def test_canned_query_default_title(app_client): + response = app_client.get("/fixtures/magic_parameters") + assert response.status == 200 + soup = Soup(response.body, "html.parser") + assert "fixtures: magic_parameters" == soup.find("h1").text + + def test_canned_query_with_custom_metadata(app_client): response = app_client.get("/fixtures/neighborhood_search?text=town") assert response.status == 200 diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 2d57b5e3..90e58a27 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -179,13 +179,13 @@ def test_view_query(allow, expected_anon, expected_auth): assert expected_anon == anon_response.status if allow and anon_response.status == 200: # Should be no padlock - assert ">fixtures 🔒" not in anon_response.text + assert "🔒" not in anon_response.text auth_response = client.get( "/fixtures/q", cookies={"ds_actor": client.actor_cookie({"id": "root"})} ) assert expected_auth == auth_response.status if allow and expected_anon == 403 and expected_auth == 200: - assert ">fixtures 🔒" in auth_response.text + assert ">fixtures: q 🔒" in auth_response.text @pytest.mark.parametrize(