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:
@@ -44,7 +44,7 @@ jobs:
|
||||
run: docker run --rm --network container:ci-postgres -e SECRET_KEY=ci-secret-key -e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype "$CI_IMAGE" mypy apps config
|
||||
|
||||
- name: Pytest
|
||||
run: docker run --rm --network container:ci-postgres -e SECRET_KEY=ci-secret-key -e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype "$CI_IMAGE" pytest
|
||||
run: docker run --rm --network container:ci-postgres -e SECRET_KEY=ci-secret-key -e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype "$CI_IMAGE" pytest --ignore=e2e
|
||||
|
||||
- name: Tailwind build (assert generated diff is clean)
|
||||
run: |
|
||||
@@ -67,6 +67,71 @@ jobs:
|
||||
if: always()
|
||||
run: docker image rm -f "$CI_IMAGE" || true
|
||||
|
||||
pr-e2e:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CI_IMAGE: nohype-ci-e2e:${{ github.run_id }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
run: docker build -t "$CI_IMAGE" .
|
||||
|
||||
- name: Start PostgreSQL
|
||||
run: |
|
||||
docker run -d --name pr-e2e-postgres \
|
||||
-e POSTGRES_DB=nohype \
|
||||
-e POSTGRES_USER=nohype \
|
||||
-e POSTGRES_PASSWORD=nohype \
|
||||
postgres:16-alpine
|
||||
for i in $(seq 1 30); do
|
||||
if docker exec pr-e2e-postgres pg_isready -U nohype -d nohype >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
docker logs pr-e2e-postgres || true
|
||||
exit 1
|
||||
|
||||
- name: Start app with seeded content
|
||||
run: |
|
||||
docker run -d --name pr-e2e-app --network container:pr-e2e-postgres \
|
||||
-e SECRET_KEY=ci-secret-key \
|
||||
-e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \
|
||||
-e CONSENT_POLICY_VERSION=1 \
|
||||
-e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \
|
||||
-e DEFAULT_FROM_EMAIL=hello@nohypeai.com \
|
||||
-e NEWSLETTER_PROVIDER=buttondown \
|
||||
"$CI_IMAGE" \
|
||||
sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000"
|
||||
for i in $(seq 1 40); do
|
||||
if docker exec pr-e2e-app curl -fsS http://127.0.0.1:8000/ >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
docker logs pr-e2e-app || true
|
||||
exit 1
|
||||
|
||||
- name: Install Playwright browsers
|
||||
run: docker exec pr-e2e-app python -m playwright install chromium
|
||||
|
||||
- name: Run E2E tests
|
||||
run: |
|
||||
docker exec -e E2E_BASE_URL=http://127.0.0.1:8000 pr-e2e-app \
|
||||
pytest e2e/ -o addopts='' -q --tb=short
|
||||
|
||||
- name: Remove containers
|
||||
if: always()
|
||||
run: |
|
||||
docker rm -f pr-e2e-app || true
|
||||
docker rm -f pr-e2e-postgres || true
|
||||
|
||||
- name: Remove CI image
|
||||
if: always()
|
||||
run: docker image rm -f "$CI_IMAGE" || true
|
||||
|
||||
nightly-e2e:
|
||||
if: github.event_name == 'schedule'
|
||||
runs-on: ubuntu-latest
|
||||
@@ -96,6 +161,10 @@ jobs:
|
||||
docker run -d --name nightly-e2e --network container:nightly-postgres \
|
||||
-e SECRET_KEY=ci-secret-key \
|
||||
-e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \
|
||||
-e CONSENT_POLICY_VERSION=1 \
|
||||
-e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \
|
||||
-e DEFAULT_FROM_EMAIL=hello@nohypeai.com \
|
||||
-e NEWSLETTER_PROVIDER=buttondown \
|
||||
"$CI_IMAGE" \
|
||||
sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000"
|
||||
for i in $(seq 1 40); do
|
||||
@@ -106,11 +175,11 @@ jobs:
|
||||
done
|
||||
docker logs nightly-e2e || true
|
||||
exit 1
|
||||
- name: Run nightly Playwright journey
|
||||
- name: Run Playwright E2E tests
|
||||
run: |
|
||||
docker exec nightly-e2e python -m playwright install chromium
|
||||
docker exec -e E2E_BASE_URL=http://127.0.0.1:8000 nightly-e2e \
|
||||
pytest -o addopts='' apps/core/tests/test_nightly_e2e_playwright.py -q
|
||||
pytest e2e/ apps/core/tests/test_nightly_e2e_playwright.py -o addopts='' -q --tb=short
|
||||
- name: Remove nightly container
|
||||
if: always()
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user