Check-in gate + fixes, RPC test suite, docs
- Convivo: not-checked-in gate for non-staff (see-a-staff screen with QR code + logout); lifts automatically once staff checks them in - Convivo: fix check-in 'pick a session first' race (synchronous default session fallback) - Add RPC test suite (npm run test:rpc): points idempotency, role guards, service-session guard, speaker auto-promote, leaderboard staff exclusion - Fix db:types script (create packages/shared/src); gitignore generated types - Docs: README/roadmap drift fixes, tests.md, backend README link Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
fcbc19b8fc
commit
b08a439949
11 files changed
+559
-38
No files matched your search
@@ -13,6 +13,7 @@ Postgres. This folder documents that core.
|
||||
| [seed.md](./seed.md) | Seed data + the demo accounts |
|
||||
| [docker.md](./docker.md) | Docker: the app image + root compose (how the core + app run together) |
|
||||
| [sidecar.md](./sidecar.md) | The Sessionize sync sidecar (on-demand, service-role) |
|
||||
| [tests.md](./tests.md) | The RPC test suite (`npm run test:rpc`) |
|
||||
|
||||
## The big picture
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Backend — RPC Test Suite
|
||||
|
||||
A self-contained, idempotent test suite for the transactional points RPCs, role
|
||||
guards, and the speaker auto-promote trigger. It runs directly against the local
|
||||
Supabase Postgres container.
|
||||
|
||||
## Run it
|
||||
|
||||
```bash
|
||||
npm run db:start # the Supabase core must be running
|
||||
npm run test:rpc # runs supabase/tests/rpc_tests.sql, exits non-zero on failure
|
||||
```
|
||||
|
||||
Or manually:
|
||||
|
||||
```bash
|
||||
docker exec -i supabase_db_Convivo psql -U postgres < supabase/tests/rpc_tests.sql
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
- **No seed mutation.** Everything runs in a single transaction that **rolls
|
||||
back** at the end, so the seed data is never changed. Safe to run repeatedly.
|
||||
- **Current user = PostgREST-style JWT claim.** Each test sets the user the same
|
||||
way PostgREST does:
|
||||
`set_config('request.jwt.claims', '{"email":"..."}', false)`, which is what
|
||||
[`public.current_email()`](./rpcs.md) and `public.is_admin()` read.
|
||||
- **Every test always runs.** Each test is a `DO` block that catches its own
|
||||
exceptions and records a pass/fail row into a temp table, so one failure never
|
||||
aborts the rest. A summary is printed before the rollback.
|
||||
- **The runner fails the process** (`npm run test:rpc`) if any test failed, so it
|
||||
can be wired into CI.
|
||||
|
||||
## What it covers
|
||||
|
||||
| Area | Tests |
|
||||
|---|---|
|
||||
| `checkin_attendee` | awards +10, marks `checked_in`, idempotent re-check-in, service-session guard, non-admin role guard |
|
||||
| `submit_feedback` | +5 rating-only, idempotent re-submit, requires check-in |
|
||||
| `accept_connection` | +5 to both parties |
|
||||
| `adjust_points` | admin-only role guard |
|
||||
| Speaker auto-promote trigger | attendee → speaker, never overrides staff |
|
||||
| Leaderboard | excludes staff |
|
||||
|
||||
## Files
|
||||
|
||||
- [`supabase/tests/rpc_tests.sql`](../../supabase/tests/rpc_tests.sql) — the test
|
||||
script (fixtures + assertions + summary).
|
||||
- [`supabase/tests/run-rpc-tests.js`](../../supabase/tests/run-rpc-tests.js) — the
|
||||
runner (executes the script, parses the summary, sets the exit code).
|
||||
Reference in new issue
Block a user