Files
Convivo/e2e/tests/checkin-attendee.spec.ts
T
17473916a6 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.

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]>
2026-10-19 15:10:20 +02:00

163 lines
6.6 KiB
TypeScript

import { test, expect } from './base';
import { APP_URL, ID } from '../src/helpers/config';
import { login } from '../src/helpers/auth';
import { createUser } from '../src/helpers/multi';
import { db } from '../src/helpers/db';
import { AppPage } from '../src/pages/AppPage';
import { ScanPage } from '../src/pages/ScanPage';
/**
* §8 Staff Welcome Check-In, §9 First-Time Attendee Access, §10 Real-Time
* Welcome Check-In Activation.
*/
test.describe('Welcome Check-In + attendee access', () => {
test('CONV-CHECKIN-001 welcome check-in via QR (manual code) persists state', async ({ page }) => {
const app = new AppPage(page, APP_URL);
const scan = new ScanPage(page);
await login(page, APP_URL, ID.staff);
await app.waitForAdmitted();
// Staff mode + Welcome Check-In.
await app.gotoTab('scan');
await scan.setStaffMode();
await scan.setWelcomeMode();
// Scan ATTENDEE_NEW (manual code = the QR payload). A confirmation popup
// appears first; the attendee is only checked in after confirming.
await scan.scanCode(ID.attendeeNew.qrToken);
await expect(scan.welcomeConfirm()).toBeVisible();
await scan.confirmWelcome();
await expect(scan.welcomeResult()).toBeVisible();
// Backend state is persisted: ATTENDEE_NEW is now welcome-checked-in.
expect(await db.waitForWelcomeCheckedIn(ID.attendeeNew.email)).toBe(true);
});
test('CONV-CHECKIN-002 welcome check-in via manual code is equivalent to QR', async ({ page }) => {
const app = new AppPage(page, APP_URL);
const scan = new ScanPage(page);
await login(page, APP_URL, ID.staff);
await app.waitForAdmitted();
await app.gotoTab('scan');
await scan.setStaffMode();
await scan.setWelcomeMode();
// Manual code input (the same token the QR would carry); confirm the popup.
await scan.scanCode(ID.attendeeNew.qrToken);
await expect(scan.welcomeConfirm()).toBeVisible();
await scan.confirmWelcome();
await expect(scan.welcomeResult()).toBeVisible();
// Equivalent backend state: welcome-checked-in, no session check-in created.
expect(await db.waitForWelcomeCheckedIn(ID.attendeeNew.email)).toBe(true);
// Give the commit a moment, then confirm no session check-in was created.
await new Promise((r) => setTimeout(r, 300));
expect(db.sessionCheckins(ID.attendeeNew.email)).toEqual([]);
});
test('CONV-CHECKIN-003 welcome scan shows a confirm popup; No cancels, Yes checks in', async ({ page }) => {
const app = new AppPage(page, APP_URL);
const scan = new ScanPage(page);
await login(page, APP_URL, ID.staff);
await app.waitForAdmitted();
await app.gotoTab('scan');
await scan.setStaffMode();
await scan.setWelcomeMode();
// Scanning shows a confirmation naming the attendee and the print warning,
// but does NOT check them in yet.
await scan.scanCode(ID.attendeeNew.qrToken);
const confirm = scan.welcomeConfirm();
await expect(confirm).toBeVisible();
await expect(confirm).toContainText(/You are checking in/);
// One label by default, so the singular wording applies. `.` covers the
// typographic apostrophe in the app copy.
await expect(confirm).toContainText(/print this person.s label/i);
expect(db.isWelcomeCheckedIn(ID.attendeeNew.email)).toBe(false);
// "No" dismisses the popup and leaves the attendee unchecked in.
await scan.declineWelcome();
await expect(confirm).toBeHidden();
await new Promise((r) => setTimeout(r, 300));
expect(db.isWelcomeCheckedIn(ID.attendeeNew.email)).toBe(false);
// Scanning again and choosing "Yes" performs the check-in.
await scan.scanCode(ID.attendeeNew.qrToken);
await expect(scan.welcomeConfirm()).toBeVisible();
await scan.confirmWelcome();
await expect(scan.welcomeResult()).toBeVisible();
expect(await db.waitForWelcomeCheckedIn(ID.attendeeNew.email)).toBe(true);
});
test('CONV-ATT-AUTH-001 first-time attendee is gated before welcome check-in', async ({ page }) => {
const app = new AppPage(page, APP_URL);
// ATTENDEE_NEW (never checked in) logs in.
await login(page, APP_URL, ID.attendeeNew);
// The gate is shown; normal functionality is unavailable.
await app.waitForGated();
await expect(page.getByText(/Please see a staff member/)).toBeVisible();
await expect(page.getByTestId('tab-home')).toHaveCount(0);
});
test('CONV-ATT-AUTH-002 attendee activates automatically after staff welcome check-in (real-time)', async ({ browser }) => {
// Two simultaneous contexts: the attendee stays open; the staff checks them in.
const attendee = await createUser(browser, 'attendeeNew');
const staff = await createUser(browser, 'staff');
try {
const aApp = new AppPage(attendee.page, APP_URL);
const sApp = new AppPage(staff.page, APP_URL);
const sScan = new ScanPage(staff.page);
// 1. The attendee logs in and is gated (waiting screen).
await login(attendee.page, APP_URL, ID.attendeeNew);
await aApp.waitForGated();
// 2. The staff (separate context) logs in and performs the welcome check-in.
await login(staff.page, APP_URL, ID.staff);
await sApp.waitForAdmitted();
await sApp.gotoTab('scan');
await sScan.setStaffMode();
await sScan.setWelcomeMode();
await sScan.scanCode(ID.attendeeNew.qrToken);
await sScan.confirmWelcome();
await expect(sScan.welcomeResult()).toBeVisible();
// 3. The attendee's open browser lifts the gate automatically (4s poll) —
// no refresh, no restart, no re-login.
await aApp.waitForAdmitted();
await expect(await aApp.isGated()).toBe(false);
// Home/application content becomes available.
await expect(attendee.page.getByTestId('tab-home')).toBeVisible();
} finally {
await attendee.close();
await staff.close();
}
});
test('CONV-ATT-AUTH-003 returning attendee is not re-gated on re-login', async ({ page }) => {
const app = new AppPage(page, APP_URL);
// ATTENDEE_RETURNING (previously checked in) logs in → admitted directly.
await login(page, APP_URL, ID.attendeeReturning);
await app.waitForAdmitted();
await expect(await app.isGated()).toBe(false);
// Log out, then log in again → still admitted (no staff intervention).
await app.gotoTab('profile');
await page.getByTestId('profile-logout').click();
await page.getByTestId('login-splash').waitFor({ state: 'visible' });
await login(page, APP_URL, ID.attendeeReturning);
await app.waitForAdmitted();
await expect(await app.isGated()).toBe(false);
await expect(page.getByText(/Please see a staff member/)).toHaveCount(0);
});
});