bmc_hub/tests/test_customer_crm_improvements.py

24 lines
975 B
Python
Raw Normal View History

2026-08-28 20:49:55 +02:00
import re
from pathlib import Path
def test_customer_email_patterns_are_exact():
from app.customers.backend.router import _email_address_pattern, _email_domain_pattern
address = re.compile(_email_address_pattern("info@example.com"))
assert address.search("Info <info@example.com>")
assert not address.search("otherinfo@example.com")
domain = re.compile(_email_domain_pattern("example.com"))
assert domain.search("person@example.com")
assert not domain.search("person@example.com.evil.test")
assert not domain.search("person@notexample.com")
def test_customer_detail_exposes_email_tab_and_supplier_service_checkbox():
template = Path("app/customers/frontend/customer_detail.html").read_text(encoding="utf-8")
assert 'href="#emails"' in template
assert 'id="supplierServiceEnrolled"' in template
assert "supplier_service_enrolled: checkbox.checked" in template
assert "/emails?limit=${customerEmailsLimit}" in template