feat(points): staff auto-connect never scores; event feedback pays +5

- Migration 20261020120000: staff (type staff / Admin / @appe.at) are
  auto-connected to every participant of the event via connections.auto
  rows inserted directly as accepted - never through accept_connection,
  so zero points by construction; backfill + idempotent helper + trigger.
- Migration 20261020130000: submit_event_feedback awards +5 on the first
  submission per participant x event (edits earn 0), gated by
  _points_eligible; response gains earned column; ACL restored.
- Admin: points move from Contacts to Registrations (active-event rows
  only, in-place save); Dashboard Top points drops emails; Dashboard and
  Activity hide auto connections.
- Attendee: leaderboard masks surnames (Max M.); EventFeedback toast
  shows +5 pts on paid submissions.
- Tests: staff_auto_connections_tests.sql (14 assertions), rpc_tests
  section 11 (4 assertions). Docs + release record 2026-10-20.
- README: document the git-ignored .env provisioning step (missing key
  = white screen).
This commit is contained in:
lago committed 2026-10-20 22:15:29 +02:00
1 parent b7c2abb73b
commit 35b88d50ca
22 files changed
+809 -166

No files matched your search

+48 -48
View File
@@ -229,78 +229,78 @@ test.describe('Connections', () => {
expect(await conns.outgoingContains('Jonas Unger')).toBe(false);
});
test('CONV-CONN-007 staff can send, receive, accept, and decline connection requests', async ({ browser }) => {
test('CONV-CONN-007 staff are auto-connected to everyone and never for points', async ({ browser }) => {
// Staff ↔ people connections are created by the registrations trigger
// (migration 20261020120000_staff_auto_connections) with auto = true:
// no request, no accept step — and never any points. This replaces the
// old manual staff networking flow, which the feature made impossible:
// scanning a staff lanyard now lands on an already-accepted pair.
const staff = await createUser(browser, 'staff');
const mia = await createUser(browser, 'attendeeA');
const jonas = await createUser(browser, 'attendeeB');
const emma = await createUser(browser, 'attendeeC');
try {
const sApp = new AppPage(staff.page, APP_URL);
const sScan = new ScanPage(staff.page);
const sConns = new ConnectionsPage(staff.page);
const mApp = new AppPage(mia.page, APP_URL);
const mConns = new ConnectionsPage(mia.page);
const mScan = new ScanPage(mia.page);
const jApp = new AppPage(jonas.page, APP_URL);
const jScan = new ScanPage(jonas.page);
const eApp = new AppPage(emma.page, APP_URL);
const eScan = new ScanPage(emma.page);
const jConns = new ConnectionsPage(jonas.page);
// 1. Staff sends a connection request to Mia.
const pair = (a: string, b: string) => psql(
`select c.status || '|' || c.auto::text from public.connections c
where c.event_id = (select id from public.events where is_active limit 1)
and least(c.from_email, c.to_email) = least(${sqlQuote(a)}, ${sqlQuote(b)})
and greatest(c.from_email, c.to_email) = greatest(${sqlQuote(a)}, ${sqlQuote(b)});`,
);
const score = (email: string) => psql(
`select coalesce(sum(points), 0) from public.registrations
where event_id = (select id from public.events where is_active limit 1)
and contact_email = ${sqlQuote(email)};`,
);
// 1. No manual flow needed: the staff member already has everyone.
await login(staff.page, APP_URL, ID.staff);
await sApp.waitForAdmitted();
await sApp.gotoTab('scan');
await sScan.setAttendeeMode();
await sScan.scanCode(ID.attendeeA.qrToken);
await sScan.sendConnection();
expect(await sConns.mineContains('Mia Moser')).toBe(true);
expect(await sConns.mineContains('Jonas Unger')).toBe(true);
// 2. Mia accepts.
// 2. Mia sees the staff in her own connections without ever asking,
// and the backend row is an auto-created accepted pair.
await login(mia.page, APP_URL, ID.attendeeA);
await mApp.waitForAdmitted();
await mConns.gotoRequests();
await mConns.accept();
// 3. Verify the connection both ways.
await mConns.gotoMine();
expect(await mConns.mineContains('Jose Lago')).toBe(true);
await sConns.gotoMine();
expect(await sConns.mineContains('Mia Moser')).toBe(true);
expect(pair(ID.staff.email, ID.attendeeA.email)).toBe('accepted|true');
// 4. Jonas (a different attendee) sends the staff a request; the staff accepts.
// 3. Scanning a staff lanyard connects instantly — no request is born.
const miaScore = score(ID.attendeeA.email);
const staffScore = score(ID.staff.email);
await mApp.gotoTab('scan');
await mScan.setAttendeeMode();
await mScan.scanCode(ID.staff.qrToken);
await mScan.sendConnection();
await expect(mia.page.getByText(/You.re connected/)).toBeVisible();
// 4. Neither side earns a point for connecting with staff.
expect(score(ID.attendeeA.email)).toBe(miaScore);
expect(score(ID.staff.email)).toBe(staffScore);
expect(psql(
`select count(*) from public.points_log
where created_at > now() - interval '2 minutes'
and contact_email in (${sqlQuote(ID.staff.email)}, ${sqlQuote(ID.attendeeA.email)});`,
)).toBe('0');
// 5. Jonas is connected to the staff the same instant, both directions.
await login(jonas.page, APP_URL, ID.attendeeB);
await jApp.waitForAdmitted();
await jApp.gotoTab('scan');
await jScan.setAttendeeMode();
await jScan.scanCode(ID.staff.qrToken);
await jScan.sendConnection();
await sConns.gotoRequests();
await sConns.accept();
// 5. The staff–Jonas connection is established both ways.
await sConns.gotoMine();
expect(await sConns.mineContains('Jonas Unger')).toBe(true);
await jApp.gotoTab('connections');
const jConns = new ConnectionsPage(jonas.page);
await jConns.gotoMine();
expect(await jConns.mineContains('Jose Lago')).toBe(true);
// 6. Emma sends the staff a request; the staff declines → no connection.
await login(emma.page, APP_URL, ID.attendeeC);
await eApp.waitForAdmitted();
await eApp.gotoTab('scan');
await eScan.setAttendeeMode();
await eScan.scanCode(ID.staff.qrToken);
await eScan.sendConnection();
await sConns.gotoRequests();
await sConns.decline();
// 7. Emma is NOT in the staff's established connections.
await sConns.gotoMine();
expect(await sConns.mineContains('Emma Dorfer')).toBe(false);
await sApp.gotoTab('home');
expect(await sConns.mineContains('Jonas Unger')).toBe(true);
} finally {
await staff.close();
await mia.close();
await jonas.close();
await emma.close();
}
});
+5 -2
View File
@@ -46,8 +46,11 @@ test('real leaderboard updates scores and ranks without rewarding staff or admin
commit;`);
await login(page, APP_URL, { email: emails[0], qrToken: password, type: 'attendee', label: 'Disposable leaderboard player' });
await page.getByText('Leaderboard', { exact: true }).click();
await expect(page.locator('.podium .pname')).toHaveText(['Board', 'Board', 'Board']);
await expect(page.getByText('Board Fourth', { exact: true })).toBeVisible();
// Names on the leaderboard are masked: first name + last-name initial.
await expect(page.locator('.podium .pname')).toHaveText(['Board P.', 'Board P.', 'Board T.']);
await expect(page.getByText('Board F.', { exact: true })).toBeVisible();
await expect(page.getByText('Board Player', { exact: true })).toHaveCount(0);
await expect(page.getByText('Board Fourth', { exact: true })).toHaveCount(0);
await expect(page.getByText(/You.re ranked/)).toContainText('#1');
await expect.poll(() => subscribed, { timeout: 20_000, message: 'Realtime subscription acknowledged' }).toBe(true)
.catch(error => { throw new Error(`${error.message}\n${transportMessages.join('\n')}`); });