diff --git a/event/tests/test_views_participant.py b/event/tests/test_views_participant.py index cb11330..4328210 100644 --- a/event/tests/test_views_participant.py +++ b/event/tests/test_views_participant.py @@ -106,6 +106,29 @@ def test_events_are_sorted_alphabetically_by_theme_and_subject(self): self.assertEqual(events_list[4], self.event5) +class EventListViewPaginationTest(TestCase): + def setUp(self): + self.url = reverse("event_list") + + def test_list_page_pagination_visibility(self): + response = self.client.get(self.url) + self.assertNotContains(response, "Page suivante") + + EventFactory.create_batch(10, pub_status=Event.PubStatus.PUB) + response = self.client.get(self.url) + self.assertNotContains(response, "Page suivante") + + # Paginate by 10 + EventFactory(pub_status=Event.PubStatus.PUB) + response = self.client.get(self.url) + self.assertContains(response, "Page suivante") + self.assertContains(response, "?page=2") + + response = self.client.get(f"{self.url}?page=2") + self.assertContains(response, "Page précédente") + self.assertContains(response, self.url) + + class EventRegistrationViewTest(TestCase): def setUp(self): respx.post(settings.BREVO_SMTP_URL).mock(return_value=httpx.Response(200, json={"message": "OK"})) @@ -267,6 +290,29 @@ def test_contributions_are_sorted_alphabetically_by_theme_and_title(self): self.assertEqual(contributions_list[4], self.contribution5) +class ContributionListViewPaginationTest(TestCase): + def setUp(self): + self.url = reverse("contribution_list") + + def test_list_page_pagination_visibility(self): + response = self.client.get(self.url) + self.assertNotContains(response, "Page suivante") + + ContributionFactory.create_batch(10, public=True, event__pub_status=Event.PubStatus.PUB) + response = self.client.get(self.url) + self.assertNotContains(response, "Page suivante") + + # Paginate by 10 + ContributionFactory(public=True, event__pub_status=Event.PubStatus.PUB) + response = self.client.get(self.url) + self.assertContains(response, "Page suivante") + self.assertContains(response, "?page=2") + + response = self.client.get(f"{self.url}?page=2") + self.assertContains(response, "Page précédente") + self.assertContains(response, self.url) + + class ContributionDetailViewTest(TestCase): def test_anonymous_user_cannot_see_not_public_contribution(self): contribution = ContributionFactory(public=False) diff --git a/templates/event/contribution_list.html b/templates/event/contribution_list.html index a004385..17f9164 100644 --- a/templates/event/contribution_list.html +++ b/templates/event/contribution_list.html @@ -46,8 +46,10 @@