diff options
| author | Maryam Yusuf <maryam.m.yusuf1802@gmail.com> | 2024-07-13 13:39:20 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-07-15 12:43:42 +0200 |
| commit | 65344f0e1ecfff3e9623c18c51eff8fe72f9a9df (patch) | |
| tree | 9ee588e301ae3d407a2f86be676babdbc1049082 /tests/admin_inlines | |
| parent | b5f4d76bc400b9f2017da0a52ee4ff0d7c09be15 (diff) | |
Refs #35464 -- Added test to cover layout of TabularInline fieldsets.
Diffstat (limited to 'tests/admin_inlines')
| -rw-r--r-- | tests/admin_inlines/admin.py | 10 | ||||
| -rw-r--r-- | tests/admin_inlines/tests.py | 36 |
2 files changed, 43 insertions, 3 deletions
diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py index 3b018aa5d7..c3983985c3 100644 --- a/tests/admin_inlines/admin.py +++ b/tests/admin_inlines/admin.py @@ -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"}, ), ] diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 04f0a37e02..620aac10a8 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -2422,3 +2422,39 @@ class SeleniumTests(AdminSeleniumTestCase): ) 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"), + [], + ) |
