"""Tests for homepage and entry-point routes."""

import pytest


@pytest.mark.integration
class TestPageRendering:
    """Verify entry-point routes return working pages."""

    def test_root_redirects_to_ui(self, app_client):
        """GET / redirects to the UI mount point."""
        _, client = app_client
        response = client.get("/", follow_redirects=False)

        assert response.status_code == 307
        assert response.headers["location"] == "/ui/homepage"

    def test_ui_redirects_to_homepage(self, app_client):
        """GET /ui redirects to the homepage."""
        _, client = app_client
        response = client.get("/ui", follow_redirects=False)

        assert response.status_code == 307
        assert response.headers["location"] == "/ui/homepage"

    def test_homepage_page_renders(self, app_client):
        """GET /ui/homepage renders the homepage page."""
        _, client = app_client
        response = client.get("/ui/homepage")

        assert response.status_code == 200
        assert "Home" in response.text
        assert "Edit Home Page" in response.text
        assert '/homepage' in response.text

    def test_homepage_edit_page_renders(self, app_client):
        """GET /ui/homepage/edit renders the edit page."""
        _, client = app_client
        response = client.get("/ui/homepage/edit")

        assert response.status_code == 200
        assert "Edit Home Page" in response.text
        assert "Homepage markdown" in response.text

