Skip to content

test: add Pest browser tests (Playwright) - #126

Merged
StanBarrows merged 3 commits into
mainfrom
test/pest-browser
Oct 23, 2026
Merged

StanBarrows merged 3 commits into
mainfrom
test/pest-browser

Conversation

@StanBarrows

Copy link
Copy Markdown
Contributor

Adds Pest browser tests (pestphp/pest-plugin-browser, Playwright Chromium) and a CI lane pull-request | ci pest browser on ubuntu-latest with PostgreSQL 17.

Bug found and fixed (own commit): the markdown fields on the internship application used x-html, which the Alpine CSP build refuses. Every application page threw 4 JavaScript errors and the preview dialog stayed empty. The preview element is now an x-ref and render() writes the already escaped HTML into it, with a Vitest case for it.

Tests (tests/Browser/, 27 tests)

  • PublicPagesTest: every public page shows its heading with no JavaScript errors or console messages (CSP violations included). Also covers the / → /de-ch redirect and the error page.
  • NavigationTest: language links, mobile menu (opens, navigates, closes on Escape), and the language suggestion for an English browser arriving through / (none for a German one).
  • FormsTest: the network profile link request, the internship flow from the email form to the signed application page with autosave, and the markdown preview.

Other changes

  • phpunit.xml.dist: new Browser testsuite. The pest and coverage lanes already list their directories explicitly, so they don't run it.
  • New dev dependencies: pestphp/pest-plugin-browser ^5.1 and playwright ^1.64.1.
  • Failure screenshots (tests/Browser/Screenshots) are gitignored.

Run locally

composer install && npm ci && npm run build
npx playwright install chromium
DB_CONNECTION=pgsql DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=testing DB_USERNAME=postgres DB_PASSWORD=postgres ./vendor/bin/pest tests/Browser

🤖 Generated with Claude Code

Sebastian BURGIN-FIX (ext) and others added 3 commits October 23, 2026 14:47
The site runs the CSP build of Alpine (@alpinejs/csp), which refuses the
x-html directive: on every page with a markdown field (the internship
application) the browser logged "Using the x-html directive is
prohibited in the CSP build" four times and the preview dialog stayed
empty. The new Pest browser tests caught it.

The preview element is now an x-ref and render() writes the HTML that
renderMarkdown() already escapes into it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n forms

Company rule since 2026-10-23: every repository has Pest browser tests
(pestphp/pest-plugin-browser with Playwright). The site runs with a
strict CSP and the Alpine CSP build, which HTTP tests cannot check; these
drive a real Chromium:

- every public page renders its heading without JavaScript errors or
  console messages (CSP violations included), / redirects to /de-ch,
  unknown paths show the error page
- the language links switch to the localized slug, the mobile menu opens,
  navigates and closes with Escape, the language suggestion appears for
  an English browser arriving through / and not for a German one
- the network profile link request, and the internship flow from the
  email form to the signed application page with autosave, plus the
  markdown preview

tests/Pest.php already applies TestCase, RefreshDatabase and the roles
seeder to every test directory. phpunit.xml.dist gets a Browser
testsuite; the pest and coverage lanes list their directories explicitly
and do not run it. Failure screenshots are ignored by git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New lane "pull-request | ci pest browser" on ubuntu-latest (public
repository, so no self-hosted runners) with the PHP, Nova credentials and
.env setup of the pest lane and a PostgreSQL 17 service on a
Docker-assigned port. It builds the assets, installs Playwright's
Chromium and runs tests/Browser; on failure it uploads the logs and the
failure screenshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StanBarrows
StanBarrows merged commit 6455fe7 into main Oct 23, 2026
7 checks passed
@StanBarrows
StanBarrows deleted the test/pest-browser branch October 23, 2026 13:01
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.

1 participant