From 9facaf404f6d18836f078822f106d8ea7bcfde81 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 29 Dec 2021 10:20:54 -0800 Subject: [PATCH] Validates html in feed views --- bookwyrm/templates/feed/status.html | 2 +- bookwyrm/tests/views/test_feed.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/feed/status.html b/bookwyrm/templates/feed/status.html index 8dcad0886..e7b9280d7 100644 --- a/bookwyrm/templates/feed/status.html +++ b/bookwyrm/templates/feed/status.html @@ -31,7 +31,7 @@ {% endif %} {% endfor %} -
+
{% include 'snippets/status/status.html' with status=status main=True %}
diff --git a/bookwyrm/tests/views/test_feed.py b/bookwyrm/tests/views/test_feed.py index 63264b800..475bebeb7 100644 --- a/bookwyrm/tests/views/test_feed.py +++ b/bookwyrm/tests/views/test_feed.py @@ -13,6 +13,7 @@ from django.test.client import RequestFactory from bookwyrm import models from bookwyrm import views from bookwyrm.activitypub import ActivitypubResponse +from bookwyrm.tests.validate_html import validate_html @patch("bookwyrm.activitystreams.ActivityStream.get_activity_stream") @@ -58,7 +59,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request, "home") self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_status_page(self, *_): @@ -72,7 +73,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -139,7 +140,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -159,7 +160,7 @@ class FeedViews(TestCase): is_api.return_value = False result = view(request, "mouse", status.id) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) with patch("bookwyrm.views.feed.is_api_request") as is_api: @@ -175,7 +176,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) def test_direct_messages_page_user(self, *_): @@ -185,7 +186,7 @@ class FeedViews(TestCase): request.user = self.local_user result = view(request, "nutria") self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) self.assertEqual(result.context_data["partner"], self.another_user)