Skip to content

chore: Playwright e2e testing + CI (#46) - #49

Merged
acharlop merged 4 commits into
mainfrom
chore/playwright-e2e
Jun 13, 2026
Merged

acharlop merged 4 commits into
mainfrom
chore/playwright-e2e

Conversation

@acharlop

Copy link
Copy Markdown
Contributor

Summary

Sets up end-to-end testing with Playwright for the existing site (Astro static output + React islands + Netlify adapter). There was no test framework and no CI before this PR.

Closes #46

What's included

  • @playwright/test dev dependency + test:e2e script.
  • playwright.config.ts — single chromium project, baseURL on port 4321.
  • .github/workflows/e2e.yml — installs pnpm deps, installs the Playwright chromium browser (cached), builds, and runs pnpm test:e2e on PRs and pushes to main.

Web server strategy (why not astro preview)

The original plan was pnpm build && pnpm preview, but the Netlify adapter does not support astro preview ("The @astrojs/netlify adapter does not support the preview command."), and astro dev boots Netlify Dev which requires network access to api.netlify.com. Since the site is output: 'static', the config builds the site and serves the emitted dist/ with a tiny zero-dependency Node static server (tests/static-server.mjs) on port 4321. Port 4321 matches the SITE_URL baked into non-prod builds, so absolute og:image URLs resolve back to the test server.

Test coverage (existing functionality only)

  • Smoke (smoke.spec.ts): landing page renders (hero, CTAs, title); key routes return 200 (/, /en, /mission, /print, /images, /en/question/1, /hu/question/1, /events/hajnalig, /events/hajnalig/play); unknown route serves the 404 page.
  • Event play (event-play.spec.ts): the SimplePlay island at /events/hajnalig/play — loads the ?q=-selected question in the default (hu) language, next/previous navigation, language toggle (hu↔en), and the auto-hiding controls (fade out after 3s, reappear on mouse movement).
  • Per-question page (question-page.spec.ts): /en/question/1 renders the question text and GameControls; the next control navigates to another question page.
  • OG / social images (og-images.spec.ts): for /, /en/question/1, /hu/question/1, asserts og:image and twitter:image exist, point at the expected committed image (/social.png or /images/{lang}/{id}.png), and that the image URL resolves (HTTP 200 + image/* content-type).

Skipped / TODO follow-ups

  • Contact / card-request form (contact.spec.ts) — skipped. /contact is an SSR-only route (prerender = false) emitted as a Netlify function, so it is not served by the static e2e server; submitting a valid payload would also call Postgres (insertUser) and Google Sheets (createContactSheetRow). The spec is written out (render + native-validation checks) and can be enabled once the suite runs against a server that can execute SSR routes (e.g. netlify dev with network).
  • test.fixme placeholder in og-images.spec.ts noting that code-generated card images (Generate question card images via code instead of committing PNGs #44) and the new /play screen (General play screen for the main site #41) get dedicated tests once they land.

Local run

pnpm test:e2e → 21 passed, 3 skipped (2 contact + 1 TODO).

Note on pnpm install + sharp

sharp's postinstall tries to build libvips from source (fails without node-gyp), while the prebuilt platform binary it actually uses is installed from the lockfile. The CI workflow installs with --ignore-scripts so this spurious build step doesn't fail the run; the site still builds correctly.

Set up end-to-end testing with @playwright/test for the existing site.

- playwright.config.ts builds the static site and serves dist/ via a tiny
  zero-dependency Node static server (tests/static-server.mjs). The Netlify
  adapter does not support `astro preview`, and `astro dev` needs network
  access to Netlify, so serving the built static output is the hermetic option.
- test:e2e script + .github/workflows/e2e.yml (install, build, browsers, run).
- Specs cover: landing + key routes (smoke), hajnalig SimplePlay event screen
  (next/prev, language toggle, auto-hiding controls, ?q= start), per-question
  page + GameControls, and og:image/twitter:image meta resolving to real images.
- Contact form spec is written but skipped: it is an SSR-only route
  (prerender=false) emitted as a Netlify function, not served by the static
  e2e server, and submitting would hit Postgres/Google Sheets.
- TODO placeholder for #44 (generated card images) and #41 (new /play screen).

Closes #46
@netlify

netlify Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for whocards-calmly ready!

Name Link
🔨 Latest commit 3382e7b
🔍 Latest deploy log https://app.netlify.com/projects/whocards-calmly/deploys/6a2d56f132f45b000812b0e7
😎 Deploy Preview https://deploy-preview-49--whocards-calmly.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97
Accessibility: 87
Best Practices: 100
SEO: 100
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

acharlop added 3 commits June 13, 2026 15:02
- drop question-page.spec.ts (per-question pages removed; now 301 -> /play,
  covered by Netlify redirect-rules, not the static dist/ harness)
- smoke: remove /:lang/question/:id routes (now redirects / SSR, not static)
- og-images: replace question-page samples with static-page fallbacks; turn the
  #44 placeholder into real assertions that generated /og/{lang}/{id}.png cards
  resolve (incl. RTL he); add fixme noting /play SSR og needs a functions server
- gitignore harness agent worktrees
The generalized <Play> control now has aria-label='change language' (the old
hajnalig button had none), so locate it by accessible name instead of
button:not([aria-label]).
@acharlop
acharlop merged commit 96e84d7 into main Jun 13, 2026
6 checks passed
@acharlop
acharlop deleted the chore/playwright-e2e branch June 13, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playwright E2E tests (incl. OG image checks)

1 participant