Fixed broken CSS on 404 page, closes #777

pull/819/head
Simon Willison 2020-06-08 17:35:23 -07:00
rodzic 49d6d2f7b0
commit 647c5ff0f3
2 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -1015,7 +1015,16 @@ class DatasetteRouter(AsgiRouter):
templates = ["500.html"]
if status != 500:
templates = ["{}.html".format(status)] + templates
info.update({"ok": False, "error": message, "status": status, "title": title})
info.update(
{
"ok": False,
"error": message,
"status": status,
"title": title,
"base_url": self.ds.config("base_url"),
"app_css_hash": self.ds.app_css_hash(),
}
)
headers = {}
if self.ds.cors:
headers["Access-Control-Allow-Origin"] = "*"

Wyświetl plik

@ -965,6 +965,18 @@ def inner_html(soup):
return inner_html.strip()
@pytest.mark.parametrize("path", ["/404", "/fixtures/404"])
def test_404(app_client, path):
response = app_client.get(path)
assert 404 == response.status
assert (
'<link rel="stylesheet" href="/-/static/app.css?{}'.format(
app_client.ds.app_css_hash()
)
in response.text
)
@pytest.mark.parametrize(
"path,expected_redirect",
[("/fixtures/", "/fixtures"), ("/fixtures/simple_view/", "/fixtures/simple_view")],