"""Tests for the Market Score methodology page."""


async def test_en_returns_200(client):
    resp = await client.get("/en/market-score")
    assert resp.status_code == 200
    text = await resp.get_data(as_text=True)
    assert "Market Score" in text
    assert "padelnomics" in text


async def test_de_returns_200(client):
    resp = await client.get("/de/market-score")
    assert resp.status_code == 200
    text = await resp.get_data(as_text=True)
    assert "Market Score" in text
    assert "padelnomics" in text


async def test_legacy_redirect(client):
    resp = await client.get("/market-score")
    assert resp.status_code == 301
    assert resp.headers["Location"].endswith("/en/market-score")


async def test_contains_jsonld(client):
    resp = await client.get("/en/market-score")
    text = await resp.get_data(as_text=True)
    assert '"@type": "WebPage"' in text
    assert '"@type": "FAQPage"' in text
    assert '"@type": "BreadcrumbList"' in text


async def test_contains_faq_section(client):
    resp = await client.get("/en/market-score")
    text = await resp.get_data(as_text=True)
    assert "Frequently Asked Questions" in text
    assert "<details" in text


async def test_de_contains_faq_section(client):
    resp = await client.get("/de/market-score")
    text = await resp.get_data(as_text=True)
    assert "Häufig gestellte Fragen" in text


async def test_contains_og_tags(client):
    resp = await client.get("/en/market-score")
    text = await resp.get_data(as_text=True)
    assert 'og:title' in text
    assert 'og:description' in text


async def test_footer_has_market_score_link(client):
    resp = await client.get("/en/market-score")
    text = await resp.get_data(as_text=True)
    assert "/en/market-score" in text
    # Footer should link to market score page
    assert "Market Score" in text
