- e2e/: full Playwright suite covering every spec case (staff auth/UI, welcome + session check-in, attendee access/gating, connections, profile visibility, speaker material, sponsor, feedback, E2E journeys, role security matrix). 46/46 passing. - apps/convivo: add data-testid attributes (gate, tabs, scanner, toggles) to support the E2E suite. - test_cases.md: spec-case-to-test coverage map (all cases fully covered). - .gitignore: ignore e2e node_modules/reports/test-results.
122 lines
4.8 KiB
TypeScript
122 lines
4.8 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).
|
|
await scan.scanCode(ID.attendeeNew.qrToken);
|
|
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).
|
|
await scan.scanCode(ID.attendeeNew.qrToken);
|
|
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-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 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);
|
|
});
|
|
});
|