Files
kooltab-backoffice/docs/testing.md
T
brammie15 314717ba3a
CI / build-and-test (push) Canceled after 0s
feat: move to V2
2026-10-29 11:21:52 +01:00

36 lines
1.4 KiB
Markdown

# Testing
```bash
pnpm test # every package's unit tests
pnpm test:e2e # the API against a real database
```
## Unit tests
- `apps/api/src/**/*.spec.ts` (Jest): the rules in `ledger/` (tabs, drinks, settling, stock, product merges), event
parsing, the app version gate, consistency checks, email templates and image processing. Pure, no database.
- `apps/dashboard/src/**/*.test.ts` (Vitest): the customer import, amount parsing, and that every translation key the
dashboard uses exists in English and Dutch.
## End-to-end tests
`apps/api/test/api.e2e-spec.ts` starts the whole API against the database in `DATABASE_URL` (migrated, and
**wiped** by the test) and plays a terminal and the dashboard together: pairing, syncing events once, settling on a
terminal and on the dashboard, customers getting tabs, stock movements, unpairing, venue access, and the superadmin
page.
Locally, `docker compose up -d` creates a `kooltap_test` database too:
```bash
cd apps/api
DATABASE_URL=postgresql://kooltap:kooltap@localhost:5432/kooltap_test npx prisma migrate deploy
DATABASE_URL=postgresql://kooltap:kooltap@localhost:5432/kooltap_test pnpm test:e2e
```
CI runs both, checks that the Prisma schema matches the migrations, builds everything and exports the terminal
protocol's JSON Schema.
## By hand
`pnpm simulate` is a terminal on the command line: open tabs, ring up drinks and settle, and watch the dashboard follow.