Skip to content

Commit

Permalink
Update BE tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albinazs committed Sep 25, 2024
1 parent 87b4ef1 commit aad183c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion wagtail/admin/tests/test_account_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def post_form(self, extra_post_data):
"locale-current_time_zone": "Europe/London",
"theme-theme": "dark",
"theme-density": "default",
"theme-contrast": "default",
}
post_data.update(extra_post_data)
return self.client.post(reverse("wagtailadmin_account"), post_data)
Expand Down Expand Up @@ -480,7 +481,7 @@ def test_change_language_preferences(self):
response = self.client.get(reverse("wagtailadmin_home"))
self.assertContains(
response,
'<html lang="es" dir="ltr" class="w-theme-dark w-density-default">',
'<html lang="es" dir="ltr" class="w-theme-dark w-density-default w-contrast-default">',
)

def test_unset_language_preferences(self):
Expand Down Expand Up @@ -610,6 +611,21 @@ def test_change_theme_post(self):

self.assertEqual(profile.theme, "light")

def test_change_contrast_post(self):
response = self.post_form(
{
"theme-contrast": "high_contrast",
}
)

# Check that the user was redirected to the account page
self.assertRedirects(response, reverse("wagtailadmin_account"))

profile = UserProfile.get_for_user(self.user)
profile.refresh_from_db()

self.assertEqual(profile.contrast, "high_contrast")

def test_change_density_post(self):
response = self.post_form(
{
Expand Down
4 changes: 2 additions & 2 deletions wagtail/admin/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def test_language_code(self):
response = self.client.get(reverse("wagtailadmin_login"))
self.assertContains(
response,
'<html lang="de" dir="ltr" class="w-theme-system w-density-default">',
'<html lang="de" dir="ltr" class="w-theme-system w-density-default w-contrast-default">',
)

@override_settings(LANGUAGE_CODE="he")
def test_bidi_language_changes_dir_attribute(self):
response = self.client.get(reverse("wagtailadmin_login"))
self.assertContains(
response,
'<html lang="he" dir="rtl" class="w-theme-system w-density-default">',
'<html lang="he" dir="rtl" class="w-theme-system w-density-default w-contrast-default">',
)

@override_settings(
Expand Down

0 comments on commit aad183c

Please sign in to comment.