Files
Convivo/e2e/tests/session-checkin.spec.ts
T
Lago 9a6e2e5c2a feat(scan): confirm before welcome check-in, with print warning
The staff scanner checked attendees in silently, and the default session
mode never prints — so a welcome-desk scan could check someone in with no
badge and no confirmation.

- new read-only RPC preview_welcome_checkin(qr): resolves the attendee and
  reports already + will_print (mirrors the exact welcome_checkin enqueue
  condition: first check-in AND a layout exists). Staff/admin only; checks
  nobody in, enqueues nothing.
- attendee Scan screen previews first and shows a Yes/No sheet: "You are
  checking in [Name]. By confirming, you will print this person's label."
  Only Yes runs welcome_checkin. Session check-in unchanged (never prints).
- badge_print_tests.sql +8 assertions (109 total); ScanPage + welcome specs
  drive the confirm step; new CONV-CHECKIN-003 (No cancels, Yes checks in).
- docs: rpcs.md, printing.md, releases/2026-10-19.md.
2026-10-19 09:45:20 +02:00

96 lines
3.7 KiB
TypeScript

import { test, expect } from './base';
import { APP_URL, ID, SESSION_A, SESSION_B } 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';
/**
* §21–§23 Session Check-In + Welcome/Session independence.
*/
test.describe('Session Check-In', () => {
test('CONV-SESSION-001 staff checks an attendee into a session (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.setSessionMode();
// SESSION_A is explicitly selected.
await scan.selectSession(SESSION_A);
// Scan ATTENDEE_A and complete the check-in.
await scan.scanCode(ID.attendeeA.qrToken);
await expect(scan.sessionResult()).toBeVisible();
// Attendance is registered for (ATTENDEE_A, SESSION_A) and persisted.
expect(await db.waitForSessionCheckin(ID.attendeeA.email, SESSION_A)).toBe(true);
// Attendance is NOT automatically created for other sessions.
const checkins = db.sessionCheckins(ID.attendeeA.email);
expect(checkins).toContain(SESSION_A);
expect(checkins).not.toContain(SESSION_B);
});
test('CONV-SESSION-002 session 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.setSessionMode();
await scan.selectSession(SESSION_A);
// Manual code input (the same token the QR would carry).
await scan.scanCode(ID.attendeeA.qrToken);
await expect(scan.sessionResult()).toBeVisible();
// Equivalent backend state: (ATTENDEE_A, SESSION_A) checked in.
expect(await db.waitForSessionCheckin(ID.attendeeA.email, SESSION_A)).toBe(true);
});
test('CONV-SESSION-003 welcome check-in and session check-in are independent states', 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');
// 1. Welcome check-in only (no session). A confirmation popup appears
// first; confirm it before the attendee is checked in.
await scan.setWelcomeMode();
await scan.scanCode(ID.attendeeA.qrToken);
await expect(scan.welcomeConfirm()).toBeVisible();
await scan.confirmWelcome();
await expect(scan.welcomeResult()).toBeVisible();
expect(await db.waitForWelcomeCheckedIn(ID.attendeeA.email)).toBe(true);
// Welcome check-in must NOT create any session attendance.
await new Promise((r) => setTimeout(r, 300));
expect(db.sessionCheckins(ID.attendeeA.email)).toEqual([]);
// Dismiss the result sheet so its backdrop doesn't block the mode toggle.
await scan.dismissResult();
// 2. Now a session check-in (SESSION_A) — a distinct, session-specific state.
await scan.setSessionMode();
await scan.selectSession(SESSION_A);
await scan.scanCode(ID.attendeeA.qrToken);
await expect(scan.sessionResult()).toBeVisible();
expect(await db.waitForSessionCheckin(ID.attendeeA.email, SESSION_A)).toBe(true);
// The session check-in references a specific session (SESSION_A, not SESSION_B).
const checkins = db.sessionCheckins(ID.attendeeA.email);
expect(checkins).toContain(SESSION_A);
expect(checkins).not.toContain(SESSION_B);
});
});