# region __tests__/test_report_type_profiles [TYPE Module]
# @RELATION  BINDS_TO -> ../type_profiles.py
# @PURPOSE: Contract testing for task type profiles and resolution logic.
# endregion __tests__/test_report_type_profiles

from src.models.report import TaskType
from src.services.reports.type_profiles import get_type_profile, resolve_task_type


# @TEST_CONTRACT  ResolveTaskType -> Invariants
# @TEST_INVARIANT  fallback_to_unknown
# region test_resolve_task_type_fallbacks [TYPE Function]
# @RELATION  BINDS_TO -> __tests__/test_report_type_profiles
# @PURPOSE: Verify resolve_task_type_fallbacks returns correct fallback type when primary is missing.
def test_resolve_task_type_fallbacks():
    """Verify missing/unmapped plugin_id returns TaskType.UNKNOWN."""
    assert resolve_task_type(None) == TaskType.UNKNOWN
    assert resolve_task_type("") == TaskType.UNKNOWN
    assert resolve_task_type("   ") == TaskType.UNKNOWN
    assert resolve_task_type("invalid_plugin") == TaskType.UNKNOWN

# @TEST_FIXTURE  valid_plugin
# endregion test_resolve_task_type_fallbacks

# region test_resolve_task_type_valid [TYPE Function]
# @RELATION  BINDS_TO -> __tests__/test_report_type_profiles
# @PURPOSE: Verify resolve_task_type_valid returns the correct type when valid input is provided.
def test_resolve_task_type_valid():
    """Verify known plugin IDs map correctly."""
    assert resolve_task_type("superset-migration") == TaskType.MIGRATION
    assert resolve_task_type("llm_dashboard_validation") == TaskType.LLM_VERIFICATION
    assert resolve_task_type("superset-backup") == TaskType.BACKUP
    assert resolve_task_type("documentation") == TaskType.DOCUMENTATION

# @TEST_FIXTURE  valid_profile
# endregion test_resolve_task_type_valid

# region test_get_type_profile_valid [TYPE Function]
# @RELATION  BINDS_TO -> __tests__/test_report_type_profiles
# @PURPOSE: Verify get_type_profile_valid returns the correct profile for a valid task type.
def test_get_type_profile_valid():
    """Verify known task types return correct profile metadata."""
    profile = get_type_profile(TaskType.MIGRATION)
    assert profile["display_label"] == "Migration"
    assert profile["visual_variant"] == "migration"
    assert profile["fallback"] is False

# @TEST_INVARIANT  always_returns_dict
# @TEST_EDGE  missing_profile
# endregion test_get_type_profile_valid

# region test_get_type_profile_fallback [TYPE Function]
# @RELATION  BINDS_TO -> __tests__/test_report_type_profiles
# @PURPOSE: Verify get_type_profile_fallback returns default profile when type is unknown.
def test_get_type_profile_fallback():
    """Verify unknown task type returns fallback profile."""
    # Assuming TaskType.UNKNOWN or any non-mapped value
    profile = get_type_profile(TaskType.UNKNOWN)
    assert profile["display_label"] == "Other / Unknown"
    assert profile["fallback"] is True

    # Passing a value that might not be in the dict explicitly
    profile_fallback = get_type_profile("non-enum-value")
    assert profile_fallback["display_label"] == "Other / Unknown"
    assert profile_fallback["fallback"] is True
# endregion test_get_type_profile_fallback
