|
11 | 11 | than in a SimpleTestCase. |
12 | 12 | """ |
13 | 13 |
|
| 14 | +import re |
14 | 15 | from datetime import date |
15 | 16 |
|
16 | 17 | from django.urls import reverse |
@@ -115,3 +116,35 @@ def test_awards_page_renders_card_with_year_and_anchor_kind(self): |
115 | 116 | self.assertIn("award-card", html) |
116 | 117 | self.assertIn("award-card--medal", html) # faculty honor -> medal anchor |
117 | 118 | self.assertIn("2017", html) # prominent year is rendered |
| 119 | + |
| 120 | + def test_recipient_and_project_join_has_no_stray_space(self): |
| 121 | + # Regression: the recipient/project connector rendered as "Name , Project" |
| 122 | + # due to template whitespace between the two loops. |
| 123 | + person = self.make_person(first_name="Chu", last_name="Li") |
| 124 | + project = self.make_project(name="AltGeoViz", short_name="altgeoviz", is_visible=True) |
| 125 | + award = Award.objects.create(title="People's Choice Award", date=date(2024, 10, 29), |
| 126 | + award_type=AwardType.PROJECT_AWARD) |
| 127 | + award.recipients.set([person]) |
| 128 | + award.projects.set([project]) |
| 129 | + |
| 130 | + html = self.client.get(reverse("website:awards")).content.decode() |
| 131 | + # Strip tags (names sit inside <a>…</a>), then collapse whitespace, so we |
| 132 | + # compare the *visible* text the way a reader sees it. |
| 133 | + text = re.sub(r"\s+", " ", re.sub(r"<[^>]+>", "", html)) |
| 134 | + self.assertIn("Chu Li, AltGeoViz", text) |
| 135 | + self.assertNotIn("Chu Li , AltGeoViz", text) |
| 136 | + |
| 137 | + def test_section_anchors_are_clean_and_paper_sections_show_counts(self): |
| 138 | + self.make_publication(title="A Great Paper", year=2020, award="Best Paper Award") |
| 139 | + Award.objects.create(title="A Faculty Honor", date=date(2017, 5, 1), |
| 140 | + award_type=AwardType.FACULTY_HONOR).recipients.set([self.make_person()]) |
| 141 | + |
| 142 | + html = self.client.get(reverse("website:awards")).content.decode() |
| 143 | + # Clean, shareable anchor IDs (no verbose 'section-...-heading'). |
| 144 | + self.assertIn('id="faculty-honors"', html) |
| 145 | + self.assertIn('id="best-paper-awards"', html) |
| 146 | + self.assertNotIn("section-faculty-honors-heading", html) |
| 147 | + self.assertNotIn("best-paper-awards-heading", html) |
| 148 | + # Paper-section counts. |
| 149 | + self.assertIn("Best Paper Awards (1)", html) |
| 150 | + self.assertIn("Other Paper Awards (0)", html) |
0 commit comments