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 ") 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