Files
Convivo/docs/backend/tests.md
T
Lago 6bde90aac1 fix(convivo): readable descriptions, no feedback UI on service sessions, no demo-clock badge
Three attendee-app polish items from hands-on testing (Sabrina). All
presentation-layer: no migration, no RPC, no admin/sidecar change.

- Session detail collapsed multi-paragraph descriptions into one block. The
  feed carries real newlines (the sidecar passes Sessionize description through
  untouched), so this was pure CSS: new .sd-desc uses white-space: pre-line.
  The AI feedback summary gets the same via .feedback-review .fr-text.
- Staff saw "Your session feedback" on Break/Lunch cards, because
  _assign_service_session_speakers makes every staff member a speaker of every
  service slot. showFeedback = !isService now gates all three feedback surfaces
  (review block, Give-feedback button, "not checked in" note). The sheet itself
  stays openable for service sessions.
- Removed the "Demo clock" badge from the Home header. The simulated clock is an
  internal demo aid; attendees were never meant to see it. useEvent() still
  exposes clockMode and the admin toggle is unchanged.

Tests: three new API-mocked cases in convivo-admin-entry.spec.ts (service
feedback suppression, multi-line description via pre-line CSS + exact textContent
+ rendered-height comparison, no demo-clock badge per clock mode). 45/45 green
against the local dev server; attendee build clean.

Docs synced: screens.md, app-structure.md, backend/tests.md, next-steps.md, plus
a release record at docs/releases/2026-10-18.md noting that items 1/3/7 of the
report were already shipped (ef0446d, 999527b) and that this change is not yet
deployed.
2026-10-18 18:20:16 +02:00

22 KiB

Badge Editor Regression

After applying 20261015194531_badge_editor, run:

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 and the Badges view.

Registration Badge Preview Regression

No migration is involved — the preview reuses the badge layouts above. Run:

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:

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:

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 and the Raffle view.

Leaderboard Regression

After applying 20261015164546_leaderboard_staff_admin_exclusion, run:

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 for results and scope.

Feedback AI Summary Regression

After applying only 20261011163332_feedback_ai_summaries, run:

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 cover provider payload privacy, settings-key redaction and retention, scope isolation, empty feedback, errors, duplicate requests and private-address rejection and multi-page snapshots. 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 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:

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:

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:

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.

Agenda Consistency + Home Picks Regression

Further API-mocked checks run in the same spec:

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.

Session Persistence Regression

Run the rollback-only fixture after applying 20261010183614_preserve_sessions_on_unchanged_ticket:

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.

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):

{ 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):

{ 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.

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:

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() 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 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 and staff overlap migration on the local database. Apply without resetting existing data:

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 uses mocked Auth, REST and Storage responses, without real credentials or mail delivery:

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, API client, RLS and RPCs.

Sessionize Date Guard

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:

{ 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 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:

{ 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 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:

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.

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