"""E2E tests for RSS feed, sitemap, and robots.txt.""" from __future__ import annotations import pytest from playwright.sync_api import Page @pytest.mark.e2e def test_rss_feed_returns_valid_xml(page: Page, base_url: str) -> None: response = page.goto(f"{base_url}/feed/", wait_until="networkidle") assert response is not None assert response.status == 200 content = page.content() assert " None: response = page.goto(f"{base_url}/feed/", wait_until="networkidle") assert response is not None and response.status == 200 content = page.content() assert "Nightly Playwright Journey" in content, "Seeded article title must appear in the feed" @pytest.mark.e2e def test_sitemap_returns_valid_xml(page: Page, base_url: str) -> None: response = page.goto(f"{base_url}/sitemap.xml", wait_until="networkidle") assert response is not None assert response.status == 200 content = page.content() assert "urlset" in content or "<urlset" in content, "Sitemap must contain urlset element" @pytest.mark.e2e def test_sitemap_contains_article_url(page: Page, base_url: str) -> None: response = page.goto(f"{base_url}/sitemap.xml", wait_until="networkidle") assert response is not None and response.status == 200 content = page.content() assert "nightly-playwright-journey" in content, "Seeded article URL must appear in sitemap" @pytest.mark.e2e def test_robots_txt_is_accessible(page: Page, base_url: str) -> None: response = page.goto(f"{base_url}/robots.txt", wait_until="networkidle") assert response is not None assert response.status == 200 content = page.content() assert "User-agent" in content, "robots.txt must contain User-agent directive" @pytest.mark.e2e def test_tag_rss_feed(page: Page, base_url: str) -> None: """Tag-specific feed must return 200 and valid XML for a seeded tag.""" response = page.goto(f"{base_url}/feed/tag/ai-tools/", wait_until="networkidle") assert response is not None assert response.status == 200 content = page.content() assert "