From 3ef4de84322c1016c615eac2bf4288408a312c15 Mon Sep 17 00:00:00 2001 From: Dani Hodovic Date: Tue, 2 Jun 2020 00:09:02 +0300 Subject: [PATCH] Add test for TOC markdown extension markdown 3.2.2 breaks TOC, so add a regression test --- tests/settings/base.py | 1 + tests/test_pages.py | 16 ++++++++++++++++ tox.ini | 2 ++ 3 files changed, 19 insertions(+) diff --git a/tests/settings/base.py b/tests/settings/base.py index 7d67a0d..7a9682f 100644 --- a/tests/settings/base.py +++ b/tests/settings/base.py @@ -71,3 +71,4 @@ STATIC_URL = "/static/" SITE_ID = 1 WAGTAIL_SITE_NAME = "My Example Site" +WAGTAILMARKDOWN_EXTENSIONS = ["toc"] diff --git a/tests/test_pages.py b/tests/test_pages.py index 6febe75..594b4de 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -59,3 +59,19 @@ def test_canonical_url(client): soup = BeautifulSoup(res.content, "html.parser") el = soup.find("link", attrs={"rel": "canonical"}) assert el["href"] == "https://foo.com" + + +def test_renders_toc(client): + post = BlogPage( + title="My post", + body=""" +[TOC] +# first paragraph""", + date=timezone.now(), + ) + pages = [(BlogIndexPage(title="index"), [post])] + with page_tree(pages): + [(_, [post])] = pages + res = client.get(post.get_url()) + assert res.status_code == 200 + assert BeautifulSoup(res.content, "html.parser").select(".toc") diff --git a/tox.ini b/tox.ini index 09b8d46..c28cc4b 100644 --- a/tox.ini +++ b/tox.ini @@ -80,6 +80,8 @@ passenv = addopts = --ds=tests.settings.test --reuse-db -ra testpaths = tests norecursedirs = .git */migrations/* .venv +filterwarnings = + ignore::django.utils.deprecation.RemovedInDjango40Warning [isort] recursive = True