diff options
| author | David Smith <smithdc@gmail.com> | 2023-11-17 05:39:53 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-17 05:43:33 +0100 |
| commit | 557fa51837a57534f8ca486133a412547a98a37e (patch) | |
| tree | b08710ab737146fa9b137e9529b0d373caa1258f /tests/forms_tests | |
| parent | 292f1ea90f90ff140617299a25884c8fda24aa64 (diff) | |
Refs #32819 -- Added aria-describedby test for widgets with custom id.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 877571726d..7ea88f0cc8 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -3097,6 +3097,23 @@ Options: <select multiple name="options" aria-invalid="true" required> "</span></td></tr>", ) + def test_aria_describedby_custom_widget_id(self): + class UserRegistration(Form): + username = CharField( + max_length=255, + help_text="e.g., user@example.com", + widget=TextInput(attrs={"id": "custom-id"}), + ) + + f = UserRegistration() + self.assertHTMLEqual( + str(f), + '<div><label for="custom-id">Username:</label>' + '<div class="helptext" id="id_username_helptext">e.g., user@example.com' + '</div><input type="text" name="username" id="custom-id" maxlength="255" ' + 'required aria-describedby="id_username_helptext"></div>', + ) + def test_as_widget_custom_aria_describedby(self): class FoodForm(Form): intl_name = CharField(help_text="The food's international name.") |
