from __future__ import annotations

from app.api.schemas.service_guide import (
    ServiceGuideExtractPreviewResponse,
    StandardServiceGuideProfile,
)


def test_standard_service_guide_profile_preserves_known_and_future_fields() -> None:
    profile = StandardServiceGuideProfile.model_validate(
        {
            "profile_id": "guide-1",
            "doc_id": "doc-1",
            "matter_name": "办理普通护照",
            "materials": [{"material_name": "居民身份证", "raw_row_text": "居民身份证原件"}],
            "consultation_and_supervision": {"consultation_phones": ["12367"]},
            "experimental_field": {"source": "future"},
        }
    )

    assert profile.profile_id == "guide-1"
    assert profile.materials[0].material_name == "居民身份证"
    assert profile.consultation_and_supervision.consultation_phones == ["12367"]
    assert profile.model_dump()["experimental_field"] == {"source": "future"}


def test_service_guide_extract_preview_response_uses_typed_profile() -> None:
    preview = ServiceGuideExtractPreviewResponse(
        detected=True,
        detection_confidence=0.95,
        profile={
            "profile_id": "guide-2",
            "doc_id": "doc-2",
            "matter_name": "建设用地审批",
            "fees": [{"fee_name": "工本费", "amount_value": 120.0}],
        },
    )

    assert preview.profile is not None
    assert preview.profile.profile_id == "guide-2"
    assert preview.profile.fees[0].fee_name == "工本费"