diff options
| author | antoliny0919 <antoliny0919@gmail.com> | 2025-08-07 22:17:50 +0900 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-27 07:43:45 -0500 |
| commit | 187a789f99ecbc708de517c6b54d480b68ba59fe (patch) | |
| tree | a9ad3ba592bf6c65cb14b39110adbfbaa2825a51 /tests/auth_tests/test_templates.py | |
| parent | d4ab33af061c13e290b6996756b2c72578891285 (diff) | |
Fixed #34643 -- Moved inputs beneath labels and errors in admin forms.
Thanks Sarah Boyce and Jacob Walls for reviews.
Co-authored-by: Hrushikesh Vaidya <hrushikeshrv@gmail.com>
Diffstat (limited to 'tests/auth_tests/test_templates.py')
| -rw-r--r-- | tests/auth_tests/test_templates.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auth_tests/test_templates.py b/tests/auth_tests/test_templates.py index edde6ca6b4..775409af59 100644 --- a/tests/auth_tests/test_templates.py +++ b/tests/auth_tests/test_templates.py @@ -37,6 +37,20 @@ class AuthTemplateTests(TestCase): ) self.assertContains(response, "<h1>Password reset</h1>") + def test_password_reset_view_error_form(self): + response = self.client.post(reverse("password_reset"), {}) + self.assertContains( + response, + '<div class="flex-container">' + '<label for="id_email">Email address:</label>' + '<ul class="errorlist" id="id_email_error">' + "<li>This field is required.</li></ul>" + '<input type="email" name="email" autocomplete="email" maxlength="254" ' + 'required aria-invalid="true" aria-describedby="id_email_error" ' + 'id="id_email"></div>', + html=True, + ) + def test_password_reset_view_error_title(self): response = self.client.post(reverse("password_reset"), {}) self.assertContains( @@ -96,6 +110,38 @@ class AuthTemplateTests(TestCase): response, "<title>Error: Enter new password | Django site admin</title>" ) + def test_password_reset_confirm_view_error_form(self): + client = PasswordResetConfirmClient() + default_token_generator = PasswordResetTokenGenerator() + token = default_token_generator.make_token(self.user) + uidb64 = urlsafe_base64_encode(str(self.user.pk).encode()) + url = reverse( + "password_reset_confirm", kwargs={"uidb64": uidb64, "token": token} + ) + response = client.post(url, {}) + self.assertContains( + response, + '<div class="flex-container errors">' + '<label for="id_new_password1">New password:</label>' + '<ul class="errorlist" id="id_new_password1_error">' + "<li>This field is required.</li></ul>" + '<input type="password" name="new_password1" autocomplete="new-password" ' + 'required aria-invalid="true" aria-describedby="id_new_password1_error" ' + 'id="id_new_password1"></div>', + html=True, + ) + self.assertContains( + response, + '<div class="flex-container errors">' + '<label for="id_new_password2">Confirm password:</label>' + '<ul class="errorlist" id="id_new_password2_error">' + "<li>This field is required.</li></ul>" + '<input type="password" name="new_password2" autocomplete="new-password" ' + 'required aria-invalid="true" aria-describedby="id_new_password2_helptext ' + 'id_new_password2_error" id="id_new_password2"></div>', + html=True, + ) + @override_settings(AUTH_USER_MODEL="auth_tests.CustomUser") def test_password_reset_confirm_view_custom_username_hint(self): custom_user = CustomUser.custom_objects.create_user( |
