Skip to content

tests: e2e playwright - #439

Merged
sabinem merged 10 commits into
mainfrom
test/e2e-playwright
Nov 19, 2026
Merged

sabinem merged 10 commits into
mainfrom
test/e2e-playwright

Conversation

@sabinem

@sabinem sabinem commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Every pull request is now tested in a real browser

Before, CI started the whole app and filled it with test data, but nothing ever opened it in a browser. A broken login or a page showing the wrong things to the wrong person could merge unnoticed. Now every pull request logs in through the real login page as an organizer and as a participant, and checks what each of them sees.

  • Developers: just check::e2e runs the same tests against the app started with just start. just check::e2e-report then shows each failure with a screenshot and a step-by-step trace.
  • CI: runs them after Seed. On a failure, the report and the app's logs can be downloaded from the run for a week.
  • The tests turned up two gaps in CI's app, both fixed here. The frontend had no secrets file, so every page failed. And the backend never saw the permissions the seed granted, so CI now restarts the app after seeding.
  • If the app isn't reachable, the recipe says whether nothing answers or the frontend answers with an error, and it never leaves an old report behind.
  • The browser comes from Nix. @playwright/test must match the Nix version exactly, and check::e2e says so when it doesn't.

Left out: only five smoke tests so far, Chromium only, and the frontend runs in dev mode. The backend still needs a restart after every seed, locally too. Making it reload permissions by itself is a separate change.

Verified: locally on macOS, all tests pass after a restart done the way CI does it, and a broken test fails with a screenshot and a trace. Frontend lint and formatting pass. The CI fixes are confirmed only once this PR's run is green.

`just check::e2e` runs browser tests against whatever serves :8081, so
`just start` locally and the seeded stack in CI. Each user logs in once
through the real Keycloak form and the session is reused. The tests only
read, against the seeded hackathons, so they hold on a fresh database and on
a local one that has been clicked through.

The browsers come from nixpkgs through a new `test-e2e` toolchain, the same
build on a Mac and in CI. Playwright refuses browsers built for another
version, so `@playwright/test` is pinned to exactly the nixpkgs version, and
the recipe says so plainly when the two drift apart.
The Test job already starts the whole stack and seeds it, so the browser
tests run right after, on every pull request. When they fail, the HTML
report and the traces are uploaded for a week, without the saved logins.

`deploy::up` returns once the backend is ready, which can be before the
frontend answers, so `check::e2e` now waits up to two minutes for :8081
instead of giving up at once.
`check::e2e` only knew "nothing answered on :8081", so a frontend that was
up but answered every page with a 500, because its backend was gone, was
reported as a stack that was not started. It now tells the two apart, and
for an error points at the backend and the frontend log. It also says that
it is waiting, so the two minutes do not look like a hang.

It deletes the previous report before it starts. A run that stopped before
Playwright left the old report in place, where it read as a pass.
A failed test only reported the error and the line, never what the page
looked like: traces were kept on a retry, and nothing is retried locally.
Each failure now keeps a screenshot and a trace, in CI as locally. Passing
tests keep neither.

`just check::e2e-report` opens the report of the last run, and
`check::e2e` names it when a test fails, or the report artifact in CI.
The frontend reads data/test/config/secrets.yaml, which is git-ignored, so
a fresh checkout has none. Every developer copies it from the example once,
as the frontend README says, but nothing did so in CI. Nothing there loaded
a page until the browser tests, which found every page answering 500.

CI now copies the example before it starts the stack. Its values do for a
throwaway stack, and the copy also proves the example stays a working
config.

A failed run now also uploads the stack's logs with the report, so a stack
that broke before the tests could start says why.
They test the whole stack, so their place under components/frontend reads
like a mistake. The config now states the rule: a system test lives in the
component whose interface it drives, so a page and its test change together.
The seed writes casbin rows straight into the database, but the backend
loads its permission rules once, at startup. CI seeded a running backend
and never restarted it, so it served the seeded data without the seeded
roles. alice was not an organizer there, and the browser test that expects
her to be offered `Create Hackathon` failed.

CI now restarts the stack after seeding, as "Restart the backend after
seeding" in cmd/seed/README.md prescribes. The data is kept.
The image build fetches the frontend's npm packages up front, pinned to
vendorHash, and then installs offline. Adding @playwright/test changed the
lockfile but not the hash, so the pinned fetch lacked it and the frontend
image failed with ERR_PNPM_NO_OFFLINE_TARBALL. The test job did not notice:
it installs with network access.

Set by `just nix::fix`. The hash does not depend on the platform it is
computed on: on a Mac, main's unchanged lockfile gives exactly the hash CI
has built with since August.
@sabinem sabinem changed the title Test/e2e playwright tests: e2e playwright Nov 18, 2026
The config said CI runs the tests after `deploy::up` and `db::seed`. Since
CI also restarts the stack after seeding, so the backend sees the seed's
roles, that description fell short of what a reader needs to reproduce a
CI failure locally.
The frontend image installs its npm packages offline from a download
pinned by `vendorHash`. A changed lockfile without a new hash passes every
check and then fails the image build with ERR_PNPM_NO_OFFLINE_TARBALL,
as adding @playwright/test did. The README now says what to run.
@sabinem
sabinem merged commit 88fe6e9 into main Nov 19, 2026
4 checks passed
@sabinem
sabinem deleted the test/e2e-playwright branch November 19, 2026 12:18
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