from pathlib import Path def test_assisted_identity_skips_duplicate_current_customer_suggestion(): source = Path("app/fiscal_enrichment_service.py").read_text() assert "email_identity_matches_current_fiscal_customer" in source assert "suggested_customer_id == linked_customer_id" in source assert '"suggested": 0' in source def test_customer_detail_has_create_opportunity_flow(): source = Path("app/admin_ui/pages/customers.py").read_text() assert "/customers/{customer_id}/opportunities/create" in source assert "create_manual_opportunity_from_customer" in source assert "Criar oportunidade" in source def test_manual_opportunity_command_links_customer_and_optional_task(): source = Path("app/opportunity_service.py").read_text() assert "def create_manual_opportunity_from_customer" in source assert "local_customer_id" in source assert "created_from_customer_page" in source assert "manual_opportunity_created" in source assert "created_from_manual_opportunity" in source def test_duplicate_identity_metadata_jsonb_parameters_are_cast_to_text(): source = Path("app/fiscal_enrichment_service.py").read_text() assert "CAST(:customer_id AS TEXT)" in source assert "CAST(:customer_name AS TEXT)" in source assert "CAST(:customer_tax_id AS TEXT)" in source