0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Assert breadcrumbs not rendered on views that have them disabled

To be reverted once we reintroduce breadcrumbs to these views
This commit is contained in:
Sage Abdullah 2023-10-05 16:52:21 +01:00 committed by Thibaud Colas
parent 92c5be35e8
commit 7ad4263d82
5 changed files with 22 additions and 139 deletions

View File

@ -70,9 +70,7 @@ class TestCollectionsIndexViewAsSuperuser(
self.assertTemplateUsed(response, "wagtailadmin/collections/index.html")
self.assertNotContains(response, "No collections have been created.")
self.assertContains(response, "Holiday snaps")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Collections"}], response.content
)
self.assertBreadcrumbsNotRendered(response.content)
def test_ordering(self):
root_collection = Collection.get_first_root_node()
@ -207,13 +205,7 @@ class TestAddCollectionAsSuperuser(AdminTemplateTestUtils, WagtailTestUtils, Tes
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.root_collection.name)
self.assertBreadcrumbsItemsRendered(
[
{"label": "Collections", "url": "/admin/collections/"},
{"label": "New: Collection", "url": ""},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_post(self):
response = self.post(
@ -332,13 +324,7 @@ class TestEditCollectionAsSuperuser(AdminTemplateTestUtils, WagtailTestUtils, Te
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Delete collection")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/collections/", "label": "Collections"},
{"url": "", "label": str(self.collection)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_cannot_edit_root_collection(self):
response = self.get(collection_id=self.root_collection.id)

View File

@ -116,10 +116,7 @@ class TestWorkflowsIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase)
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/index.html")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Workflows"}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
# Initially there should be no workflows listed
self.assertContains(response, "There are no enabled workflows.")
@ -207,13 +204,7 @@ class TestWorkflowsCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/create.html")
self.assertBreadcrumbsItemsRendered(
[
{"label": "Workflows", "url": "/admin/workflows/list/"},
{"label": "New: Workflow", "url": ""},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_post(self):
response = self.post(
@ -437,13 +428,7 @@ class TestWorkflowsEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/edit.html")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/workflows/list/", "label": "Workflows"},
{"url": "", "label": str(self.workflow)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
# Check that the list of pages has the page to which this workflow is assigned
self.assertContains(response, self.page.title)
@ -756,10 +741,7 @@ class TestTaskIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/task_index.html")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Tasks"}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
# Initially there should be no tasks listed
self.assertContains(response, "There are no enabled tasks")
@ -854,13 +836,7 @@ class TestCreateTaskView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/create_task.html")
self.assertBreadcrumbsItemsRendered(
[
{"label": "Tasks", "url": "/admin/workflows/tasks/index/"},
{"label": "New: Simple task", "url": ""},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_get_with_non_task_model(self):
response = self.get(
@ -978,13 +954,7 @@ class TestEditTaskView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/edit_task.html")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/workflows/tasks/index/", "label": "Tasks"},
{"url": "", "label": str(self.task)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_post(self):
self.assertEqual(self.task.groups.count(), 0)

View File

@ -20,10 +20,7 @@ class TestLocaleIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/generic/index.html")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Locales"}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
class TestLocaleCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
@ -46,13 +43,7 @@ class TestLocaleCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtaillocales/create.html")
self.assertBreadcrumbsItemsRendered(
[
{"label": "Locales", "url": "/admin/locales/"},
{"label": "New: Locale", "url": ""},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
self.assertEqual(
response.context["form"].fields["language_code"].choices, [("fr", "French")]
@ -127,13 +118,7 @@ class TestLocaleEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtaillocales/edit.html")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/locales/", "label": "Locales"},
{"url": "", "label": str(self.english)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
self.assertEqual(
response.context["form"].fields["language_code"].choices,

View File

@ -20,10 +20,7 @@ class TestSiteIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/generic/index.html")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Sites"}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
class TestSiteCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
@ -60,13 +57,7 @@ class TestSiteCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailsites/create.html")
self.assertBreadcrumbsItemsRendered(
[
{"label": "Sites", "url": "/admin/sites/"},
{"label": "New: Site", "url": ""},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_create(self):
response = self.post(
@ -206,13 +197,7 @@ class TestSiteEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailsites/edit.html")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/sites/", "label": "Sites"},
{"url": "", "label": str(self.localhost)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
url_finder = AdminURLFinder(self.user)
expected_url = "/admin/sites/edit/%d/" % self.localhost.id

View File

@ -11,7 +11,6 @@ from django.db.models import Q
from django.http import HttpRequest, HttpResponse
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils.text import capfirst
from wagtail import hooks
from wagtail.admin.admin_url_finder import AdminURLFinder
@ -118,10 +117,7 @@ class TestGroupUsersView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
self.assertContains(response, "testuser")
# response should contain page furniture, including the "Add a user" button
self.assertContains(response, "Add a user")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": capfirst(User._meta.verbose_name_plural)}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_inexisting_group(self):
response = self.get(group_id=9999)
@ -207,10 +203,7 @@ class TestUserIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
self.assertContains(response, "testuser")
# response should contain page furniture, including the "Add a user" button
self.assertContains(response, "Add a user")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": capfirst(User._meta.verbose_name_plural)}],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
@unittest.skipIf(
settings.AUTH_USER_MODEL == "emailuser.EmailUser", "Negative UUID not possible"
@ -314,16 +307,7 @@ class TestUserCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
self.assertTemplateUsed(response, "wagtailusers/users/create.html")
self.assertContains(response, "Password")
self.assertContains(response, "Password confirmation")
self.assertBreadcrumbsItemsRendered(
[
{
"url": "/admin/users/",
"label": capfirst(User._meta.verbose_name_plural),
},
{"url": "", "label": f"New: {capfirst(User._meta.verbose_name)}"},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_create(self):
response = self.post(
@ -842,16 +826,7 @@ class TestUserEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
self.assertTemplateUsed(response, "wagtailusers/users/edit.html")
self.assertContains(response, "Password")
self.assertContains(response, "Password confirmation")
self.assertBreadcrumbsItemsRendered(
[
{
"url": "/admin/users/",
"label": capfirst(User._meta.verbose_name_plural),
},
{"url": "", "label": str(self.test_user)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
url_finder = AdminURLFinder(self.current_user)
expected_url = "/admin/users/%s/" % self.test_user.pk
@ -1345,10 +1320,7 @@ class TestGroupIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
self.assertTemplateUsed(response, "wagtailadmin/generic/index.html")
# response should contain page furniture, including the "Add a group" button
self.assertContains(response, "Add a group")
self.assertBreadcrumbsItemsRendered(
[{"url": "", "label": "Groups"}], response.content
)
self.assertBreadcrumbsNotRendered(response.content)
def test_search(self):
response = self.get({"q": "Hello"})
@ -1412,13 +1384,7 @@ class TestGroupCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailusers/groups/create.html")
self.assertBreadcrumbsItemsRendered(
[
{"url": "/admin/groups/", "label": "Groups"},
{"url": "", "label": "New: Group"},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
def test_create_group(self):
response = self.post({"name": "test group"})
@ -1660,16 +1626,7 @@ class TestGroupEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailusers/groups/edit.html")
self.assertBreadcrumbsItemsRendered(
[
{
"url": "/admin/groups/",
"label": "Groups",
},
{"url": "", "label": str(self.test_group)},
],
response.content,
)
self.assertBreadcrumbsNotRendered(response.content)
url_finder = AdminURLFinder(self.user)
expected_url = "/admin/groups/edit/%d/" % self.test_group.id