- 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. 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]>
314 lines
14 KiB
TypeScript
314 lines
14 KiB
TypeScript
import path from 'node:path';
|
||
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 { signInJwt, 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 { AgendaPage } from '../src/pages/AgendaPage';
|
||
import { HomePage } from '../src/pages/HomePage';
|
||
import { FeedbackPage } from '../src/pages/FeedbackPage';
|
||
|
||
/**
|
||
* §38 End-to-end journeys + §39 Role security matrix.
|
||
*
|
||
* CONV-E2E-001: First-time attendee complete journey (3 contexts).
|
||
* CONV-E2E-002: Speaker journey (login → pending material → upload → done).
|
||
* Role security matrix: backend authorization checks across roles.
|
||
*/
|
||
|
||
/** The speaker's session title (slot 1). */
|
||
const SPEAKER_SESSION_TITLE = 'From Vision to Reality';
|
||
/** SESSION_B title (slot 2, "now" — not done). */
|
||
const SESSION_B_TITLE = '10 Essential tips to kickstart Power Platform Governance';
|
||
|
||
/** A small, valid test file for the material upload. */
|
||
const MATERIAL_FILE = path.join(__dirname, '..', 'fixtures', 'material.txt');
|
||
|
||
/** Poll until a session has material (robust against commit timing). */
|
||
async function waitForMaterial(sessionId: string, timeoutMs = 5000): Promise<boolean> {
|
||
const deadline = Date.now() + timeoutMs;
|
||
for (;;) {
|
||
if (db.sessionHasMaterial(sessionId)) return true;
|
||
if (Date.now() > deadline) return db.sessionHasMaterial(sessionId);
|
||
await new Promise((r) => setTimeout(r, 200));
|
||
}
|
||
}
|
||
|
||
test.describe('E2E Journeys', () => {
|
||
test('CONV-E2E-001 first-time attendee complete journey', async ({ browser }) => {
|
||
// Three isolated contexts: the new attendee, the staff, and a second
|
||
// attendee (ATTENDEE_B) for the connection sub-journey.
|
||
const attendee = await createUser(browser, 'attendeeNew');
|
||
const staff = await createUser(browser, 'staff');
|
||
const other = await createUser(browser, 'attendeeB');
|
||
try {
|
||
const aApp = new AppPage(attendee.page, APP_URL);
|
||
const aScan = new ScanPage(attendee.page);
|
||
const aConns = new ConnectionsPage(attendee.page);
|
||
const aAgenda = new AgendaPage(attendee.page);
|
||
const sApp = new AppPage(staff.page, APP_URL);
|
||
const sScan = new ScanPage(staff.page);
|
||
const oApp = new AppPage(other.page, APP_URL);
|
||
const oConns = new ConnectionsPage(other.page);
|
||
|
||
// 1–2. The new attendee logs in and is gated (waiting screen).
|
||
await login(attendee.page, APP_URL, ID.attendeeNew);
|
||
await aApp.waitForGated();
|
||
await expect(attendee.page.getByText(/Please see a staff member/)).toBeVisible();
|
||
await expect(attendee.page.getByTestId('tab-home')).toHaveCount(0);
|
||
|
||
// 3–6. 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();
|
||
|
||
// Backend: the attendee is now welcome-checked-in.
|
||
expect(await db.waitForWelcomeCheckedIn(ID.attendeeNew.email)).toBe(true);
|
||
|
||
// Dismiss the welcome result sheet so it doesn't intercept later clicks.
|
||
await sScan.dismissResult();
|
||
|
||
// 7. 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);
|
||
|
||
// 8–11. The app is fully usable: Home, Agenda, Connections, Profile.
|
||
const home = new HomePage(attendee.page);
|
||
await expect(home.greeting()).toBeVisible();
|
||
await expect(attendee.page.getByTestId('tab-home')).toBeVisible();
|
||
await aApp.gotoTab('agenda');
|
||
await expect(aApp.eventTitle()).toBeVisible();
|
||
await aApp.gotoTab('connections');
|
||
await expect(attendee.page.getByTestId('connections-tab-mine')).toBeVisible();
|
||
await aApp.gotoTab('profile');
|
||
await expect(attendee.page.getByTestId('profile-save')).toBeVisible();
|
||
|
||
// 12–14. ATTENDEE_NEW scans ATTENDEE_B and sends a connection request.
|
||
await aApp.gotoTab('scan');
|
||
await aScan.setAttendeeMode();
|
||
await aScan.scanCode(ID.attendeeB.qrToken);
|
||
await aScan.sendConnection();
|
||
await aConns.gotoRequests();
|
||
expect(await aConns.outgoingContains('Jonas Unger')).toBe(true);
|
||
|
||
// 15–17. ATTENDEE_B observes the incoming request and accepts it.
|
||
await login(other.page, APP_URL, ID.attendeeB);
|
||
await oApp.waitForAdmitted();
|
||
await oConns.gotoRequests();
|
||
await oConns.accept();
|
||
|
||
// 18–19. The established connection is visible from both parties.
|
||
await oConns.gotoMine();
|
||
expect(await oConns.mineContains('Lena Huber')).toBe(true);
|
||
// Force the attendee's Connections screen to re-fetch (it was already
|
||
// mounted, so navigate away + back to trigger a fresh load).
|
||
await aApp.gotoTab('home');
|
||
await aConns.gotoMine();
|
||
expect(await aConns.mineContains('Jonas Unger')).toBe(true);
|
||
|
||
// 20–22. STAFF_01 selects SESSION_A and checks ATTENDEE_NEW into it.
|
||
await sApp.gotoTab('scan');
|
||
await sScan.setSessionMode();
|
||
await sScan.selectSession(SESSION_A);
|
||
await sScan.scanCode(ID.attendeeNew.qrToken);
|
||
await expect(sScan.sessionResult()).toBeVisible();
|
||
// Backend: SESSION_A attendance is persisted.
|
||
expect(await db.waitForSessionCheckin(ID.attendeeNew.email, SESSION_A)).toBe(true);
|
||
|
||
// 23–24. SESSION_A feedback becomes available; SESSION_B remains unavailable.
|
||
await aApp.gotoTab('agenda');
|
||
await aAgenda.openSession('From Vision to Reality');
|
||
await expect(aAgenda.giveFeedbackButton()).toBeVisible();
|
||
await attendee.page.getByRole('button', { name: '✕' }).click();
|
||
await aAgenda.openSession(SESSION_B_TITLE);
|
||
await expect(aAgenda.giveFeedbackButton()).toHaveCount(0);
|
||
await attendee.page.getByRole('button', { name: '✕' }).click();
|
||
|
||
// 25–27. Navigate away, then return: SESSION_A feedback is still available.
|
||
await aApp.gotoTab('home');
|
||
await aApp.gotoTab('agenda');
|
||
await aAgenda.openSession('From Vision to Reality');
|
||
await expect(aAgenda.giveFeedbackButton()).toBeVisible();
|
||
|
||
// 28. Submit SESSION_A feedback.
|
||
await aAgenda.giveFeedbackButton().click();
|
||
const feedback = new FeedbackPage(attendee.page);
|
||
await feedback.rate(5);
|
||
await feedback.setComment('Great journey!');
|
||
await feedback.submit();
|
||
// Backend: the feedback is persisted for (ATTENDEE_NEW, SESSION_A).
|
||
const fbRows = db.feedback(ID.attendeeNew.email);
|
||
expect(fbRows.some((r) => r.sessionId === SESSION_A)).toBe(true);
|
||
|
||
// 29–32. Logout, log in again: Welcome Check-In is not requested again,
|
||
// and normal functionality remains available.
|
||
await aApp.gotoTab('profile');
|
||
await attendee.page.getByTestId('profile-logout').click();
|
||
await attendee.page.getByTestId('login-splash').waitFor({ state: 'visible' });
|
||
await login(attendee.page, APP_URL, ID.attendeeNew);
|
||
await aApp.waitForAdmitted();
|
||
await expect(await aApp.isGated()).toBe(false);
|
||
await expect(attendee.page.getByText(/Please see a staff member/)).toHaveCount(0);
|
||
await expect(home.greeting()).toBeVisible();
|
||
} finally {
|
||
await attendee.close();
|
||
await staff.close();
|
||
await other.close();
|
||
}
|
||
});
|
||
|
||
test('CONV-E2E-002 speaker journey: login → material → networking → participant functionality', async ({ browser }) => {
|
||
// Two contexts: the speaker and an attendee (for the networking sub-journey).
|
||
const speaker = await createUser(browser, 'speaker');
|
||
const attendee = await createUser(browser, 'attendeeA');
|
||
try {
|
||
const app = new AppPage(speaker.page, APP_URL);
|
||
const scan = new ScanPage(speaker.page);
|
||
const conns = new ConnectionsPage(speaker.page);
|
||
const agenda = new AgendaPage(speaker.page);
|
||
const aApp = new AppPage(attendee.page, APP_URL);
|
||
const aConns = new ConnectionsPage(attendee.page);
|
||
|
||
// 1. The speaker logs in and is admitted.
|
||
await login(speaker.page, APP_URL, ID.speaker);
|
||
await app.waitForAdmitted();
|
||
|
||
// 2. The pending-material pill is visible (the speaker's session has no material).
|
||
const home = new HomePage(speaker.page);
|
||
await expect(home.materialPill()).toBeVisible();
|
||
|
||
// 3. Open the session in the Agenda — the upload notice is visible.
|
||
await app.gotoTab('agenda');
|
||
await agenda.openSession(SPEAKER_SESSION_TITLE);
|
||
await expect(agenda.materialUploadInput()).toBeVisible();
|
||
|
||
// 4. Upload the material.
|
||
await agenda.uploadMaterial(MATERIAL_FILE);
|
||
|
||
// 5. Backend: the session now has material.
|
||
expect(await waitForMaterial(SESSION_A)).toBe(true);
|
||
|
||
// 6. Reload so the app picks up the updated session data, then verify
|
||
// the "Download material" link is visible.
|
||
await speaker.page.reload({ waitUntil: 'domcontentloaded' });
|
||
await app.waitForAdmitted();
|
||
await app.gotoTab('agenda');
|
||
await agenda.openSession(SPEAKER_SESSION_TITLE);
|
||
await expect(speaker.page.getByText(/Download material/)).toBeVisible();
|
||
// Close the session sheet.
|
||
await speaker.page.getByRole('button', { name: '✕' }).click();
|
||
|
||
// 7. Verify normal participant functionality: Agenda + Profile.
|
||
await app.gotoTab('profile');
|
||
await expect(speaker.page.getByTestId('profile-save')).toBeVisible();
|
||
|
||
// 8. Send a connection request to an attendee (speaker networking).
|
||
await app.gotoTab('scan');
|
||
await scan.setAttendeeMode();
|
||
await scan.scanCode(ID.attendeeA.qrToken);
|
||
await scan.sendConnection();
|
||
await conns.gotoRequests();
|
||
expect(await conns.outgoingContains('Mia Moser')).toBe(true);
|
||
|
||
// 9. 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();
|
||
|
||
// 10. The connection is established both ways.
|
||
await aConns.gotoMine();
|
||
expect(await aConns.mineContains('Duncan Boyne')).toBe(true);
|
||
// Force the speaker's Connections screen to re-fetch (it was already
|
||
// mounted, so navigate away + back to trigger a fresh load).
|
||
await app.gotoTab('home');
|
||
await conns.gotoMine();
|
||
expect(await conns.mineContains('Mia Moser')).toBe(true);
|
||
|
||
// 11. The speaker remains able to use all normal participant functionality.
|
||
await app.gotoTab('agenda');
|
||
await expect(app.eventTitle()).toBeVisible();
|
||
await app.gotoTab('profile');
|
||
await expect(speaker.page.getByTestId('profile-save')).toBeVisible();
|
||
} finally {
|
||
await speaker.close();
|
||
await attendee.close();
|
||
}
|
||
});
|
||
});
|
||
|
||
test.describe('Role Security Matrix (§39)', () => {
|
||
test('welcome_checkin: only staff can call (non-staff → error)', async () => {
|
||
// Staff can call welcome_checkin (takes the attendee's QR token).
|
||
const staffJwt = await signInJwt(ID.staff.email, ID.staff.password!);
|
||
const staffResult = await userRpcResult(staffJwt, 'welcome_checkin', {
|
||
p_attendee_qr: ID.attendeeNew.qrToken,
|
||
});
|
||
expect(staffResult.ok).toBe(true);
|
||
|
||
// A non-staff attendee cannot call welcome_checkin.
|
||
const attendeeJwt = await signInJwt(ID.attendeeA.email, ID.attendeeA.qrToken);
|
||
const attendeeResult = await userRpcResult(attendeeJwt, 'welcome_checkin', {
|
||
p_attendee_qr: ID.attendeeB.qrToken,
|
||
});
|
||
expect(attendeeResult.ok).toBe(false);
|
||
});
|
||
|
||
test('checkin_attendee: only staff can call (non-staff → error)', async () => {
|
||
// Staff can call checkin_attendee (session check-in; takes QR + session).
|
||
const staffJwt = await signInJwt(ID.staff.email, ID.staff.password!);
|
||
const staffResult = await userRpcResult(staffJwt, 'checkin_attendee', {
|
||
p_attendee_qr: ID.attendeeA.qrToken,
|
||
p_session_id: SESSION_A,
|
||
});
|
||
expect(staffResult.ok).toBe(true);
|
||
|
||
// A non-staff attendee cannot call checkin_attendee.
|
||
const attendeeJwt = await signInJwt(ID.attendeeB.email, ID.attendeeB.qrToken);
|
||
const attendeeResult = await userRpcResult(attendeeJwt, 'checkin_attendee', {
|
||
p_attendee_qr: ID.attendeeC.qrToken,
|
||
p_session_id: SESSION_A,
|
||
});
|
||
expect(attendeeResult.ok).toBe(false);
|
||
});
|
||
|
||
test('set_session_material: only speaker/admin can call (attendee → error)', async () => {
|
||
// The speaker can call set_session_material for their own session.
|
||
const speakerJwt = await signInJwt(ID.speaker.email, ID.speaker.qrToken);
|
||
const speakerResult = await userRpcResult(speakerJwt, 'set_session_material', {
|
||
p_session_id: SESSION_A,
|
||
p_material_path: 'sessions/test/security-matrix.txt',
|
||
});
|
||
expect(speakerResult.ok).toBe(true);
|
||
|
||
// An attendee cannot call set_session_material.
|
||
const attendeeJwt = await signInJwt(ID.attendeeA.email, ID.attendeeA.qrToken);
|
||
const attendeeResult = await userRpcResult(attendeeJwt, 'set_session_material', {
|
||
p_session_id: SESSION_A,
|
||
p_material_path: 'sessions/test/attendee-should-fail.txt',
|
||
});
|
||
expect(attendeeResult.ok).toBe(false);
|
||
});
|
||
|
||
test('submit_feedback: only for attended sessions (not checked in → error)', async () => {
|
||
// An attendee who is NOT checked in to SESSION_A cannot submit feedback.
|
||
const attendeeJwt = await signInJwt(ID.attendeeD.email, ID.attendeeD.qrToken);
|
||
const result = await userRpcResult(attendeeJwt, 'submit_feedback', {
|
||
p_session_id: SESSION_A,
|
||
p_rating: 5,
|
||
p_comment: 'Security matrix test',
|
||
});
|
||
expect(result.ok).toBe(false);
|
||
expect(result.message).toMatch(/checked in/i);
|
||
});
|
||
});
|