feat: comprehensive Playwright E2E test suite #7

Merged
mark merged 3 commits from tests/e2e into main 2026-02-28 20:25:30 +00:00
Owner

What

Adds a full Playwright E2E test suite in e2e/ covering all key user journeys, wired into CI so every PR runs it.

Tests added (e2e/)

Module Scenarios
test_home.py Page title, nav links (Home/Articles/About), theme toggle, newsletter form
test_cookie_consent.py Banner on first visit, accept all, reject all, granular prefs, persistence across pages
test_articles.py Index loads, AI Tools tag filter, click-through navigation
test_article_detail.py Title/read-time, share section, comments section, newsletter aside, related section, copy-link
test_comments.py Valid submit → redirect with ?commented=1, empty body → errors, disabled check
test_newsletter.py JS confirmation message, invalid email error, article aside form, duplicate handling
test_feeds.py RSS XML validity, sitemap XML, robots.txt, tag-specific feed

Seed content extended

seed_e2e_content now creates tagged article, about page, no-comments article, and legal pages.

CI changes

  • New pr-e2e job (runs on every PR): builds image → starts postgres + app → playwright install → pytest e2e/
  • Nightly job updated to run full e2e/ suite alongside the existing journey test
  • Unit-test pytest step gets --ignore=e2e (browser tests excluded from coverage)

Verified

  • Unit tests: 95.57% coverage ✓
  • ruff clean ✓
## What Adds a full Playwright E2E test suite in `e2e/` covering all key user journeys, wired into CI so every PR runs it. ## Tests added (`e2e/`) | Module | Scenarios | |---|---| | `test_home.py` | Page title, nav links (Home/Articles/About), theme toggle, newsletter form | | `test_cookie_consent.py` | Banner on first visit, accept all, reject all, granular prefs, persistence across pages | | `test_articles.py` | Index loads, AI Tools tag filter, click-through navigation | | `test_article_detail.py` | Title/read-time, share section, comments section, newsletter aside, related section, copy-link | | `test_comments.py` | Valid submit → redirect with `?commented=1`, empty body → errors, disabled check | | `test_newsletter.py` | JS confirmation message, invalid email error, article aside form, duplicate handling | | `test_feeds.py` | RSS XML validity, sitemap XML, robots.txt, tag-specific feed | ## Seed content extended `seed_e2e_content` now creates tagged article, about page, no-comments article, and legal pages. ## CI changes - **New `pr-e2e` job** (runs on every PR): builds image → starts postgres + app → playwright install → `pytest e2e/` - **Nightly job** updated to run full `e2e/` suite alongside the existing journey test - Unit-test pytest step gets `--ignore=e2e` (browser tests excluded from coverage) ## Verified - Unit tests: 95.57% coverage ✓ - `ruff` clean ✓
codex_a added 1 commit 2026-02-28 19:31:12 +00:00
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
9d323d2040
- 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>
codex_a added 1 commit 2026-02-28 19:47:17 +00:00
fix: resolve 5 E2E test failures from first CI run
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 1m32s
4992b0cb9d
- test_homepage_title_contains_brand: to_have_title() requires a string or
  regex, not a lambda; switch to re.compile('No Hype AI')
- test_granular_preferences_save_dismisses_banner: wrong element clicked to
  open <details>; use 'details summary' locator directly
- test_subscribe_invalid_email_shows_error: browser HTML5 email validation
  swallows the submit event before the JS handler fires; add 'novalidate' via
  evaluate() so the fetch still runs and the server returns 400
- test_copy_link_button_updates_text: clipboard API unavailable in headless
  Docker; add polyfill + pre-grant permissions in conftest page fixture so
  the JS success path runs and button text becomes 'Copied'
- test_comments_section_absent_when_disabled: guard against Wagtail's
  add_child() resetting BooleanField defaults by calling an explicit
  .update(comments_enabled=False) + re-setting on the instance before
  save_revision().publish(); also tighten test to assert 200 + correct title

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
codex_a added 1 commit 2026-02-28 20:20:21 +00:00
fix: run E2E tests properly with mounted browsers and real postgres
All checks were successful
CI / nightly-e2e (pull_request) Has been skipped
CI / pr-e2e (pull_request) Successful in 1m33s
CI / ci (pull_request) Successful in 2m18s
f6edcadd46
- Mount /opt/playwright-tools/browsers into web container (docker-compose.yml
  and CI docker run) — never download browsers, use the ones on this host
- Set PLAYWRIGHT_BROWSERS_PATH in all container envs (compose + CI)
- Drop 'playwright install chromium' steps from pr-e2e and nightly-e2e jobs
- Bump playwright requirement to ~1.57.0 to match the installed browser builds
- Fix seed_e2e_content: de-duplicate default Site entries left by unit test
  fixtures so Wagtail always routes to the seeded home page
- Fix test_comments_section_absent_when_disabled: use exact=True on heading
  locator to avoid matching 'No Comments Article' h1 as 'Comments' heading
- Fix test_copy_link_button_updates_text: use [data-copy-link] data-attr
  locator (stable across text change) and force-override clipboard.writeText
  via page.evaluate() rather than relying on init_script polyfill

E2E suite verified locally: 34 passed via docker compose exec

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mark merged commit 96f9eca19d into main 2026-02-28 20:25:30 +00:00
mark deleted branch tests/e2e 2026-02-28 20:25:30 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nohype/main-site#7