"""Tests for prompt content: QA checklist and efficiency rules."""

from pathlib import Path

import pytest

PROMPT_PATH = Path(__file__).resolve().parents[2] / "src" / "godotiq" / "prompts" / "godot_development_prompt_v2.md"


@pytest.fixture
def prompt_text():
    """Load the prompt file as a string."""
    return PROMPT_PATH.read_text(encoding="utf-8")


class TestQAChecklist:
    """Verify QA checklist section exists with required content."""

    def test_prompt_is_loadable(self, prompt_text):
        assert len(prompt_text) > 0

    def test_qa_section_exists(self, prompt_text):
        assert "MANDATORY: Final QA" in prompt_text

    def test_qa_contains_spatial_audit(self, prompt_text):
        assert "spatial_audit" in prompt_text

    def test_qa_contains_cannot_see_constraint(self, prompt_text):
        assert "CANNOT see" in prompt_text or "NEVER say" in prompt_text

    def test_qa_after_creation_workflow(self, prompt_text):
        assert prompt_text.index("MANDATORY: Final QA") > prompt_text.index("Creation Workflow")

    def test_qa_before_token_efficiency(self, prompt_text):
        assert prompt_text.index("MANDATORY: Final QA") < prompt_text.index("Token Efficiency")


class TestEfficiencyRules:
    """Verify efficiency rules section exists with required content."""

    def test_efficiency_section_exists(self, prompt_text):
        assert "Efficiency Rules" in prompt_text

    def test_contains_dont_overthink(self, prompt_text):
        assert "overthink" in prompt_text.lower()

    def test_contains_batch_operations(self, prompt_text):
        assert "Batch operations" in prompt_text

    def test_contains_editor_state_reference(self, prompt_text):
        assert "_editor_state" in prompt_text

    def test_contains_dont_repeat(self, prompt_text):
        assert "repeat tool calls" in prompt_text.lower()

    def test_efficiency_before_mandatory_workflows(self, prompt_text):
        assert prompt_text.index("Efficiency Rules") < prompt_text.index("Mandatory Workflows")
