Skip to content

Commit

Permalink
Refs #35464 -- Added test to cover layout of TabularInline fieldsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
mharyam authored and sarahboyce committed Jul 15, 2024
1 parent b5f4d76 commit 65344f0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/admin_inlines/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ class PhotoInlineMixin:
model = Photo
extra = 2
fieldsets = [
(None, {"fields": ["image", "title"]}),
(None, {"fields": ["image", "title"], "description": "First group"}),
(
"Details",
{"fields": ["description", "creation_date"], "classes": ["collapse"]},
{
"fields": ["description", "creation_date"],
"classes": ["collapse"],
"description": "Second group",
},
),
(
"Details", # Fieldset name intentionally duplicated
{"fields": ["update_date", "updated_by"]},
{"fields": ["update_date", "updated_by"], "description": "Third group"},
),
]

Expand Down
36 changes: 36 additions & 0 deletions tests/admin_inlines/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2422,3 +2422,39 @@ def test_inlines_verbose_name(self):
)
self.assertEqual(available.text, "AVAILABLE ATTENDANT")
self.assertEqual(chosen.text, "CHOSEN ATTENDANT")

def test_tabular_inline_layout(self):
from selenium.webdriver.common.by import By

self.admin_login(username="super", password="secret")
self.selenium.get(
self.live_server_url + reverse("admin:admin_inlines_photographer_add")
)
tabular_inline = self.selenium.find_element(
By.CSS_SELECTOR, "[data-inline-type='tabular']"
)
headers = tabular_inline.find_elements(By.TAG_NAME, "th")
self.assertEqual(
[h.get_attribute("innerText") for h in headers],
[
"",
"IMAGE",
"TITLE",
"DESCRIPTION",
"CREATION DATE",
"UPDATE DATE",
"UPDATED BY",
"DELETE?",
],
)
# There are no fieldset section names rendered.
self.assertNotIn("Details", tabular_inline.text)
# There are no fieldset section descriptions rendered.
self.assertNotIn("First group", tabular_inline.text)
self.assertNotIn("Second group", tabular_inline.text)
self.assertNotIn("Third group", tabular_inline.text)
# There are no fieldset classes applied.
self.assertEqual(
tabular_inline.find_elements(By.CSS_SELECTOR, ".collapse"),
[],
)

0 comments on commit 65344f0

Please sign in to comment.