feat: add comprehensive Playwright E2E test suite
- 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:
@@ -2,7 +2,7 @@ import pytest
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
from apps.blog.models import ArticleIndexPage, ArticlePage
|
||||
from apps.blog.models import AboutPage, ArticleIndexPage, ArticlePage
|
||||
from apps.blog.tests.factories import AuthorFactory
|
||||
|
||||
|
||||
@@ -28,3 +28,29 @@ def test_check_content_integrity_fails_for_blank_summary(home_page):
|
||||
|
||||
with pytest.raises(CommandError, match="empty summary"):
|
||||
call_command("check_content_integrity")
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_seed_e2e_content_creates_expected_pages():
|
||||
call_command("seed_e2e_content")
|
||||
|
||||
assert ArticlePage.objects.filter(slug="nightly-playwright-journey").exists()
|
||||
assert ArticlePage.objects.filter(slug="e2e-tagged-article").exists()
|
||||
assert ArticlePage.objects.filter(slug="e2e-no-comments").exists()
|
||||
assert AboutPage.objects.filter(slug="about").exists()
|
||||
|
||||
# Tagged article must carry the seeded tag
|
||||
tagged = ArticlePage.objects.get(slug="e2e-tagged-article")
|
||||
assert tagged.tags.filter(slug="ai-tools").exists()
|
||||
|
||||
# No-comments article must have comments disabled
|
||||
no_comments = ArticlePage.objects.get(slug="e2e-no-comments")
|
||||
assert no_comments.comments_enabled is False
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_seed_e2e_content_is_idempotent():
|
||||
"""Running the command twice must not raise or create duplicates."""
|
||||
call_command("seed_e2e_content")
|
||||
call_command("seed_e2e_content")
|
||||
assert ArticlePage.objects.filter(slug="nightly-playwright-journey").count() == 1
|
||||
|
||||
Reference in New Issue
Block a user