"""Tests for slide mapping block-to-layout type logic.

Uses a duplicated mapping dict to avoid importing the full service module
(which has heavy transitive deps via google.genai).
Must stay in sync with services/slide_mapping_engine.py.
"""

# Duplicated from models/content_models.py
BLOCK_TYPES = [
    "narrative", "quote", "metric", "table", "timeline",
    "comparison", "list_items", "image_reference", "call_to_action",
]

# Duplicated from services/slide_mapping_engine.py
_BLOCK_TO_LAYOUT_TYPE = {
    "metric": ["metrics", "kpi", "data", "chart", "content"],
    "quote": ["quote", "testimonial", "content"],
    "table": ["table", "chart", "data", "content"],
    "timeline": ["timeline", "process", "content"],
    "comparison": ["comparison", "two_column", "content"],
    "list_items": ["content", "bullet", "list"],
    "narrative": ["content", "text", "description"],
    "image_reference": ["picture", "image", "content"],
    "call_to_action": ["content", "title_slide"],
}


class TestBlockToLayoutMapping:
    def test_all_block_types_have_mappings(self):
        for bt in BLOCK_TYPES:
            assert bt in _BLOCK_TO_LAYOUT_TYPE, (
                f"ContentBlockType.{bt} missing from _BLOCK_TO_LAYOUT_TYPE"
            )

    def test_metric_prefers_metrics_layout(self):
        assert _BLOCK_TO_LAYOUT_TYPE["metric"][0] == "metrics"

    def test_quote_prefers_quote_layout(self):
        assert _BLOCK_TO_LAYOUT_TYPE["quote"][0] == "quote"

    def test_table_prefers_table_layout(self):
        assert _BLOCK_TO_LAYOUT_TYPE["table"][0] == "table"

    def test_timeline_prefers_timeline_layout(self):
        assert _BLOCK_TO_LAYOUT_TYPE["timeline"][0] == "timeline"

    def test_every_mapping_has_content_fallback(self):
        for bt, layouts in _BLOCK_TO_LAYOUT_TYPE.items():
            assert "content" in layouts, (
                f"ContentBlockType.{bt} has no 'content' fallback in layout mapping"
            )
