Add Playwright E2E suite (46 tests) + app testids + test_cases.md
- 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.
This commit is contained in:
1 parent
e4c8815e52
commit
692df23149
44 files changed
+3715
-26
No files matched your search
@@ -0,0 +1,119 @@
|
||||
import { test, expect } from './base';
|
||||
import { APP_URL, ID } from '../src/helpers/config';
|
||||
import { toScanStep } from '../src/helpers/auth';
|
||||
import { signInJwt } from '../src/helpers/api';
|
||||
import { AppPage } from '../src/pages/AppPage';
|
||||
|
||||
/**
|
||||
* §6 Staff Authentication.
|
||||
*
|
||||
* In this app the staff identity is provided via the lanyard QR (which resolves
|
||||
* to the staff contact — i.e. the staff's email), and the staff password is
|
||||
* always required. CONV-STAFF-AUTH-001 ("email + password") and -002 ("QR +
|
||||
* password") therefore both exercise the same QR→identity + password flow; the
|
||||
* QR is what carries the identity (the staff's email).
|
||||
*/
|
||||
|
||||
test.describe('CONV-STAFF-AUTH', () => {
|
||||
test('CONV-STAFF-AUTH-001 staff login (identity + password) succeeds and loads the demo event', async ({ page }) => {
|
||||
const app = new AppPage(page, APP_URL);
|
||||
await toScanStep(page, APP_URL);
|
||||
|
||||
// Provide the staff identity (QR) + the correct staff password.
|
||||
await page.getByTestId('scanner-manual-code').fill(ID.staff.qrToken);
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('staff-login-password').fill(ID.staff.password!);
|
||||
await page.getByTestId('login-confirm').click();
|
||||
|
||||
// Admitted: the tab bar is visible and the staff is recognized.
|
||||
await app.waitForAdmitted();
|
||||
await expect(await app.isGated()).toBe(false);
|
||||
|
||||
// Staff functionality is available: the Scan screen offers the Staff mode.
|
||||
await app.gotoTab('scan');
|
||||
await expect(page.getByTestId('scan-mode-staff')).toBeVisible();
|
||||
|
||||
// The Demo Event + timetable load.
|
||||
await app.gotoTab('agenda');
|
||||
await expect(app.eventTitle()).toBeVisible();
|
||||
await expect(page.getByText(/slots/)).toBeVisible();
|
||||
|
||||
// No authentication error remains visible.
|
||||
await expect(page.getByTestId('login-error')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('CONV-STAFF-AUTH-002 staff login via QR + password succeeds', async ({ page }) => {
|
||||
const app = new AppPage(page, APP_URL);
|
||||
await toScanStep(page, APP_URL);
|
||||
|
||||
// The QR resolves to the staff (the confirm screen shows "Staff sign in").
|
||||
await page.getByTestId('scanner-manual-code').fill(ID.staff.qrToken);
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await expect(page.getByTestId('staff-login-password')).toBeVisible();
|
||||
|
||||
// The password is mandatory and, once provided, authentication succeeds.
|
||||
await page.getByTestId('staff-login-password').fill(ID.staff.password!);
|
||||
await page.getByTestId('login-confirm').click();
|
||||
await app.waitForAdmitted();
|
||||
|
||||
// Demo event + timetable load.
|
||||
await app.gotoTab('agenda');
|
||||
await expect(app.eventTitle()).toBeVisible();
|
||||
});
|
||||
|
||||
test('CONV-STAFF-AUTH-003 QR alone does not authenticate staff (password mandatory)', async ({ page }) => {
|
||||
await toScanStep(page, APP_URL);
|
||||
|
||||
// Provide the QR but no password.
|
||||
await page.getByTestId('scanner-manual-code').fill(ID.staff.qrToken);
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('staff-login-password').waitFor({ state: 'visible' });
|
||||
|
||||
// The confirm control is disabled without a password → cannot continue.
|
||||
await expect(page.getByTestId('login-confirm')).toBeDisabled();
|
||||
|
||||
// Backend: the QR token is NOT the staff's auth password.
|
||||
const res = await signInJwt(ID.staff.email, ID.staff.qrToken).then(
|
||||
() => 'ok',
|
||||
() => 'rejected',
|
||||
);
|
||||
expect(res).toBe('rejected');
|
||||
});
|
||||
|
||||
test('CONV-STAFF-AUTH-004 identity (email) alone does not authenticate staff', async ({ page }) => {
|
||||
await toScanStep(page, APP_URL);
|
||||
|
||||
// Provide the identity (QR → staff email) but no password.
|
||||
await page.getByTestId('scanner-manual-code').fill(ID.staff.qrToken);
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('staff-login-password').waitFor({ state: 'visible' });
|
||||
await expect(page.getByTestId('login-confirm')).toBeDisabled();
|
||||
|
||||
// Backend: the staff email with an empty password does not authenticate.
|
||||
const res = await signInJwt(ID.staff.email, '').then(
|
||||
() => 'ok',
|
||||
() => 'rejected',
|
||||
);
|
||||
expect(res).toBe('rejected');
|
||||
});
|
||||
|
||||
test('CONV-STAFF-AUTH-005 incorrect staff password is rejected (email + QR variants)', async ({ page }) => {
|
||||
// Variant A: identity + wrong password.
|
||||
await toScanStep(page, APP_URL);
|
||||
await page.getByTestId('scanner-manual-code').fill(ID.staff.qrToken);
|
||||
await page.getByTestId('scanner-manual-go').click();
|
||||
await page.getByTestId('staff-login-password').fill('wrong-password-xyz');
|
||||
await page.getByTestId('login-confirm').click();
|
||||
|
||||
// A suitable authentication error is displayed and no session is created.
|
||||
await expect(page.getByTestId('login-error')).toBeVisible();
|
||||
await expect(page.getByTestId('tab-home')).toHaveCount(0);
|
||||
|
||||
// Variant B: QR + wrong password (backend).
|
||||
const res = await signInJwt(ID.staff.email, 'wrong-password-xyz').then(
|
||||
() => 'ok',
|
||||
() => 'rejected',
|
||||
);
|
||||
expect(res).toBe('rejected');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user