def test_e2e_homepage_renders_hero_feed_and_modal_shell(client, seeded_news):
    response = client.get("/")
    assert response.status_code == 200
    html = response.text
    assert 'x-data="heroBlock()"' in html
    assert 'x-data="newsFeed()"' in html
    assert 'aria-label="Article summary"' in html


def test_e2e_api_hero_and_feed_journey(client, seeded_news):
    latest = client.get("/api/news/latest?language=en")
    assert latest.status_code == 200
    latest_payload = latest.json()
    assert latest_payload["id"] == seeded_news

    feed = client.get("/api/news?limit=10&language=en")
    assert feed.status_code == 200
    items = feed.json()["items"]
    assert len(items) >= 1
    assert items[0]["id"] == seeded_news


def test_e2e_permalink_and_share_hooks_present(client):
    response = client.get("/")
    html = response.text
    assert "function articlePermalink(item)" in html
    assert "function getPermalinkArticleId()" in html
    assert "shareLink('x', modalItem)" in html
    assert "shareLink('whatsapp', modalItem)" in html
    assert "shareLink('linkedin', modalItem)" in html
