"""Pytest fixtures for summarization infrastructure tests.

Provides shared helpers for creating test segments and mock LLM responses.
Common fixtures like `meeting_id` are inherited from tests/conftest.py.
"""

from __future__ import annotations

import json
from typing import Any

import pytest

from noteflow.domain.entities import Segment


def create_test_segment(
    segment_id: int,
    text: str,
    start: float = 0.0,
    end: float = 5.0,
) -> Segment:
    """Create a test segment with default timing values.

    Args:
        segment_id: Unique segment identifier.
        text: Transcript text content.
        start: Start time in seconds (default 0.0).
        end: End time in seconds (default 5.0).

    Returns:
        Segment instance for testing.
    """
    return Segment(
        segment_id=segment_id,
        text=text,
        start_time=start,
        end_time=end,
    )


def build_valid_json_response(
    summary: str = "Test summary.",
    key_points: list[dict[str, Any]] | None = None,
    action_items: list[dict[str, Any]] | None = None,
) -> str:
    """Build a valid JSON response string for LLM mock responses.

    Args:
        summary: Executive summary text.
        key_points: List of key point dictionaries with text and segment_ids.
        action_items: List of action item dictionaries.

    Returns:
        JSON-encoded response string matching expected LLM output format.
    """
    return json.dumps(
        {
            "executive_summary": summary,
            "key_points": key_points or [],
            "action_items": action_items or [],
        }
    )


@pytest.fixture
def test_segment() -> Segment:
    """Provide a single test segment for simple tests."""
    return create_test_segment(0, "Test segment text.")


@pytest.fixture
def test_segments() -> list[Segment]:
    """Provide a sequence of test segments for multi-segment tests."""
    return [
        create_test_segment(0, "First segment text.", 0.0, 5.0),
        create_test_segment(1, "Second segment text.", 5.0, 10.0),
        create_test_segment(2, "Third segment text.", 10.0, 15.0),
    ]
