From 612e02da02413aea7c2068e243a6b562a71edfcb Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Thu, 5 Feb 2026 19:12:25 +0530 Subject: [PATCH] fix: modify email header test and email header html to support indicators --- frappe/email/test_email_body.py | 5 +-- frappe/public/scss/email.bundle.scss | 10 +++--- frappe/templates/emails/email_header.html | 2 +- frappe/tests/test_email.py | 39 ----------------------- 4 files changed, 9 insertions(+), 47 deletions(-) diff --git a/frappe/email/test_email_body.py b/frappe/email/test_email_body.py index 901d755942..2152c50917 100644 --- a/frappe/email/test_email_body.py +++ b/frappe/email/test_email_body.py @@ -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("""""" in email_string) + # REDESIGN: Add style for indicators in email + self.assertIn("indicator", email_string) + self.assertIn("indicator-green", email_string) self.assertTrue("Email Title" in email_string) self.assertIn( "Subject: Test Subject, with line break, and Line feed and carriage return.", email_string diff --git a/frappe/public/scss/email.bundle.scss b/frappe/public/scss/email.bundle.scss index 0f3b0e2761..49995c4dbc 100644 --- a/frappe/public/scss/email.bundle.scss +++ b/frappe/public/scss/email.bundle.scss @@ -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; } diff --git a/frappe/templates/emails/email_header.html b/frappe/templates/emails/email_header.html index cb327a52b8..05c250a51f 100644 --- a/frappe/templates/emails/email_header.html +++ b/frappe/templates/emails/email_header.html @@ -3,7 +3,7 @@

{% if indicator %} - + {% endif %} {{ header_title }}

diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index 50252ee4ff..dedb3ab5b0 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -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):