test: add e2e tests for all 9 email handlers (54 tests)
Mock send_email and call each handler directly. Covers recipient,
subject content, HTML design elements (wordmark, preheader, heat
badges), from_addr, skip-on-missing-data guards, and email_sent_at
timestamp updates.
Also fixes IndexError in handle_send_welcome when payload has no name
("".split()[0] → safe fallback).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -298,7 +298,8 @@ async def handle_send_quote_verification(payload: dict) -> None:
|
||||
async def handle_send_welcome(payload: dict) -> None:
|
||||
"""Send welcome email to new user."""
|
||||
lang = payload.get("lang", "en")
|
||||
first_name = (payload.get("name") or "").split()[0] or "there"
|
||||
name_parts = (payload.get("name") or "").split()
|
||||
first_name = name_parts[0] if name_parts else "there"
|
||||
|
||||
body = (
|
||||
f'<h2 style="margin:0 0 8px;color:#0F172A;font-size:22px;">{_t("email_welcome_heading", lang, app_name=config.APP_NAME)}</h2>'
|
||||
|
||||
Reference in New Issue
Block a user