summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Maron <johannes@maron.family>2024-03-06 21:18:36 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-14 20:37:53 +0100
commit8fd953f28abc95aee2e2f59c94d8c58af0d792d7 (patch)
tree1e19bdca015140228e7d9f88406f88adf6bc907e /tests
parent710ca576816fe90c15a7e62f95074ff0bbd77f0e (diff)
[5.0.x] Fixed #35273 -- Fixed rendering AdminFileWidget's attributes.
Regression in 8a6c0203c4e92908c2b26ba54feba4ce7e76d081. Backport of e69019555d683fd6a831f87cb09e3deb86e4e7c7 from main
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_widgets/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 75c546bcbf..abaed86384 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -590,6 +590,19 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
'<input type="file" name="test">',
)
+ def test_render_with_attrs_id(self):
+ storage_url = default_storage.url("")
+ w = widgets.AdminFileWidget()
+ self.assertHTMLEqual(
+ w.render("test", self.album.cover_art, attrs={"id": "test_id"}),
+ f'<p class="file-upload">Currently: <a href="{storage_url}albums/'
+ r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> '
+ '<span class="clearable-file-input">'
+ '<input type="checkbox" name="test-clear" id="test-clear_id"> '
+ '<label for="test-clear_id">Clear</label></span><br>'
+ 'Change: <input type="file" name="test" id="test_id"></p>',
+ )
+
def test_render_required(self):
widget = widgets.AdminFileWidget()
widget.is_required = True
@@ -618,6 +631,20 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
},
)
+ def test_render_checked(self):
+ storage_url = default_storage.url("")
+ widget = widgets.AdminFileWidget()
+ widget.checked = True
+ self.assertHTMLEqual(
+ widget.render("test", self.album.cover_art),
+ f'<p class="file-upload">Currently: <a href="{storage_url}albums/'
+ r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a> '
+ '<span class="clearable-file-input">'
+ '<input type="checkbox" name="test-clear" id="test-clear_id" checked>'
+ '<label for="test-clear_id">Clear</label></span><br>'
+ 'Change: <input type="file" name="test" checked></p>',
+ )
+
def test_readonly_fields(self):
"""
File widgets should render as a link when they're marked "read only."