- 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.
128 lines
5.6 KiB
TypeScript
128 lines
5.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 { signInJwt, userRpc, userRpcResult } from '../src/helpers/api';
|
|
import { db } from '../src/helpers/db';
|
|
import { AppPage } from '../src/pages/AppPage';
|
|
import { ScanPage } from '../src/pages/ScanPage';
|
|
import { ConnectionsPage } from '../src/pages/ConnectionsPage';
|
|
import { ProfilePage } from '../src/pages/ProfilePage';
|
|
import { HomePage } from '../src/pages/HomePage';
|
|
|
|
/**
|
|
* CONV-SPONSOR-001 — validate a Sponsor account.
|
|
*
|
|
* A sponsor can log in via the normal participant flow and use the app like any
|
|
* non-staff participant (Home, Agenda, Connections, Profile, connection
|
|
* requests, Show Email / Show LinkedIn). A sponsor must NOT automatically
|
|
* receive Staff privileges: it cannot perform Welcome Check-In or Session
|
|
* Check-In (enforced by the backend, not just the UI).
|
|
*/
|
|
|
|
/** What another user sees for a contact (via the public directory RPC). */
|
|
async function publicView(viewerJwt: string, targetEmail: string) {
|
|
const rows = await userRpc<{ email: string; show_email: boolean; linkedin_url: string | null }[]>(
|
|
viewerJwt,
|
|
'get_public_contacts',
|
|
{},
|
|
);
|
|
return rows.find((r) => r.email === targetEmail) ?? null;
|
|
}
|
|
|
|
test.describe('CONV-SPONSOR-001 — sponsor functionality', () => {
|
|
test('sponsor can use the app like a participant (Home, Agenda, Connections, Profile, privacy)', async ({ browser }) => {
|
|
const sponsor = await createUser(browser, 'sponsor');
|
|
const attendee = await createUser(browser, 'attendeeA');
|
|
try {
|
|
const sApp = new AppPage(sponsor.page, APP_URL);
|
|
const sScan = new ScanPage(sponsor.page);
|
|
const sConns = new ConnectionsPage(sponsor.page);
|
|
const sProfile = new ProfilePage(sponsor.page);
|
|
const aApp = new AppPage(attendee.page, APP_URL);
|
|
const aConns = new ConnectionsPage(attendee.page);
|
|
|
|
// 1. Log in via the normal participant flow (QR + ticket email).
|
|
await login(sponsor.page, APP_URL, ID.sponsor);
|
|
await sApp.waitForAdmitted();
|
|
|
|
// Backend: registration type is 'sponsor' (NOT staff) and checked in.
|
|
expect(db.registration(ID.sponsor.email)?.type).toBe('sponsor');
|
|
expect(db.registration(ID.sponsor.email)?.checkedIn).toBe(true);
|
|
|
|
// 2. Access Home (greeting renders).
|
|
const home = new HomePage(sponsor.page);
|
|
await expect(home.greeting()).toBeVisible();
|
|
|
|
// 3. Access Agenda (the demo timetable renders).
|
|
await sApp.gotoTab('agenda');
|
|
await expect(sApp.eventTitle()).toBeVisible();
|
|
await expect(sponsor.page.getByText(/slots/)).toBeVisible();
|
|
|
|
// 4. Access Profile (save control present).
|
|
await sApp.gotoTab('profile');
|
|
await expect(sponsor.page.getByTestId('profile-save')).toBeVisible();
|
|
|
|
// 5. Send a connection request to an attendee (sponsor networking).
|
|
await sApp.gotoTab('scan');
|
|
await sScan.setAttendeeMode();
|
|
await sScan.scanCode(ID.attendeeA.qrToken);
|
|
await sScan.sendConnection();
|
|
await sConns.gotoRequests();
|
|
expect(await sConns.outgoingContains('Mia Moser')).toBe(true);
|
|
|
|
// 6. The attendee sees the incoming request and accepts it.
|
|
await login(attendee.page, APP_URL, ID.attendeeA);
|
|
await aApp.waitForAdmitted();
|
|
await aConns.gotoRequests();
|
|
await aConns.accept();
|
|
|
|
// 7. The connection is established both ways.
|
|
await aConns.gotoMine();
|
|
expect(await aConns.mineContains('Demo Sponsor')).toBe(true);
|
|
// Force the sponsor's Connections screen to re-fetch (it was already
|
|
// mounted from step 5, so navigate away + back to trigger a fresh load).
|
|
await sApp.gotoTab('home');
|
|
await sConns.gotoMine();
|
|
expect(await sConns.mineContains('Mia Moser')).toBe(true);
|
|
|
|
// 8. Use Show Email + Show LinkedIn (privacy controls work for sponsors).
|
|
await sApp.gotoTab('profile');
|
|
await sProfile.setShowEmail(true);
|
|
await sProfile.setLinkedinUrl('https://linkedin.com/in/demo-sponsor');
|
|
await sProfile.setShowLinkedin(true);
|
|
await sProfile.save();
|
|
// The settings persist (DB).
|
|
expect(db.contact(ID.sponsor.email)?.showEmail).toBe(true);
|
|
expect(db.contact(ID.sponsor.email)?.showLinkedin).toBe(true);
|
|
// The attendee can see the sponsor's email + LinkedIn (via the public RPC).
|
|
const aJwt = await signInJwt(ID.attendeeA.email, ID.attendeeA.qrToken);
|
|
const view = await publicView(aJwt, ID.sponsor.email);
|
|
expect(view?.show_email).toBe(true);
|
|
expect(view?.linkedin_url).toBe('https://linkedin.com/in/demo-sponsor');
|
|
} finally {
|
|
await sponsor.close();
|
|
await attendee.close();
|
|
}
|
|
});
|
|
|
|
test('sponsor does not receive staff privileges (cannot perform check-ins)', async () => {
|
|
// Backend: a sponsor's JWT cannot call welcome_checkin (staff only).
|
|
const sponsorJwt = await signInJwt(ID.sponsor.email, ID.sponsor.qrToken);
|
|
const welcomeRes = await userRpcResult(sponsorJwt, 'welcome_checkin', {
|
|
p_attendee_qr: ID.attendeeNew.qrToken,
|
|
});
|
|
expect(welcomeRes.ok).toBe(false);
|
|
|
|
// Backend: a sponsor's JWT cannot call checkin_attendee (staff only).
|
|
const checkinRes = await userRpcResult(sponsorJwt, 'checkin_attendee', {
|
|
p_attendee_qr: ID.attendeeA.qrToken,
|
|
p_session_id: '37ab7060-3d81-4221-9322-6971e97d1175',
|
|
});
|
|
expect(checkinRes.ok).toBe(false);
|
|
|
|
// The registration type is 'sponsor', not 'staff' (no role elevation).
|
|
expect(db.registration(ID.sponsor.email)?.type).toBe('sponsor');
|
|
});
|
|
});
|