Files
Convivo/docs/backend/tests.md
T
lago 35b88d50ca feat(points): staff auto-connect never scores; event feedback pays +5
- Migration 20261020120000: staff (type staff / Admin / @appe.at) are
  auto-connected to every participant of the event via connections.auto
  rows inserted directly as accepted - never through accept_connection,
  so zero points by construction; backfill + idempotent helper + trigger.
- Migration 20261020130000: submit_event_feedback awards +5 on the first
  submission per participant x event (edits earn 0), gated by
  _points_eligible; response gains earned column; ACL restored.
- Admin: points move from Contacts to Registrations (active-event rows
  only, in-place save); Dashboard Top points drops emails; Dashboard and
  Activity hide auto connections.
- Attendee: leaderboard masks surnames (Max M.); EventFeedback toast
  shows +5 pts on paid submissions.
- Tests: staff_auto_connections_tests.sql (14 assertions), rpc_tests
  section 11 (4 assertions). Docs + release record 2026-10-20.
- README: document the git-ignored .env provisioning step (missing key
  = white screen).
2026-10-20 22:15:29 +02:00

782 lines
42 KiB
Markdown

# Full E2E Suite Status
The suite is **31 spec files / 255 tests** (`npx playwright test --list`), and it
is **not currently green** — the next person to run it will hit this
immediately, so it is recorded before any run list: a clean serial run on
2026-10-19 gave **213 passed, 42 failed** (exit code **1**).
```sh
cd e2e
npx playwright test --workers=1 > /tmp/full.log 2>&1; echo EXIT=$?
# then read /tmp/full.log
```
> **Never read a full-suite result through a pipe.** `... | tail -3` reports
> **tail's** exit code — `0` — even when Playwright failed, and it shows only
> the end of the output, where the failed-tests list is easy to misread as
> progress. This burned the team twice on 2026-10-19 and produced two false
> "0 failed" records before the correction; see the
> [release record](../releases/2026-10-19.md). Redirect to a file, capture
> `echo EXIT=$?`, then read the file.
Run **one full suite at a time**: every spec shares a single Postgres, and two
suites racing produce phantom failures.
The 42 failures are **pre-existing seed drift, not regressions**. The
mechanism: `e2e/src/helpers/config.ts` hardcodes the demo identities of the
*original* seed (`[email protected]`, `[email protected]`,
`[email protected]`, …), and the pretix import replaced the attendee
data on this database — only 1 of 5 sampled seed contacts still exists.
`e2e/src/helpers/reset.ts` then only **UPDATE**s those rows (assigning the
speaker's `qr_token`, re-hashing the auth password); it inserts nothing except
the sponsor, which was never in the seed either. An UPDATE against a missing
row affects **0 rows and raises nothing** — the reset passes silently and the
spec hangs in `login()` → `waitForAdmitted()`, because the login can never
succeed for a contact that does not exist. Each attempt burns the full timeout,
which is why the failures sprawl across 11 files: connections (8),
checkin-attendee (6), speaker-material (5 — every test except the
self-contained `CONV-MATERIAL-005`), profile-visibility (5), feedback (5),
session-checkin (3), e2e-journeys (6), sponsor (1), leaderboard-live (1),
attendee-navigation (1), admin-schedule (1).
The one failure that could plausibly have been recent work — admin-schedule's
"permission and network failures keep the visible schedule intact", suspected
of the silent-poll refactor — **fails identically when `Schedule.tsx` is
replaced with its pre-silent-refresh version**. Same failure, same error; the
refactor is exonerated. The check was run on 2026-10-19 as recorded in the
[release record](../releases/2026-10-19.md); it needs no re-verification, and
re-running it would mean temporarily reverting a source file.
**Fix direction (known work, not yet done):** make `reset.ts` *provision* the
demo contacts, registrations and auth users — upsert them the way
`ensureSponsor()` already does — instead of assuming the seed rows still exist.
The specs that provision themselves are exactly the ones that survived the data
change: `checkin-points.spec.ts` and `CONV-MATERIAL-005` insert their own
fixtures and delete them in a `finally`, and both passed in the same run that
produced the 42 failures. Until `reset.ts` is converted, new real-backend
specs should follow that self-provisioning pattern rather than the shared
identities.
# LLM Connection Test Regression
No migration is involved — the change is how the Settings "Validate AI
connection" verdict reads the reasoning-token counter. Run:
```sh
npm test --prefix apps/sidecar # 35 unit tests, 6 of them llm-test
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- llm-connection-test.spec.ts --project=chromium
```
The production gateway (ai.lago.dev) answers with
`completion_tokens_details: {}` — it reports **no** reasoning counter at all.
Treating "not reported" as "still thinking" would tell an admin that a working
configuration is broken, so the verdict keeps three reasoning states apart, and
`llm-connection-test.spec.ts` (**6 tests**, API-mocked — it stubs
`**/sidecar/llm-settings` and `**/sidecar/llm-test`) pins each one on the real
Settings screen: a reported `reasoning_tokens: 0` renders the green
`.llm-test-result.good` with no warning; a reported `null` renders the new
neutral `.llm-test-result.neutral` — no warning, a headline that does **not**
contain "still thinking", and copy saying the endpoint does not report a
counter instead of asserting thinking is off; a reported non-zero renders
`.warn` with the warning and the token count. A failed test (`ok: false`)
renders `.bad` with the provider's error and **no** reasoning line at all, and
the button stays usable.
The spec also guards two states that are easy to get wrong: the **dirty-form
lock** (the button is disabled while `#llm-endpoint` differs from the stored
settings — the API key never reaches the browser, so only saved settings can
be exercised — and re-enables after the edit is reverted) and the **in-flight
state** (progress visible, button disabled, and exactly **1** request leaves —
a `POST` carrying the admin's `Bearer` token). The verdict contract itself is
unit-tested on the sidecar side: **35** tests in the suite, **6** of them
covering `llm-test`.
# Tooltip Containment Regression
No migration is involved. Run:
```sh
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- tooltip-containment.spec.ts --project=chromium
```
A tooltip is portal-rendered so a table's `overflow` cannot clip it — but that
never kept it inside the **viewport**: the card was centred on its trigger with
a fixed width, so every tooltip attached to a right-aligned control ran off the
right edge and its text was unreachable. That was the user-reported bug on the
Sessions "Generate AI Feedback Summary" tooltip; all six call sites benefit
from the shared `Tooltip` fix, which measures the laid-out card, clamps it into
the viewport, flips it below when there is no room above, and re-aims the arrow
after any sideways shift.
`tooltip-containment.spec.ts` (**4 tests**, API-mocked admin) asserts the
measured geometry rather than the implementation: the `.tip-card` rectangle is
fully inside the viewport on all four edges (`x >= 0`, `x + width <= viewport
width`, same for `y`), the card does not widen
`document.documentElement.scrollWidth`, and `.tip-arrow` still points at the
trigger after the card is pushed sideways. It runs on the Sessions summary
button at wide (**1280 px**), narrow (**700 px**) and short (**260 px** —
genuinely no room above, forcing the flip-below `.tip-below` placement)
viewports, and on the Registrations points-exempt marker at **1100 px**.
Provenance matters when reading these tests: they were validated by
**temporarily reverting the Tooltip fix — 3 of 4 fail on the old centring
code** — so they guard the real bug, not a decorative behaviour. Mock gotcha
recorded in the spec: the admin auth path reads the contact with
`maybeSingle()`, so the `?email=eq.…` route must answer a single **object** —
answering with an array silently drops the app to the login screen, which
looks exactly like a broken tooltip.
# Speaker Pending-Material Pill Regression
The red 📎 pill on Home opened its sheet, but tapping a session there only did
`go('agenda')` — dropping the speaker on the Agenda list to hunt for the very
talk the pill had just named. It now opens the shared `SessionDetail` sheet
over Home, the way "My picks today" already behaves, with the upload form
inside. No migration is involved. Run:
```sh
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- speaker-material.spec.ts --grep CONV-MATERIAL-005 --project=chromium
```
`CONV-MATERIAL-005` (in `speaker-material.spec.ts`, **6 tests** in the file)
drives the real backend and is **self-contained**: it provisions its own
speaker on a real session that has no material — contact, registration,
`session_speakers` row and auth user — and deletes all four in a `finally`.
That matters because the §27/§28 demo speaker the rest of the spec family logs
in as belongs to the old seed and is gone since the pretix import; see
[Full E2E Suite Status](#full-e2e-suite-status). The test clicks the pill,
then the session in the "Pending material" sheet, and asserts the upload
notice and upload form are visible while the **Home tab is still active** —
the sheet opened in place, it did not navigate. Validated by mutation:
putting `go('agenda')` back makes the test fail.
# Front-Desk Gate + Badge Copies Regression
After applying `20261019110000_front_desk_gate_and_badge_copies.sql`, run the
SQL suite **combined with the migration** in one transaction (the migration is
`create or replace`, so the same stream also re-verifies an already-applied
database):
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/badge_print_tests.sql
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/set_registration_checked_in_tests.sql
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- front-desk-gate.spec.ts --project=chromium
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- welcome-badge-copies.spec.ts --project=chromium
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts --project=chromium
```
> **Replaying an older migration is no longer possible for these functions.**
> `20261019160000_welcome_points_and_toggle_restore.sql` **drops and re-creates**
> `checkin_attendee`, `welcome_checkin`, `set_registration_checked_in` and
> `preview_welcome_checkin` with wider return types, and Postgres refuses
> `create or replace` across a row-type change. So `cat`-ing the 20261019110000
> migration onto the suite now fails with
> `cannot change return type of existing function … Use DROP FUNCTION
> checkin_attendee(uuid,text) first` — that error is the guard working, not a
> broken suite. Run the suite against the live database (as above), or chain the
> **newest** migration instead:
>
> ```sh
> (echo 'begin;'; \
> cat supabase/migrations/20261019160000_welcome_points_and_toggle_restore.sql; \
> sed '/^begin;$/d' supabase/tests/badge_print_tests.sql) \
> | docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
> ```
>
> That chain still reports **113 assertions**.
The SQL fixture is rollback-only: **113 assertions** — six of them added with the
gate and the copies (the badge-print suite owns both functions) — cover the gate
refusing a session check-in for an attendee with no front-desk check-in
(`session check-in requires a front-desk check-in`), the copies loop
(`badge_copies = 3` queues three more labels) and the savepoint that returns the
queue to one so the rest of the run is unaffected, plus
`preview_welcome_checkin`'s new `copies` column: `1` by default, `0` when nothing
would print, `3` after the event is changed. The pre-existing "session check-in
records / enqueues nothing" case now flips `checked_in` on first, because the
gate makes it a precondition.
`set_registration_checked_in_tests.sql` (**24 assertions**, was 15) covers the
admin toggle that grants and revokes the same flag, with its points accounting —
see [Points Correctness Regression](#points-correctness-regression) for what the
extra nine assert.
`front-desk-gate.spec.ts` and `welcome-badge-copies.spec.ts` are real-browser
suites against the local stack (real Auth + PostgREST + pgmq): they provision a
disposable attendee, assert the scanner shows its **"Not checked in yet"** sheet
while recording no check-in, that a session check-in no longer sets the
front-desk flag by itself, that the same scan succeeds once the welcome check-in
is done, that the queue grows by exactly `badge_copies` messages, and
that a re-welcome prints nothing. They delete their own rows and restore
`badge_copies = 1`. `registration-checkin-toggle.spec.ts` is API-mocked and
covers the table behaviour the old build got wrong: no refetch on a toggle or a
type change, row order preserved, only the touched row busy while its checkbox
is disabled, other rows still usable, rollback on a rejected RPC, and the
Settings copies picker saving and reloading.
See [release record](../releases/2026-10-19.md) for the bug this started with.
# Points Correctness Regression
After applying `20261019160000_welcome_points_and_toggle_restore.sql`:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/leaderboard_tests.sql # 57 assertions
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/set_registration_checked_in_tests.sql # 24
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/badge_print_tests.sql # 113
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- checkin-points.spec.ts --project=chromium
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts sessions-view.spec.ts --project=chromium
```
`leaderboard_tests.sql` grew from 47 to **57 assertions**: the front-desk
(welcome) check-in now awards **+10** like a session scan, so it asserts the
first welcome pays out and lands on the registration, a second welcome pays
nothing, welcome-then-session totals 20, and — for each excluded identity (staff
pass, Admin contact, `@appe.at`) — that a welcome still checks the person in while
awarding **nothing** (`points_awarded = false`, `points = 0`). The excluded-identity
loop ends on a non-admin JWT, so the suite restores the admin claims afterwards;
without that the tail assertions silently run as the wrong person.
`set_registration_checked_in_tests.sql` grew from 15 to **24 assertions**, and its
third section was **rewritten because it encoded the bug**: it used to assert
"points unchanged after re-check-in". It now seeds two real `checkins` rows and
asserts the toggle ON re-awards exactly what those rows justify (30), that a
second ON adds 0, that an off→on round trip restores 30 both times, and that a
staff contact's toggle removes 0 and adds 0.
`checkin-points.spec.ts` (4 tests) is the end-to-end proof against the **real**
database, which is what the original complaint needed (the scanner appeared not
to award the +10):
- **CONV-PTS-001** the welcome check-in pays +10, the confirm sheet promises it
*before* the write, the result sheet says `+10 pts · now 10`, the registration
reads 10, and `points_log` holds a `checkin=10` row.
- **CONV-PTS-002** a second welcome says "No extra points" and stays at 10; the
following session scan takes the total to 20.
- **CONV-PTS-003** a staff pass still checks in, but the sheets say "does not
earn points" / "staff earn no points", the score stays 0 and **no `points_log`
row is written** — the exclusion, made visible.
- **CONV-PTS-004** drives `set_registration_checked_in` through the real RPC
(psql has to supply `request.jwt.claims` because `is_admin()` reads
`auth.jwt()`): off removes 20, on restores 20, and a third click adds 0 — no
farming.
`sessions-view.spec.ts` (8 tests) covers the new Sessions view against mocked
APIs: nav order Schedule → **Sessions** → Activity, per-session speaker chips and
check-in counts, the attendee filter narrowing to that person's sessions and
highlighting them in the roster, **one request per session that has feedback**
(none for a session without any), the blocking overlay with its `done / total`
counter and disabled controls, a partial failure reporting which session failed
while the others still land, the stale-summary flag, and the disabled button when
the LLM is unconfigured or nothing has feedback.
# Badge Print Queue Regression
After applying `20261018170000_badge_print_queue`, run the SQL suite **combined
with the migration** in one transaction (the migration is idempotent, so the
same stream also re-verifies an already-applied database):
```sh
(echo 'begin;'; \
cat supabase/migrations/20261018170000_badge_print_queue.sql; \
sed '/^begin;$/d' supabase/tests/badge_print_tests.sql) \
| docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- printing.spec.ts --project=chromium
pytest apps/printer/tests # worker unit tests (no hardware, no browser)
```
The SQL fixture is rollback-only: **113 assertions** (six of them the front-desk
gate and badge copies, covered in the section above) cover queue creation and
migration idempotency, pgmq/API isolation, the self-contained payload shape and
layout resolution (default-with-elements, fallback, none → no job), first-scan
enqueue inside `welcome_checkin` (re-scan enqueues nothing), station token
lifecycle (create shows the token once, only the SHA-256 digest is stored,
rename, revoke → `28000`), claim/complete/fail semantics (visibility timeout,
retry backoff, dead-letter after 3 reads, requeue/discard), the heartbeat
(status cap, name echo) and admin/non-admin/anon authorization.
The browser suite is API-mocked and covers the always-visible printer pill
(ready / error / offline / mobile, click navigates), the offline Wi-Fi setup
hint, add-station token-shown-once, inline rename, dead-letter Requeue/Discard,
completed-job Reprint, the Registrations **Print** button (queue + toast,
offline still queues, no-layout disabled state) and the 5 s overview polling.
The pytest suite covers label composition (die-cut, endless, auto-rotate,
`LayoutTooLarge`), the worker loop (job outcomes, sticky complete, paused
printer), the RPC client error mapping, status mapping and the network-state
reader. No real printer, Pi or attendee data is involved.
See [printing.md](./printing.md) for the feature reference and the
[release record](../releases/2026-10-18.md) for results.
# Badge Editor Regression
After applying `20261015194531_badge_editor`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/badge_layout_tests.sql
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- badge-editor.spec.ts --project=chromium
```
The SQL fixture is rollback-only: fifteen assertions cover creating a default
layout, upserting the same `(event_id, name)` in place, the one-default-per-event
invariant when a new default is saved, per-event scoping, `set_default`
promote/demote, refusing to delete the default while other layouts exist,
deleting a non-default layout, rejecting blank names, and admin/non-admin/anon
authorization (the non-admin read check runs as the real `authenticated` role so
RLS is enforced). The browser suite is API-mocked and covers loading the default
layout onto the millimetre canvas with a bound attendee name, adding/selecting a
text element and its handles, editing `x` to move an element, saving via
`save_badge_layout`, preview mode hiding the handles, the JSON view, a failed
save, the mobile layout, the **Delete key** removing the selection, binding the
**company / organizer** field, **align-centre** on the page, **Shift-click**
multi-select for group alignment, **drag-to-centre smart guides** with snapping,
the labelled **Align text in box** section (its horizontal / vertical buttons
change the rendered text alignment and persist through save and reload), and the
**`Ctrl`+`Z` / `Ctrl`+`Y`** undo / redo shortcuts (ignored while a panel field has
focus). No real attendee data changes.
See [RPC rules](./rpcs.md#badge-editor) and the [Badges view](../frontend/admin-app.md).
# Registration Badge Preview Regression
No migration is involved — the preview reuses the badge layouts above. Run:
```sh
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-badge-preview.spec.ts --project=chromium
```
The suite is API-mocked and covers a **Badge** button on every registration row,
rendering the default layout with **that row's own** name / ticket type / company
and a real QR SVG, per-attendee isolation (one row never shows another's data),
switching layouts inside the modal, hiding the picker when only one layout
exists, the **disabled (grayed-out) Badge button** when the event has no layout
or only an **empty** one, the hover **tooltip** explaining a badge must be
configured first (portalled to `document.body`, so the table never clips it), a
failed layout load leaving the buttons disabled without breaking the list,
layouts loading **once per event** (reused by every preview, no per-open
request), closing via **Done** and the backdrop, and fitting a mobile viewport.
No real attendee data changes.
# Table Filters Regression
No migration is involved — column filters and search are frontend-only. Run:
```sh
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- table-filters.spec.ts --project=chromium
```
The suite is API-mocked and covers the **Contacts** and **Registrations** views:
the general search matching **first name / last name / email** (plus **type** on
Registrations), the per-column **multi-select filters** (Contacts: LinkedIn,
Visibility, Admin; Registrations: Type, Ticket, Checked in), filters **combining**
with each other and the search, **live option counts** that follow the other
active filters (Excel-style), the **active-count badge** on a filter button,
**Clear**, and that the dropdown is **portalled to `document.body`** so the
table's `overflow: hidden` never clips it. No real data changes.
# Raffle Regression
After applying `20261015180640_raffle`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/raffle_tests.sql
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- raffle.spec.ts --project=chromium
```
The SQL fixture is rollback-only: fifteen assertions cover the eligible pool
(excluding staff, Admin, the `@appe.at` domain and the leaderboard top 3),
sequential draw numbers, drawn attendees leaving the pool, the empty-pool
over-draw error, winner persistence, run reset, and admin/non-admin/anon
authorization. The browser suite is API-mocked and covers the default five
picks, the decelerating roulette landing on a winner, drawing until the pick
count, retry after a failed draw, starting a new run, a configurable pick
count, and the mobile layout. No real LLM, email or points change is involved.
See [RPC rules](./rpcs.md#raffle) and the [Raffle view](../frontend/admin-app.md).
# Leaderboard Regression
After applying `20261015164546_leaderboard_staff_admin_exclusion`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/leaderboard_tests.sql
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- leaderboard-live.spec.ts --project=chromium
```
The SQL fixture rolls back and checks scoring, idempotency, event isolation,
staff/Admin zero balances, role changes, deterministic ranking, API-role grants
and Realtime publication membership. The browser test is local-only and uses real
Auth, PostgREST and WebSockets, not mocked APIs. It creates disposable accounts,
verifies live score/rank changes and staff/Admin exclusions, then deletes its
fixtures. It requires the local attendee app, Supabase and an active event.
See [October 15 validation](../releases/2026-10-15.md) for results and scope.
# Feedback AI Summary Regression
After applying only `20261011163332_feedback_ai_summaries`, run:
```sh
npm test --prefix apps/sidecar
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/feedback_ai_summary_tests.sql
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- feedback-ai-summary.spec.ts --project=chromium
```
The SQL fixture is rollback-only: eight assertions cover RLS, grants, deprecated
stub permissions, service-role persistence, admin/non-admin reads and cascades.
Unit tests (**35** in the suite today) cover provider payload privacy,
settings-key redaction and retention, scope isolation, empty feedback, errors,
duplicate requests and private-address rejection and multi-page snapshots, plus
the six `llm-test` verdict checks listed in
[LLM Connection Test Regression](#llm-connection-test-regression).
Eight API-mocked browser tests cover settings,
manual event/session generation, restored summaries, disabled states, pagination,
retry and desktop/mobile layouts.
These tests do not send real feedback to any LLM or send login emails.
See [Feedback AI summaries](./feedback-ai.md) for the request/response contract and
local-only activation status.
# Service Staff Regression
The attendee browser suite also covers demo clock dates for two different events
and real-time mode against a fixed system date:
```sh
CONVIVO_BASE_URL=https://convivo.appe.at npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Event demo clock'
```
These three checks fail if the demo clock falls back to the seed date. They assert
Done/Live/Up next at 10:20 on the event start date, and all Done for a later real
system date with real-time mode enabled.
GridSmart source and automatic-poll regressions:
```sh
npm test --prefix apps/sidecar
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/gridsmart_sync_tests.sql
CONVIVO_ADMIN_URL=https://admin.appe.at npm test --prefix e2e -- sessionize-source.spec.ts --project=chromium
```
Apply `20261011060534_gridsmart_service_identity` first. Seven rollback SQL
assertions cover manual service ID adoption, concurrent placeholder types,
staff assignment, omitted talks/metadata/speakers and repeat-poll idempotence.
Sidecar tests include five source-reader checks, two polling checks and the
existing nine Excel checks. Browser tests cover both input formats and invalid
host rejection without script execution. Actual live startup polling and a
second no-duplicate sync were also verified.
After applying `20261011054613_service_session_staff_assignment`, run:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/service_session_staff_tests.sql
CONVIVO_BASE_URL=https://convivo.appe.at npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Service agenda'
```
The SQL fixture rolls back and covers staff present before session creation,
later staff promotion, unchanged talk speakers, event isolation and idempotence.
Browser fixtures cover service ordering and staff names on mobile and desktop,
including active talk filters. They also cover Placeholder nesting within matching
talk blocks, corrected displayed block counts, filter-independent visibility and
retained no-pick/no-upload service behavior even for an assigned staff speaker.
A separate case checks exact date/time matching and keeps unrelated services
separate. See the [deployment record](../releases/2026-10-11.md).
# Agenda Consistency + Home Picks Regression
Further API-mocked checks run in the same spec:
```sh
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Service agenda|Home session picks'
```
- **Orphan service slot** — a `get_agenda` row whose slot is a
`service_session` with a null session (the LEFT JOIN shape a slot with no
session row produces) must render **no card at all**, so every service card
consistently shows a header plus its session row. The rule lives in
`groupAgenda`, so the list, the displayed slot count and Home's Now/Next all
agree.
- **Home session picks** — tapping a "My picks today" chip opens the shared
`SessionDetail` sheet **over Home** (title, description, time/room/speaker,
level pill, and the "Remove my pick" control) and leaves the active tab on
Home; closing the sheet returns to the pick list. This replaces the old
behavior of routing to the Agenda tab.
- **Pick nudge suppression** — with a pick on the *other* slot, the Now card's
concurrent list must **not** show "No pick yet — tap a session in the Agenda
to choose."; with no picks at all the nudge is still shown. Asserted per card
(`.now-card`), since Now and Next each render their own copy.
- **Service session feedback suppression** — a staff contact who is an assigned
speaker of a finished service slot opens its sheet and must see **no** "Your
session feedback" block, **no** `give-feedback` button and **no** "You weren't
checked in" note (the sheet still shows the title and "No pick needed for this
slot.").
- **Multi-line description** — a `get_agenda` description containing `\n\n`
renders in `#sd-desc` with `white-space: pre-line`; the raw newlines stay in
the DOM and the block measures taller than the same text with collapsed
whitespace.
- **No demo-clock badge** — each "Event demo clock" scenario also opens Home and
asserts "Demo clock" is absent, in both simulated and real-time mode.
The last three cases come from the 2026-10-18 feedback polish; see the
[release record](../releases/2026-10-18.md).
# Session Persistence Regression
Run the rollback-only fixture after applying
`20261010183614_preserve_sessions_on_unchanged_ticket`:
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/session_persistence_tests.sql
```
It verifies unchanged repeated imports preserve the existing password hash and
session, changed ticket passwords revoke sessions, and admin password precedence
survives ticket changes. No fixture accounts remain after rollback.
The production Auth policy was additionally verified with a disposable confirmed
test account: actual refresh succeeded at six days, failed after the seven-day
lifetime, and failed after eight-day inactivity. Cleanup removed the test account;
no real email was sent. See [release record](../releases/2026-10-10.md#follow-up-deployments).
# 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
Assigned-speaker/Pretix role regression tests (rollback-only):
```bash
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009225632_guard_sessionize_dates.sql supabase/migrations/20261010102828_registration_ticket_merge.sql supabase/migrations/20261010111607_preserve_assigned_speaker_role.sql supabase/tests/assigned_speaker_role_tests.sql; } | docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
```
Covers purchased attendee tickets becoming assigned speakers, assignment before
ticket creation, repeated Pretix updates, Excel/Pretix replay, assignment updates,
staff/sponsor precedence, service-session exclusion and other-event isolation.
QR, ticket ID, check-in and points are preserved.
Ticket merge regression tests (rollback-only, including prior date-guard functions
when the local database has not installed that migration):
```bash
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009225632_guard_sessionize_dates.sql supabase/migrations/20261010102828_registration_ticket_merge.sql supabase/tests/registration_ticket_merge_tests.sql; } | docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-ticket-merge.spec.ts --project=chromium
```
Coverage includes ticket-only totals, authorization, cross-event isolation,
last-speaker-safe transfers, duplicate assignments, staff precedence, retained
ticket points/QR/check-in, source activity rejection, import provenance and
Excel/API replay. Browser tests cover immediate check-in feedback and failure
rollback, imported-only merge buttons, suggestions, manual choice, cancel/retry.
```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 |
## Speaker Portal
[speaker_portal_tests.sql](../../supabase/tests/speaker_portal_tests.sql) is an
independent fail-fast suite (`ON_ERROR_STOP`) with generated contacts/events/talks,
temporary snapshots and a single transaction ending in `ROLLBACK`. It needs the
[speaker portal migration](../../supabase/migrations/20261006175631_speaker_portal.sql)
and [staff overlap migration](../../supabase/migrations/20261007153957_speaker_portal_staff_overlap.sql)
on the **local** database. Apply without resetting existing data:
```bash
docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1 --single-transaction < supabase/migrations/20261006175631_speaker_portal.sql
docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1 --single-transaction < supabase/migrations/20261007153957_speaker_portal_staff_overlap.sql
docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1 < supabase/tests/speaker_portal_tests.sql
```
This direct migration application reloads the local API schema but does not
write CLI migration history. It is not a production deployment command. No
database reset is needed; fixture sequence state is not advanced.
The suite checks assigned speaker, non-admin staff and Admin staff access,
unassigned staff, mismatched same-event registrations, attendee assignments,
unregistered assignments, automatic service-session exclusion, active/inactive past/future
events, malformed and cross-session paths, required uploaded objects, Storage
INSERT/UPDATE/DELETE (including UPDATE WITH CHECK) and unchanged registration,
points-log, check-in and leaderboard state. Storage policy checks use the
`authenticated` database role, not a superuser that bypasses RLS. A failed
assertion exits non-zero and connection closure rolls back the transaction.
[speaker-portal.spec.ts](../../e2e/tests/speaker-portal.spec.ts) uses mocked Auth,
REST and Storage responses, without real credentials or mail delivery:
```bash
cd e2e
CONVIVO_BASE_URL=http://127.0.0.1:3000 npx playwright test tests/speaker-portal.spec.ts --project=chromium --reporter=list --output=/tmp/convivo-speaker-results
```
Start Convivo's dev server first. Coverage includes both routes, existing-users-only
link requests, URL scrubbing, callback errors/rejections, StrictMode single-use
implicit/PKCE callbacks, local logout, empty access, upload/replace/remove across
desktop/mobile, failed attachment cleanup and the normal app's check-in gate
after portal login. Mocked tests do not validate live mail delivery, deployment
redirect allowlists or real Storage behavior; the SQL suite validates database
authorization separately. See [screen contract](../frontend/screens.md#speaker-portal),
[API client](../frontend/api-client.md#speaker-portal), [RLS](./rls.md#speaker-portal-authorization)
and [RPCs](./rpcs.md#speaker-portal-rpcs).
## Sessionize Date Guard
[sessionize_date_guard_tests.sql](../../supabase/tests/sessionize_date_guard_tests.sql)
is an independent fail-fast rollback-only suite for the Sessionize API and Excel
RPC date guard. It creates generated event/contact/auth fixtures, precreates
explicit negative slot IDs so successful imports do not allocate sequence values,
and ends with `ROLLBACK`.
To verify the migration and suite together on the local database without
persisting either change:
```bash
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009225632_guard_sessionize_dates.sql supabase/tests/sessionize_date_guard_tests.sql; printf '\nROLLBACK;\n'; } | docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1
```
The nested `BEGIN` warning from the suite is harmless in this rollback-only
check. This command is local validation only; it does not write CLI migration
history and is not a production deployment. Historical rows outside the newly
configured event range are retained by successful imports and need a separately
approved reconciliation if they should be removed or changed.
## Delete Event Schedule
[delete_event_schedule_tests.sql](../../supabase/tests/delete_event_schedule_tests.sql)
is an independent fail-fast rollback-only suite for the admin schedule-clear RPC.
It creates generated contacts/events/auth fixtures, uses explicit negative slot
IDs so fixture setup does not advance `slots_id_seq`, and ends with `ROLLBACK`.
To verify the migration and suite together on the local database without
persisting either change:
```bash
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009231817_delete_event_schedule.sql supabase/tests/delete_event_schedule_tests.sql; printf '\nROLLBACK;\n'; } | docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1
```
The suite checks authenticated admin execution, non-admin rejection, anon
execute denial, missing-event rejection, exact delete counts, unchanged event
selection, registrations, contacts, auth users, sponsors, connections, points,
event feedback, leaderboard and other-event schedule rows. It also proves
cross-event slot/dependent mismatches fail atomically instead of cascading
foreign-event rows. This is local validation only; it does not write migration
history or deploy anything.
## Sessionize Excel Transform
The sidecar's [Excel transform tests](../../apps/sidecar/tests/transform-excel.test.js)
use Node's built-in test runner and the installed `xlsx` dependency. They
generate synthetic workbooks in memory, without real personal data, server
startup, HTTP calls, or database access:
```bash
npm test --prefix apps/sidecar
node --check apps/sidecar/src/transform-excel.js
node --check apps/sidecar/src/server.js
```
Coverage includes the localized topic header, trimmed/case-insensitive header
matching, nonempty Area/Topic fallback, complete comma-separated topic strings,
flattened multi-speaker session grouping, duplicate speaker IDs/emails, singular
Speaker Id fallback, legacy two-sheet plural Speaker Ids, scheduled time and
metadata preservation, service-session classification, and unscheduled-row
filtering. Generated XLSX service regressions also cover an explicit service
sheet alongside flattened talks, a service-only workbook, missing-ID service
classification, duplicate service rows, stable generated IDs across repeated
parses and row reordering, unchanged IDs after duration/description edits,
distinct identities by title/room/date/start, preservation of explicit source
IDs, and exclusion of untitled, invalid-time and ID-less talk rows. See
[service export limitations and accepted service format](./sidecar.md#services-omitted-from-the-accepted-session-export).
Read-only validation of the supplied 2026-10-09 workbook compared its complete
parsed payload against the committed parser: unchanged 21 sessions, 24 speakers,
21 speaker links and zero service sessions. Parsing twice produced identical
payloads. No HTTP import or database writes were performed. Parser repeatability
and the existing RPC external-ID upsert contract support idempotent imports;
these database-free checks do not verify a live import or prove that any
configured API endpoint includes the services missing from Excel.
## 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).
# Staff Auto-Connect + Leaderboard Masking Regression
Migration `20261020120000_staff_auto_connections.sql` (staff are auto-paired
with every non-exempt registration of the event as `accepted` + `auto = true`,
**never** through `accept_connection`, so **never for points**), plus the
Contacts → Registrations points move and the leaderboard name mask
(first name + last-name initial + dot). Re-verify the migration and run its
SQL suite — both safe on an already-applied database (everything rolls back):
```sh
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/migrations/20261020120000_staff_auto_connections.sql
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
-v ON_ERROR_STOP=1 < supabase/tests/staff_auto_connections_tests.sql # 14 assertions
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- leaderboard-live.spec.ts --project=chromium
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- connections.spec.ts --grep CONV-CONN-007 --project=chromium
npm run test:rpc # section 11 covers submit_event_feedback: first submit +5, edit earns nothing, one points_log row, staff earns nothing (self-contained fixtures — green even with the seed drift below)
```
`leaderboard-live.spec.ts` pins the masked display: podium names are exactly
`Board P. / Board P. / Board T.` (rendering order 2nd-1st-3rd), the list shows
`Board F.`, and full names (`Board Player`, `Board Fourth`) must have count 0.
**CONV-CONN-007 was rewritten** by the feature itself: the old spec drove
*manual* staff networking (request → accept → decline), which the auto-pair
made impossible — scanning a staff lanyard now lands on an already-accepted
pair. The rewrite asserts pre-connected lists on both sides, the instant
"You're connected!" toast, `accepted|true` for the pair in the DB (`status`
and the new `auto` flag), and unchanged points plus zero `points_log` rows for
both parties. Its demo identities still ride the seed drift described in
[Full E2E Suite Status](#full-e2e-suite-status) (the whole connections file is
in that known-red list), so the SQL suite above is the real gate for the
backend guarantee.