"""task-1085.1: InsuRo 사이드바 간격 최적화 테스트

AppSidebar.tsx의 간격 최적화가 올바르게 적용되었는지 검증합니다.
"""

import re
from pathlib import Path

import pytest

SIDEBAR_FILE = Path("/home/jay/projects/InsuRo/src/components/AppSidebar.tsx")


class TestSidebarSpacingOptimization:
    """사이드바 간격 최적화 테스트."""

    @pytest.fixture
    def sidebar_content(self) -> str:
        """AppSidebar.tsx 파일 내용 로드."""
        if not SIDEBAR_FILE.exists():
            pytest.skip(f"파일 없음: {SIDEBAR_FILE}")
        return SIDEBAR_FILE.read_text(encoding="utf-8")

    def test_navigation_item_spacing_reduced(self, sidebar_content: str) -> None:
        """네비게이션 아이템 간격이 최적화되어야 함."""
        # px-3 py-1.5 gap-2 패턴 확인
        assert "px-3" in sidebar_content
        assert "py-1.5" in sidebar_content or "py-2.5" in sidebar_content
        assert "gap-2" in sidebar_content

    def test_user_profile_spacing_reduced(self, sidebar_content: str) -> None:
        """사용자 프로필 카드 간격이 최적화되어야 함."""
        assert "gap-2.5" in sidebar_content or "gap-2" in sidebar_content

    def test_file_exists(self) -> None:
        """파일이 존재해야 함."""
        assert SIDEBAR_FILE.exists(), f"파일 없음: {SIDEBAR_FILE}"

    def test_file_not_empty(self, sidebar_content: str) -> None:
        """파일이 비어있지 않아야 함."""
        assert len(sidebar_content) > 0, "파일이 비어있음"

    def test_has_tailwind_classes(self, sidebar_content: str) -> None:
        """Tailwind 클래스가 있어야 함."""
        tailwind_classes = ["flex", "items-center", "rounded", "gap-"]
        has_tailwind = any(cls in sidebar_content for cls in tailwind_classes)
        assert has_tailwind, "Tailwind 클래스 없음"
