fix: modify email header test and email header html to support indicators

This commit is contained in:
Shrihari Mahabal 2026-02-05 19:12:25 +05:30
parent dc7582f29c
commit 612e02da02
4 changed files with 9 additions and 47 deletions

View file

@ -160,8 +160,9 @@ w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
content=email_html,
header=["Email Title", "green"],
).as_string()
# REDESIGN-TODO: Add style for indicators in email
self.assertTrue("""<span class=3D"indicator indicator-green"></span>""" in email_string)
# REDESIGN: Add style for indicators in email
self.assertIn("indicator", email_string)
self.assertIn("indicator-green", email_string)
self.assertTrue("<span>Email Title</span>" in email_string)
self.assertIn(
"Subject: Test Subject, with line break, and Line feed and carriage return.", email_string

View file

@ -439,22 +439,22 @@ blockquote {
vertical-align: middle;
}
.indicator.red {
.indicator-red {
background-color: #dc2626;
}
.indicator.green {
.indicator-green {
background-color: #16a34a;
}
.indicator.orange {
.indicator-orange {
background-color: #ea580c;
}
.indicator.blue {
.indicator-blue {
background-color: #2563eb;
}
.indicator.gray {
.indicator-gray {
background-color: #6b7280;
}

View file

@ -3,7 +3,7 @@
<td>
<h1 class="email-header-title">
{% if indicator %}
<span class="indicator indicator-{{ indicator }} {{ indicator }}"></span>
<span class="indicator indicator-{{indicator}}"></span>
{% endif %}
<span>{{ header_title }}</span>
</h1>

View file

@ -335,45 +335,6 @@ class TestEmail(IntegrationTestCase):
# Cleanup
frappe.db.delete("User", {"email": target_user})
def test_email_header_indicator(self):
frappe.sendmail(
recipients=["test@example.com"],
subject="Indicator Test",
header=["Status", "red"],
message="Hello",
)
email_queue = frappe.db.get_value(
"Email Queue",
{"status": "Not Sent"},
"name",
)
self.assertTrue(email_queue)
from frappe.email.queue import flush
flush()
raw = frappe.db.get_value(
"Email Queue",
{"status": "Sent"},
"message",
)
import email
msg = email.message_from_string(frappe.safe_decode(raw))
html = None
for part in msg.walk():
if part.get_content_type() == "text/html":
html = part.get_payload(decode=True).decode()
break
self.assertIsNotNone(html)
self.assertIn('class="indicator', html)
self.assertIn("background-color:#dc2626", html)
class TestVerifiedRequests(IntegrationTestCase):
def test_round_trip(self):