# #region Test.TypeProfiles [C:3] [TYPE Module] [SEMANTICS test,report,type,profile,mapping]
# @BRIEF Tests for services/reports/type_profiles.py — resolve_task_type, get_type_profile.
# @RELATION BINDS_TO -> [type_profiles]

from pathlib import Path
import sys

sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))

import pytest


# #region test_resolve_task_type [C:2] [TYPE Function]
# @BRIEF Test resolve_task_type for known/unknown plugin IDs.
class TestResolveTaskType:
    def test_known_plugin_id(self):
        from src.services.reports.type_profiles import resolve_task_type
        from src.models.report import TaskType
        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
        assert resolve_task_type("clean-release-compliance") == TaskType.CLEAN_RELEASE
        assert resolve_task_type("clean_release_compliance") == TaskType.CLEAN_RELEASE

    def test_unknown_plugin_id_returns_unknown(self):
        from src.services.reports.type_profiles import resolve_task_type
        from src.models.report import TaskType
        assert resolve_task_type("unknown-plugin") == TaskType.UNKNOWN

    def test_empty_plugin_id_returns_unknown(self):
        from src.services.reports.type_profiles import resolve_task_type
        from src.models.report import TaskType
        assert resolve_task_type("") == TaskType.UNKNOWN

    def test_none_plugin_id_returns_unknown(self):
        from src.services.reports.type_profiles import resolve_task_type
        from src.models.report import TaskType
        assert resolve_task_type(None) == TaskType.UNKNOWN

    def test_whitespace_plugin_id_returns_unknown(self):
        from src.services.reports.type_profiles import resolve_task_type
        from src.models.report import TaskType
        assert resolve_task_type("  ") == TaskType.UNKNOWN
# #endregion test_resolve_task_type


# #region test_get_type_profile [C:2] [TYPE Function]
# @BRIEF Test get_type_profile returns correct profile dicts.
class TestGetTypeProfile:
    def test_known_type_returns_profile(self):
        from src.services.reports.type_profiles import get_type_profile
        from src.models.report import TaskType
        profile = get_type_profile(TaskType.MIGRATION)
        assert profile["display_label"] == "Migration"
        assert profile["icon_token"] == "shuffle"
        assert profile["fallback"] is False

    def test_unknown_type_returns_fallback(self):
        from src.services.reports.type_profiles import get_type_profile, TASK_TYPE_PROFILES
        from src.models.report import TaskType
        profile = get_type_profile(TaskType.UNKNOWN)
        assert profile["fallback"] is True
        assert profile["display_label"] == "Other / Unknown"

    def test_every_type_has_profile(self):
        from src.services.reports.type_profiles import get_type_profile
        from src.models.report import TaskType
        for task_type in TaskType:
            profile = get_type_profile(task_type)
            assert "display_label" in profile
            assert "icon_token" in profile
            assert "emphasis_rules" in profile
            assert "visual_variant" in profile
# #endregion test_get_type_profile
# #endregion Test.TypeProfiles
