Files
Convivo/e2e/tests/checkin-attendee.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

161 lines
6.5 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/);
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);
});
});