"""Tests for Markdown exporter."""

from __future__ import annotations

from datetime import datetime

from noteflow.domain.entities import ActionItem, KeyPoint, Meeting, Segment, Summary
from noteflow.infrastructure.export.markdown import MarkdownExporter


class TestMarkdownExporter:
    """Tests for MarkdownExporter output."""

    def test_export_includes_sections(self) -> None:
        meeting = Meeting.create(title="Weekly Sync")
        meeting.started_at = datetime(2024, 1, 1, 9, 0, 0)
        meeting.ended_at = datetime(2024, 1, 1, 9, 30, 0)

        segments = [
            Segment(segment_id=0, text="Hello team", start_time=0.0, end_time=1.0),
            Segment(segment_id=1, text="Next steps", start_time=1.0, end_time=2.0),
        ]

        summary = Summary(
            meeting_id=meeting.id,
            executive_summary="Great meeting.",
            key_points=[KeyPoint(text="KP1")],
            action_items=[ActionItem(text="Do thing", assignee="alice")],
        )
        meeting.summary = summary

        exporter = MarkdownExporter()
        output = exporter.export(meeting, segments)

        assert "# Weekly Sync" in output, "output should contain meeting title heading"
        assert "## Meeting Info" in output, "output should contain Meeting Info section"
        assert "## Transcript" in output, "output should contain Transcript section"
        assert "**[0:00]** Hello team" in output, "output should contain timestamped segment"
        assert "## Summary" in output, "output should contain Summary section"
        assert "### Key Points" in output, "output should contain Key Points subsection"
        assert "- KP1" in output, "output should contain key point text"
        assert "### Action Items" in output, "output should contain Action Items subsection"
        assert "- [ ] Do thing (@alice)" in output, "output should contain action item with assignee"
        assert "Exported from NoteFlow" in output, "output should contain NoteFlow footer"
