diff --git a/ds_judgements_public_ui/templates/includes/judgment_text_toolbar.html b/ds_judgements_public_ui/templates/includes/judgment_text_toolbar.html index 751564c20..93bdc6481 100644 --- a/ds_judgements_public_ui/templates/includes/judgment_text_toolbar.html +++ b/ds_judgements_public_ui/templates/includes/judgment_text_toolbar.html @@ -1,10 +1,11 @@ {% load i18n %}
- + {% if context.back_link %} + + {% endif %}
- {% if context.back_link %}{% endif %}

{{ context.judgment_title }}
diff --git a/judgments/tests/test_detail.py b/judgments/tests/test_detail.py index 65efdbd64..2bc2e7eea 100644 --- a/judgments/tests/test_detail.py +++ b/judgments/tests/test_detail.py @@ -72,6 +72,19 @@ def test_published_judgment_response(self, mock_judgment, mock_pdf_size): self.assertEqual(response.status_code, 200) +class TestJudgmentBackToSearchLink(TestCase): + @patch("judgments.views.detail.get_pdf_size") + @patch("judgments.views.detail.get_published_judgment_by_uri") + def test_no_link_if_no_context(self, mock_judgment, mock_pdf_size): + mock_judgment.return_value = JudgmentFactory.build(is_published=True) + mock_pdf_size.return_value = "1234KB" + + response = self.client.get("/test/2023/123") + decoded_response = response.content.decode("utf-8") + + assert "Back to search results" not in decoded_response + + class TestJudgmentPdfLinkText(TestCase): @patch("judgments.views.detail.get_pdf_size") @patch("judgments.views.detail.get_published_judgment_by_uri")