Tea journaling on ATProto (alpha) forked from arabica.social/arabica
README.md

End-to-end tests #

Playwright tests that drive the Solid frontend in a real Chromium against the real Go router, using an in-memory fixture instead of an account or a PDS.

Run #

pnpm --dir web exec playwright test          # build frontend, boot fixture, run, tear down
pnpm --dir web exec playwright test --ui     # same, with the UI runner

The config runs pnpm run build:web once, starts tests/e2e/server on 127.0.0.1:18939, and Playwright stops the fixture and the browser when the run ends. Set OOLONG_E2E_NO_BUILD=1 to skip that build and serve the existing web/dist. Chromium comes from Playwright's install by default; set CHROMIUM_PATH to a system Chromium (e.g. a Nix store path) to use that instead.

Variable Effect
OOLONG_E2E_PORT Fixture port (default 18939).
OOLONG_E2E_BASE_URL Fixture address to start instead of the default; must be an http loopback origin with no path, and its port must match OOLONG_E2E_PORT when both are set.
OOLONG_E2E_NO_BUILD Skip the frontend build and serve the existing web/dist.
OOLONG_E2E_WEB_DIST Frontend build directory the fixture serves (default web/dist).
CHROMIUM_PATH Chromium executable for Playwright.

The fixture is not reused: Playwright fails if the port is already taken, so a stale Go binary cannot quietly answer tests. It serves web/dist from disk on every request (spa.Config.DevDir), which is why the webserver builds first rather than relying on the embedded snapshot.

Fixture #

tests/e2e/server/main.go boots the real router, JSON API, SPA shell, and assets against:

  • memoryStore, an in-memory records.Store, so record CRUD is real code with a map behind it; every write is lost on exit.
  • a synthetic session (atpmiddleware.ContextWithAuth) for every request, so there is no OAuth flow. A fixture-signed-out cookie (set by GET /logout, or directly by the test) makes requests anonymous, including the shell's data-* session attributes.
  • a Playwright route guard that aborts every request leaving the fixture origin (and fails the test), so the browser cannot reach the network either.
  • fixtureTransport on http.DefaultTransport, which answers app.bsky.actor.getProfile, com.atproto.identity.resolveHandle, the DID document, and com.atproto.repo.listRecords/getRecord from the same store. Any other outbound request fails with fixture blocked external request, so a test cannot reach a real PDS, relay, or account.
  • seed records: vendor harney, tea earlgrey, vessel mug, brew morning.

Each run gets a fresh fixture. Tests share it with one worker, use unique record names, and lifecycle tests delete their records. There is no reset endpoint and no production test hook.

What is covered #

  • brew-lifecycle.spec.ts: log a steep through the Solid form, verify the saved state, edit it via /brews/{rkey}/edit, confirm the stored record through GET /api/brews/{rkey}, then delete it with a same-origin fetch and confirm 404 — and that a tea created through POST /api/teas shows up in the steep tea picker.
  • tea-lifecycle.spec.ts: create a tea in /teas/new, edit it in /teas/{rkey}/edit, delete it from its /my-tea card (confirming the dialog), and confirm each step through the JSON API.
  • smoke.spec.ts: signed-in shell navigation to the steep form; signed-out home and steep page keep public chrome and offer login instead of the form.

Not covered: OAuth login/logout/reauth, PDS and network failures, likes, comments, moderation, settings mutations, visual regression.

Selector contract #

Tests use roles, labels, and hrefs rather than copy or class names, so page redesigns mostly survive. These anchors are relied on today:

  • main navigation landmark: navigation named "Main navigation"
  • a visible link to /brews/new
  • steep form: combobox named "Tea", labelled inputs Time (seconds) / Temperature (°C), submit buttons "Save steep" / "Update steep", and a heading matching /saved/i after a successful save
  • entity form (/teas/new, /teas/{rkey}/edit): heading "New tea"/"Edit tea", labelled fields "Tea" (name), "Category", "Origin (if known)", submit buttons "Save tea"/"Update tea", success by navigating to /my-tea
  • /my-tea: heading "My tea", tabs in a navigation named "Your collections" (buttons "Steeps", "Teas", ...), one article per record carrying an Edit link and a Delete <name> button that opens window.confirm
  • signed-out steep page: a link to /login inside main

Owners of the pages and shell should keep those anchors, or tell the E2E owner so the tests move with the UI.