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

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

# @TEST_CONTRACT: ResolveTaskType -> Invariants
# @TEST_INVARIANT: fallback_to_unknown
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
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
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
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
