End-to-end tests with Playwright (#15) #35

Merged
miko merged 1 commit from feature/15-playwright-e2e into development 2026-11-02 13:50:14 +01:00
Owner

Closes #15.

What

A Playwright suite (npm run e2e) covering the main v1 flows end to end.

  • Test database: runs against kataba_e2e, derived from DATABASE_URL or set with E2E_DATABASE_URL. Any database whose name doesn't end in _e2e is refused, and Vitest covers that guard. Every run migrates the database and empties it, along with .e2e/uploads.
  • Sign-in without Authentik: tests mint the Auth.js session cookie with the test server's fixed secret for seeded users: an admin, two authors and a viewer. Roles come from the database, as ADR-0009 describes.
  • Specs
    • An author creates a guide and adds a step with a red and a black step line, an image, and an annotation on the red line. The author publishes it and a guest reads it.
    • A guest cannot see an internal guide or its image (the media route returns 404). A viewer can see both.
    • Another author can't edit the guide until its owner turns wiki mode on.

Notes

  • Run once as a DB admin: CREATE DATABASE kataba_e2e; GRANT ALL PRIVILEGES ON kataba_e2e.* TO 'kataba'@'localhost'; (see the README).
  • The test category is created through the admin form, not inserted into the database. The server caches the category tree (use cache), and only the admin actions invalidate that cache.
  • The test server listens on port 3100. Outside CI it is reused if it's already running.

🤖 Generated with Claude Code

Closes #15. ## What A Playwright suite (`npm run e2e`) covering the main v1 flows end to end. - **Test database**: runs against `kataba_e2e`, derived from `DATABASE_URL` or set with `E2E_DATABASE_URL`. Any database whose name doesn't end in `_e2e` is refused, and Vitest covers that guard. Every run migrates the database and empties it, along with `.e2e/uploads`. - **Sign-in without Authentik**: tests mint the Auth.js session cookie with the test server's fixed secret for seeded users: an admin, two authors and a viewer. Roles come from the database, as ADR-0009 describes. - **Specs** - An author creates a guide and adds a step with a red and a black step line, an image, and an annotation on the red line. The author publishes it and a guest reads it. - A guest cannot see an internal guide or its image (the media route returns 404). A viewer can see both. - Another author can't edit the guide until its owner turns wiki mode on. ## Notes - Run once as a DB admin: `CREATE DATABASE kataba_e2e; GRANT ALL PRIVILEGES ON kataba_e2e.* TO 'kataba'@'localhost';` (see the README). - The test category is created through the admin form, not inserted into the database. The server caches the category tree (`use cache`), and only the admin actions invalidate that cache. - The test server listens on port 3100. Outside CI it is reused if it's already running. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Playwright runs a production build on port 3100 against its own
kataba_e2e database (refused unless the name ends in _e2e) and upload
directory. Global setup migrates and empties the database, seeds one
user per role plus a second author, and creates the test category
through the admin form so the cached category tree is invalidated.
Tests sign in without Authentik by minting the Auth.js session cookie
with the test server's secret.

Specs cover: an author creating a guide with an annotated step and
publishing it, a guest reading it, a guest locked out of an internal
guide and its images while a viewer reads them, and another author
editing only once wiki mode is on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit b6b87e9aed into development 2026-11-02 13:50:14 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!35
No description provided.