feat: add comprehensive Playwright E2E test suite
Some checks failed
CI / nightly-e2e (pull_request) Has been skipped
CI / ci (pull_request) Successful in 1m22s
CI / pr-e2e (pull_request) Failing after 3m28s

- Create e2e/ directory with 7 test modules covering:
  - Home page: title, nav links, theme toggle, newsletter form
  - Cookie consent: accept all, reject all, granular prefs, persistence
  - Article index: loads, tag filter, click-through navigation
  - Article detail: title/read-time, share section, comments, newsletter aside, related
  - Comments: valid submit → redirect, empty body → error display, disabled check
  - Newsletter: JS confirmation message, invalid email error, aside form, duplicate
  - Feeds: RSS/sitemap/robots.txt validity, tag feed, seeded content present
- Extend seed_e2e_content management command with tagged article, about page,
  no-comments article, and legal pages for richer test coverage
- Add seed command tests (create + idempotency) to keep coverage ≥ 90%
- Add pr-e2e CI job (runs on pull_request): builds image, starts postgres + app,
  installs playwright, runs pytest e2e/
- Update nightly-e2e to run full e2e/ suite alongside legacy journey test
- Add --ignore=e2e to unit-test pytest step (coverage must not include browser tests)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
codex_a
2026-02-28 19:30:43 +00:00
parent aeb0afb2ea
commit 9d323d2040
12 changed files with 643 additions and 8 deletions

61
e2e/test_feeds.py Normal file
View File

@@ -0,0 +1,61 @@
"""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 "<rss" in content or "<feed" in content or "&lt;rss" in content or "&lt;feed" in content, (
"RSS feed response must contain a <rss or <feed root element"
)
@pytest.mark.e2e
def test_rss_feed_contains_seeded_article(page: Page, base_url: str) -> 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 "&lt;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 "<rss" in content or "<feed" in content or "&lt;rss" in content or "&lt;feed" in content