from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def read(path: str) -> str:
    return (ROOT / path).read_text(encoding="utf-8")


def test_customer_mismatch_warning_no_longer_blocks_by_name():
    admin = read("app/admin_dashboard.py")

    assert "def opportunity_customer_mismatch" in admin
    assert "return False" in admin
    assert "Nome de contacto ≠ cliente fiscal não é um erro fiável" in admin
    assert "Atenção: contacto e cliente fiscal não coincidem" not in admin


def test_customer_mismatch_setting_remains_accepted_for_env_compatibility():
    config = read("app/config.py")
    assert "clientflow_customer_mismatch_warning_enabled" in config
    assert "clientflow_customer_mismatch_warning_enabled: bool = False" in config
