[damned-lies/yelp-build-traling-slash: 1/2] tests: update render people avatar class
- From: Guillaume Bernard <gbernard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies/yelp-build-traling-slash: 1/2] tests: update render people avatar class
- Date: Fri, 7 Oct 2022 21:56:16 +0000 (UTC)
commit c5c7fa9eecac0a81c772062f200d743fcc66254f
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Thu Oct 6 16:03:40 2022 +0200
tests: update render people avatar class
people/templatetags/people.py | 4 ++-
people/tests.py | 31 +++++++++++++++-------
templates/base.html | 2 +-
templates/login/login_user_menu_small_screens.html | 2 +-
4 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/people/templatetags/people.py b/people/templatetags/people.py
index 340f841b..5163dfdf 100644
--- a/people/templatetags/people.py
+++ b/people/templatetags/people.py
@@ -43,5 +43,7 @@ def people_image(person):
nobody,
)
else:
- tag = format_html('<img class="img-circle" src="{url}" alt="{alt}">', url=nobody, alt=_("generic
person icon"))
+ tag = format_html(
+ '<img class="rounded-circle" src="{url}" alt="{alt}">', url=nobody, alt=_("generic person icon")
+ )
return tag
diff --git a/people/tests.py b/people/tests.py
index 0b54dcd3..f29552c7 100644
--- a/people/tests.py
+++ b/people/tests.py
@@ -5,7 +5,7 @@ from django.contrib import auth
from django.contrib.staticfiles.finders import find
from django.core import mail
from django.core.exceptions import ValidationError
-from django.test import Client, TestCase
+from django.test import Client, TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
from django.utils.safestring import SafeData
@@ -89,11 +89,23 @@ class PeopleTestCase(TestCase):
pn = self._create_person()
self.client.force_login(pn)
response = self.client.get(reverse("home"))
+
+ # There is a dropdown link with the default avatar
self.assertContains(
response,
- '<a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown"
class="dropdown-toggle'
- ' hidden-xs avatar" href="%s"><img class="img-circle" alt="generic person icon"'
- ' src="/static/img/nobody.png"></a>' % (reverse("person_detail_username", args=[pn.username])),
+ '<a id="navbar-user-menu" href="#" class="nav-link px-0 py-0 avatar" role="button" '
+ 'data-bs-toggle="dropdown" aria-expanded="false">'
+ '<img class="rounded-circle" src="/static/img/nobody.png" alt="generic person icon">'
+ "</a>",
+ html=True,
+ )
+
+ # There is a link to access the logged-in user settings
+ self.assertContains(
+ response,
+ '<a class="dropdown-item" href="%s">'
+ "User Settings"
+ "</a>" % reverse("person_detail_username", args=[pn.username]),
html=True,
)
@@ -197,32 +209,33 @@ class PeopleTestCase(TestCase):
pn = self._create_person()
self.assertHTMLEqual(
- people.people_image(pn), '<img class="img-circle" src="/static/img/nobody.png" alt="generic
person icon">'
+ people.people_image(pn),
+ '<img class="rounded-circle" src="/static/img/nobody.png" alt="generic person icon">',
)
pn.image = "http://www.example.org/my_image.png"
self.assertHTMLEqual(
people.people_image(pn),
- '<img class="img-circle" alt="John Nothing" onerror="this.onerror = null; '
+ '<img class="rounded-circle" alt="John Nothing" onerror="this.onerror = null; '
'this.src=\'/static/img/nobody.png\'" src="http://www.example.org/my_image.png" />',
)
pn.last_name = "<script>Some XSS content</script>"
self.assertIn("<script>Some XSS content</script>", people.people_image(pn))
self.assertHTMLEqual(
people.people_image(pn),
- '<img class="img-circle" alt="John <script>Some XSS content</script>" '
+ '<img class="rounded-circle" alt="John <script>Some XSS content</script>" '
"onerror=\"this.onerror = null; this.src='/static/img/nobody.png'\" "
'src="http://www.example.org/my_image.png" />',
)
pn.avatar_service = "gravatar.com"
self.assertHTMLEqual(
people.people_image(pn),
- '<img class="img-circle" alt="avatar icon" crossorigin="anonymous" '
+ '<img class="rounded-circle" alt="avatar icon" crossorigin="anonymous" '
'src="https://secure.gravatar.com/avatar/618b8b6c1c973c780ec218242c49cbe7.jpg?s=80&d=identicon&r=g">',
)
pn.avatar_service = "libravatar.org"
self.assertHTMLEqual(
people.people_image(pn),
- '<img class="img-circle" alt="avatar icon" crossorigin="anonymous" '
+ '<img class="rounded-circle" alt="avatar icon" crossorigin="anonymous" '
'src="https://seccdn.libravatar.org/avatar/618b8b6c1c973c780ec218242c49cbe7?s=80&d=identicon&r=g">',
)
diff --git a/templates/base.html b/templates/base.html
index 67747d77..2d0716e3 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -47,7 +47,7 @@
-->
<div class="navbar navbar-right d-flex no-padding d-block d-lg-none d-xl-none">
<!-- Only logo visible to open popup -->
- <ul class="list-unstyled d-none d-sm-block d-md-block my-0">
+ <ul class="list-unstyled my-0">
<li class="nav-item">
{% include "login/login_user_menu_small_screens.html" %}
</li>
diff --git a/templates/login/login_user_menu_small_screens.html
b/templates/login/login_user_menu_small_screens.html
index 70f9d57a..9934e831 100644
--- a/templates/login/login_user_menu_small_screens.html
+++ b/templates/login/login_user_menu_small_screens.html
@@ -8,7 +8,7 @@
</a>
{% else %}
<a id="navbar-user-menu" href="#"
- class="nav-link dropdown-toggle text-white"
+ class="nav-link px-0 py-0 avatar"
role="button" data-bs-toggle="dropdown" aria-expanded="false">
<img class="rounded-circle" src="{% static 'img/avatar-default.svg' %}"
alt="GNOME - Damned Lies">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]