fix(admin): per-row check-in toggle; feat(db): front-desk gate + badge copies
Registrations table felt buggy because both row actions did setBusy(true) -> write -> reloadRegistrations() -> setBusy(false): the list is sorted by points, so a reload made the row you just touched jump (or vanish under a Checked-in filter), and the single `busy` flag disabled every control in the table for the whole request. The fix is per-row in-flight state (busyIds + withRowBusy) and no reload at all: the toggle patches its own row's checked_in plus the points delta the RPC returns, the type change patches `type`; a rejected write rolls both back. Only the touched row is disabled, shows a "Saving…" pulse, and two rows can save at once. Toggle hit area is now 40x41 px with a focus-visible ring. Front-desk gate: checkin_attendee reads registrations.checked_in and raises "This attendee needs to be checked in at the front desk first." when it is not true, and no longer sets checked_in as a side effect. checkins has no INSERT policy, so the RPC is the only write path and the gate cannot be bypassed. The scanner shows a dedicated "Not checked in yet" sheet instead of a toast. Badge copies: events.badge_copies (1..4, default 1). welcome_checkin sends that many pgmq jobs in one transaction (the Pi prints one label per job, so N jobs = N labels; no worker change) and clamps the value again itself. preview_welcome_checkin gained a `copies` column (drop + recreate) so the popup states the real count. Manual reprint still prints exactly one. Set from Settings -> Badge printing (active event) and the Events form, always as a single-column update; the Settings badge section now renders even when the LLM settings call fails. Tests: badge_print 113 (+6), leaderboard 47 (+1), new registration-checkin-toggle (6), front-desk-gate (3), welcome-badge-copies (3); the stale registrations-PATCH mock in registration-ticket-merge now targets set_registration_checked_in, the ambiguous Save button is "Save copies", and the print-copy assertion tolerates the typographic apostrophe. Docs updated (rpcs, schema, printing, tests, admin-app, screens) with a release record; NOT deployed - see docs/releases/2026-10-19.md.
This commit is contained in:
1 parent
c857204cfe
commit
c49a94fe80
27 files changed
+1378
-73
No files matched your search
@@ -0,0 +1,158 @@
|
||||
import { test, expect } from './base';
|
||||
import { APP_URL, EVENT_ID, ID } from '../src/helpers/config';
|
||||
import { login } from '../src/helpers/auth';
|
||||
import { db, psql, psqlScalar, sqlQuote } from '../src/helpers/db';
|
||||
import { AppPage } from '../src/pages/AppPage';
|
||||
import { ScanPage } from '../src/pages/ScanPage';
|
||||
|
||||
/**
|
||||
* Front-desk gate: an attendee must be checked in to the EVENT (the welcome
|
||||
* check-in at the front desk) before they can be scanned into any SESSION.
|
||||
* The database enforces it (`checkin_attendee` raises); the scanner turns that
|
||||
* into a dedicated sheet so staff can relay it to the attendee.
|
||||
*
|
||||
* These specs provision their own attendee and pick a real session from the
|
||||
* active event instead of relying on seeded demo rows, so they survive data
|
||||
* re-imports (the historic fixtures were replaced by imported pretix data).
|
||||
*/
|
||||
|
||||
const GATE_EMAIL = '[email protected]';
|
||||
const GATE_TOKEN = 'CVV-GATE-TEST-01';
|
||||
const GATE_NAME = 'Gate Test Attendee';
|
||||
|
||||
/** Ensure a known ticketed attendee exists in the active event, unchecked in. */
|
||||
function ensureGateAttendee(): void {
|
||||
psql(`insert into public.contacts (email, full_name, is_admin)
|
||||
values (${sqlQuote(GATE_EMAIL)}, ${sqlQuote(GATE_NAME)}, false)
|
||||
on conflict (email) do update set full_name = excluded.full_name`);
|
||||
psql(`insert into public.registrations (event_id, contact_email, type, checked_in, points, qr_token)
|
||||
values (${sqlQuote(EVENT_ID)}, ${sqlQuote(GATE_EMAIL)}, 'attendee', false, 0, ${sqlQuote(GATE_TOKEN)})
|
||||
on conflict (event_id, contact_email)
|
||||
do update set checked_in = false, points = 0, qr_token = excluded.qr_token, type = 'attendee'`);
|
||||
}
|
||||
|
||||
function removeGateAttendee(): void {
|
||||
psql(`delete from public.checkins where contact_email = ${sqlQuote(GATE_EMAIL)}`);
|
||||
// The welcome scan in CONV-GATE-002 legitimately queued a label; with no Pi
|
||||
// attached locally it would sit in the queue forever, so drop it here.
|
||||
psql(`delete from pgmq.q_badge_print where message->'sample'->>'email' = ${sqlQuote(GATE_EMAIL)}`);
|
||||
psql(`delete from public.registrations where contact_email = ${sqlQuote(GATE_EMAIL)}`);
|
||||
psql(`delete from public.contacts where email = ${sqlQuote(GATE_EMAIL)}`);
|
||||
}
|
||||
|
||||
/** Any checkable (non-service) session of the active event. */
|
||||
function someSessionId(): string {
|
||||
return psqlScalar(`select s.id from public.sessions s
|
||||
join public.slots sl on sl.id = s.slot_id
|
||||
where s.event_id = ${sqlQuote(EVENT_ID)} and sl.type <> 'service_session'
|
||||
order by sl.id, s.id limit 1`);
|
||||
}
|
||||
|
||||
function setWelcome(checkedIn: boolean): void {
|
||||
psql(`update public.registrations set checked_in = ${checkedIn}
|
||||
where contact_email = ${sqlQuote(GATE_EMAIL)} and event_id = ${sqlQuote(EVENT_ID)}`);
|
||||
}
|
||||
|
||||
test.describe('Front-desk gate (no session check-in before welcome check-in)', () => {
|
||||
test.beforeEach(() => {
|
||||
ensureGateAttendee();
|
||||
removeGateAttendeeCheckins();
|
||||
});
|
||||
test.afterAll(() => removeGateAttendee());
|
||||
|
||||
test('CONV-GATE-001 a session scan of an unchecked attendee is refused with a front-desk message', async ({ page }) => {
|
||||
const app = new AppPage(page, APP_URL);
|
||||
const scan = new ScanPage(page);
|
||||
const session = someSessionId();
|
||||
expect(session, 'the active event needs at least one checkable session').toBeTruthy();
|
||||
|
||||
await login(page, APP_URL, ID.staff);
|
||||
await app.waitForAdmitted();
|
||||
await app.gotoTab('scan');
|
||||
await scan.setStaffMode();
|
||||
await scan.setSessionMode();
|
||||
await scan.selectSession(session);
|
||||
|
||||
await scan.scanCode(GATE_TOKEN);
|
||||
|
||||
// A blocking sheet, not a transient toast.
|
||||
await expect(scan.frontDeskSheet()).toBeVisible();
|
||||
await expect(scan.frontDeskSheet()).toContainText(/front desk/i);
|
||||
// No session result, and nothing persisted.
|
||||
await expect(scan.sessionResult()).toHaveCount(0);
|
||||
expect(db.sessionCheckins(GATE_EMAIL)).toEqual([]);
|
||||
expect(db.isWelcomeCheckedIn(GATE_EMAIL)).toBe(false);
|
||||
|
||||
// Acknowledging clears it (and re-arms the camera via `paused`).
|
||||
await scan.dismissFrontDesk();
|
||||
await expect(scan.frontDeskSheet()).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('CONV-GATE-002 after the welcome check-in the same session scan succeeds', async ({ page }) => {
|
||||
const app = new AppPage(page, APP_URL);
|
||||
const scan = new ScanPage(page);
|
||||
const session = someSessionId();
|
||||
expect(session).toBeTruthy();
|
||||
|
||||
await login(page, APP_URL, ID.staff);
|
||||
await app.waitForAdmitted();
|
||||
await app.gotoTab('scan');
|
||||
await scan.setStaffMode();
|
||||
|
||||
// 1. Blocked in session mode.
|
||||
await scan.setSessionMode();
|
||||
await scan.selectSession(session);
|
||||
await scan.scanCode(GATE_TOKEN);
|
||||
await expect(scan.frontDeskSheet()).toBeVisible();
|
||||
await scan.dismissFrontDesk();
|
||||
|
||||
// 2. Welcome (front desk) check-in.
|
||||
await scan.setWelcomeMode();
|
||||
await scan.scanWelcome(GATE_TOKEN);
|
||||
expect(await db.waitForWelcomeCheckedIn(GATE_EMAIL)).toBe(true);
|
||||
await scan.dismissResult();
|
||||
|
||||
// 3. The very same session scan now goes through.
|
||||
await scan.setSessionMode();
|
||||
await scan.selectSession(session);
|
||||
await scan.scanCode(GATE_TOKEN);
|
||||
await expect(scan.sessionResult()).toBeVisible();
|
||||
expect(await db.waitForSessionCheckin(GATE_EMAIL, session)).toBe(true);
|
||||
});
|
||||
|
||||
test('CONV-GATE-003 a session check-in no longer checks the attendee into the event by itself', async ({ page }) => {
|
||||
const app = new AppPage(page, APP_URL);
|
||||
const scan = new ScanPage(page);
|
||||
const session = someSessionId();
|
||||
expect(session).toBeTruthy();
|
||||
|
||||
// Front desk already done, so the gate is open — but the event flag is then
|
||||
// cleared by hand to prove the session check-in does not set it again.
|
||||
setWelcome(true);
|
||||
|
||||
await login(page, APP_URL, ID.staff);
|
||||
await app.waitForAdmitted();
|
||||
await app.gotoTab('scan');
|
||||
await scan.setStaffMode();
|
||||
await scan.setSessionMode();
|
||||
await scan.selectSession(session);
|
||||
|
||||
setWelcome(false); // undo the precondition: now the gate must refuse
|
||||
await scan.scanCode(GATE_TOKEN);
|
||||
await expect(scan.frontDeskSheet()).toBeVisible();
|
||||
expect(db.sessionCheckins(GATE_EMAIL)).toEqual([]);
|
||||
|
||||
setWelcome(true);
|
||||
await scan.dismissFrontDesk();
|
||||
await scan.scanCode(GATE_TOKEN);
|
||||
await expect(scan.sessionResult()).toBeVisible();
|
||||
expect(await db.waitForSessionCheckin(GATE_EMAIL, session)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
function removeGateAttendeeCheckins(): void {
|
||||
psql(`delete from public.checkins where contact_email = ${sqlQuote(GATE_EMAIL)}`);
|
||||
psql(`delete from pgmq.q_badge_print where message->'sample'->>'email' = ${sqlQuote(GATE_EMAIL)}`);
|
||||
psql(`update public.registrations set checked_in = false, points = 0
|
||||
where contact_email = ${sqlQuote(GATE_EMAIL)}`);
|
||||
}
|
||||
Reference in new issue
Block a user