Skip to content

🔄 Synced from castyou-automated-tests/README.md — edit it there, not here.

castyou-automated-tests

End-to-end / smoke tests for the casTyou platform, driven by Playwright.

Runs against locally-running instances of castyou-backend and castyou-frontend/apps/app.

Setup

sh
pnpm install
pnpm exec playwright install chromium

Prerequisites

The frontend and backend dev servers must be running before tests:

sh
# in castyou-backend/
pnpm dev   # listens on :4000

# in castyou-frontend/apps/app/
pnpm dev   # listens on :3001

Plus PostgreSQL, MongoDB, and Redis available locally (see castyou-backend/.env).

Running

sh
pnpm test            # headless
pnpm test:headed     # open the browser
pnpm test:ui         # Playwright UI mode
pnpm report          # open the last HTML report

Cleaning up generated data

Every account a run creates uses the @example.test email domain (per-test accounts plus the per-run seed accounts). Over time these — and everything they generate (jobs, posts, messages, notifications, …) — accumulate in the local databases. Clean them up on command:

sh
pnpm clean:dry   # report what WOULD be removed — changes nothing
pnpm clean       # remove every @example.test account + its data, and the local fixtures

pnpm clean purges both databases (Postgres cascade + the Mongo collections) by delegating to the backend's pnpm cleanup:e2e, then deletes the local tests/fixtures/seed-accounts.json + storage-states/ so the next run starts fresh. It never touches the @seed.castyou.dev dev-seed dataset or real data.

The backend repo is assumed to be the sibling ../castyou-backend; override the path with CASTYOU_BACKEND_DIR if your checkout differs.

To wipe automatically right after a run, set CASTYOU_CLEANUP:

sh
pnpm test:clean              # == CASTYOU_CLEANUP=1 pnpm test
CASTYOU_CLEANUP=1 pnpm test  # any test invocation works

Left unset (the default), data is kept so a failed run can be inspected.

Configuration

The frontend URL defaults to http://localhost:3001. Override with:

sh
CASTYOU_FRONTEND_URL=https://staging.castyou.example pnpm test

Specs

  • tests/auth-and-layout.spec.ts — registers a fresh email account, walks through pet-owner onboarding, navigates Home ↔ My Pets ↔ Profile, and asserts the AppShell DOM node is not remounted across route changes (proves the layout-route refactor stays effective).

Adding tests

Each test should create the data it needs (e.g. a fresh user) rather than relying on shared fixtures. Email addresses use a timestamp suffix to avoid collisions; tests run with workers: 1 to keep the local backend happy.