"""REQ-106: consumer guide documents per-env caller workflows."""
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
GUIDE = ROOT / "docs" / "consumer-guide.md"


def test_consumer_guide_has_per_env_section():
    text = GUIDE.read_text()
    assert "Per-environment deployment" in text
    assert "promotion-without-editing" in text.lower() or "promotion = running the matching job" in text.lower()


def test_consumer_guide_has_four_caller_examples():
    text = GUIDE.read_text()
    assert "deploy-dev" in text
    assert "deploy-qa" in text
    assert "deploy-prod" in text
    assert "deploy-dr" in text


def test_consumer_guide_documents_environment_input():
    text = GUIDE.read_text()
    assert "environment" in text
    assert "workflow input" in text.lower() or "workflow_call" in text.lower() or "environment:" in text


def test_consumer_guide_documents_hitl_gates():
    text = GUIDE.read_text()
    assert "approve_qa" in text
    assert "approve_prod" in text
    assert "approve_dr" in text
    assert "separation-of-duties" in text.lower() or "separation of duties" in text.lower()


def test_consumer_guide_has_interpolation_reference():
    text = GUIDE.read_text()
    assert "${env.environment}" in text
    assert "${env.account_id}" in text
    # P57: contract.module was dropped in favor of contract.id (short acronym)
    assert "${contract.id}" in text
    # The old token must not survive the P57 contract redesign
    assert "${contract.module}" not in text


def test_consumer_guide_states_no_field_editing():
    text = GUIDE.read_text()
    assert "no" in text.lower() and "environment" in text.lower() and "editing" in text.lower()