Skip to content

test: add a Playwright E2E suite - #116

Merged
LukeSavefrogs merged 26 commits into
mainfrom
claude/sweet-newton-d6bijf
Nov 27, 2026
Merged

LukeSavefrogs merged 26 commits into
mainfrom
claude/sweet-newton-d6bijf

Conversation

@LukeSavefrogs

@LukeSavefrogs LukeSavefrogs commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Browser end-to-end tests with Playwright, covering the features of the app, run in CI on SQLite and MySQL: about 230 tests, of which a smoke subset also runs on a phone viewport.

Infrastructure

  • playwright.config.ts, with these projects:
    • auth-setup: signs in each role once.
    • chromium.
    • mobile: the @mobile tests, on a Pixel 7.
    • global-state: settings and requirements, run alone after the others.
    • setup-wizard.
  • tests/e2e/support/serve.sh serves isolated instances on the ports 8010 and 8011. Each has its own .env.e2e-*, storage (storage/e2e/), database and session cookie:
    • app: installed and seeded with the new E2eSeeder, with a user per role and known records.
    • setup: empty, for the setup wizard.
  • The server is PHP's built-in one with 6 workers.
    • The OPcache JIT is turned off: setup-php turns it on, and on PHP 8.2 the workers segfaulted one after the other until every connection was refused.
    • Its request log is filtered out; its errors also go to logs/server.log.
  • Each browser context sends its own X-Forwarded-For, so that the per-IP login rate limit doesn't throttle the parallel tests.
  • Helpers in tests/e2e/support/:
    • Filament actions, menus, searchable selects, filters, imports and exports.
    • php(), which runs code in the app through Tinker.
    • Reading the sent emails from the mail log: an email is looked for among the others of the address, which may receive another one meanwhile (e.g. a new campaign).
    • TOTP codes for 2FA.
  • SQLite now takes DB_BUSY_TIMEOUT / DB_JOURNAL_MODE from the environment. Without them nothing changes. The E2E instances use WAL, so that the parallel writers wait for each other.

Specs

  • Workflows (workflows.spec.ts): the whole workflows of the users, through the pages they use.
    • A zone, then a territory in it, assigned to a publisher. The publisher follows the notification and asks to return it, then the servant follows theirs and ends the assignment.
    • A campaign created, a territory assigned in it with the wizard, then its assignments terminated.
    • A group overseer invited, who chooses their password, signs in and assigns a territory.
  • Public pages: public pages, knowledge base, login (throttling, password reset, 2FA, recovery codes), profile, dashboard.
  • Territories: territories, zones, assignments, sharing and guest pages, campaigns.
  • Administration: users (invitations, impersonation, root protections), departments, roles, per-role authorization matrix, developer pages, Artisan / cron / MCP endpoints.
  • Publications: publications, requests, regular publications, posters and storage places (with CSV import/export), tags.
  • Setup wizard: all 9 steps, on the database of the run.
  • Global settings:
    • general, territory and campaign settings;
    • required 2FA and email confirmation;
    • AI assistants;
    • root user handover, refused outside production.

CLAUDE.md now asks to keep the E2E tests in step with every change to the UI, and to cover the whole workflows.

Fix

  • FakeTerritoryAssignmentSeeder could pick a terminated campaign, which the observer refuses, so seeding the fake data failed. It now uses active campaigns only.

CI

  • New E2E tests workflow (run-e2e-tests.yml), with a [sqlite, mysql] matrix.

  • When a test fails, its retry is recorded: trace and video.

  • On failure, the job:

    • uploads the HTML report, the traces, the videos and the app logs;
    • prints when the app server stopped answering, its errors and any process killed by the kernel;
    • explains in the job summary how to open them.
  • The existing workflow is renamed, so that the two suites are told apart. The required checks of main need updating after the merge:

    Workflow File Checks
    Run tests → Pest tests run-tests.yml → run-pest-tests.yml Run tests (prefixed=no/yes) → Pest (prefixed=no/yes)
    Run E2E tests → E2E tests run-e2e.yml → run-e2e-tests.yml Run E2E tests (sqlite/mysql) → E2E (sqlite/mysql)
  • PostgreSQL is left out: the app doesn't support it yet. Almost every page fails with operator does not exist: text ->> unknown, which comes from the database notifications querying data->>'format' on a text column. It will come in its own PR.

Found while writing the tests (not fixed here, marked test.fixme)

  • /app/campaigns/{id}/assignments throws LazyLoadingViolationException outside production when a campaign has 2 or more assignments in progress. The page hides the campaign column, and the row classes still read the campaign.
  • The Log Viewer (achyutn/filament-log-viewer) lists no entries when the environment name has a hyphen, e.g. e2e-app or pr-123 previews.
  • The Slug of a tag is never saved: Spatie\Tags\HasSlug rebuilds it from the name on every save.
  • The Tags filter of the territories lists only the first 50 tags, without a search.

Other findings:

  • Creating a campaign notifies every user synchronously, which is slow with many users.
  • After "Assign Territory" on the territory view page, the header action changes to "End Assignment" only after a reload.
  • The bulk "Remove" of department members opens a "Detach selected Members" modal.

Test plan

  • php artisan test --compact tests/Feature/E2eSeederTest.php tests/Feature/FakeDataSeederTest.php tests/Feature/SqliteConnectionConfigTest.php
  • A full local run from fresh servers, set up like CI, and each spec file with --repeat-each=2 --workers=3; workflows.spec.ts with --repeat-each=4 --workers=3.
  • E2E tests and Pest tests green on SQLite and MySQL, under the new names.

🤖 Generated with Claude Code

https://claude.ai/code/session_019ELFCvU9iyEytKmTVmJRXU

The fake assignments could pick a terminated campaign, which the
assignment observer refuses, making the fake data seeding fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Serve isolated app and setup instances, seed fixed users per role
and share helpers for Filament pages, emails and 2FA codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the setup wizard on the empty instance, and the settings that
change the whole app alone, restoring their defaults after each test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app does not support PostgreSQL yet (JSON operators on text
columns): it will come in its own change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read the busy timeout and journal mode of SQLite from the env, use
WAL and database sessions in the E2E instances, and seed English
users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also add helpers for the Filament 5 menus, searchable selects,
filters, imports and exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukeSavefrogs LukeSavefrogs added the preview: off No preview for this PR label Nov 27, 2026 — with Claude
@LukeSavefrogs
LukeSavefrogs marked this pull request as draft November 27, 2026 09:58
Leave out the connection and request lines of the PHP server, as
`php artisan serve` does, keeping its errors in the test output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On CI, record the retry of a failed test (trace and video), keep the
errors of the test servers with the report, and explain in the job
summary how to open them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Note when the app server stops answering during the run, and print
its errors, the killed processes and the memory at the end of the
failed jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On CI (PHP 8.2, JIT on by setup-php) the workers of the PHP server
segfaulted one after the other until it refused every connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wait for the saved notification before reloading, and search for the
campaign, which other tests can push to another page of the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename "Run tests" to "Pest tests" and "Run E2E tests" to "E2E tests",
with their files and jobs, so that the two suites are told apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Other emails (e.g. a new campaign, sent to every user) may reach an
address while a test waits for its invitation or reset link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Zone to territory to assignment and return, a campaign from start to
end, and a user invited who then assigns a territory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give each test instance its own config, route and event caches, so
that a cached development config never points it at that database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PHP server workers write at once, leaving the ends of cut request
lines (e.g. ".3.3.0") on lines of their own: drop them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukeSavefrogs
LukeSavefrogs marked this pull request as ready for review November 27, 2026 13:56
@LukeSavefrogs
LukeSavefrogs merged commit 56feb56 into main Nov 27, 2026
10 checks passed
@LukeSavefrogs
LukeSavefrogs deleted the claude/sweet-newton-d6bijf branch November 27, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview: off No preview for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants