fix(points): welcome check-in awards +10; add Sessions view, AI connection test, silent reload

The front-desk check-in set checked_in and printed badges but awarded nothing,
so the +10 depended on which check-in a person happened to get. Every award
path was reviewed:

- welcome_checkin awards +10 (category checkin) on a genuine first check-in and
  returns points + points_awarded; checkin_attendee and preview_welcome_checkin
  return points_awarded too.
- set_registration_checked_in(false) deleted all checkin points while keeping
  the checkins rows, and switching back on awarded nothing -- one mistaken
  toggle destroyed those points permanently. ON now recomputes from the rows
  that still exist and awards only the shortfall: reversible, still unfarmable.
- The staff/Admin/@appe.at exclusion stays (product decision) but is no longer
  silent: three-way points sheets in the scanner, "no points" with a tooltip in
  Registrations, and the Contacts points modal refuses to apply rather than
  letting adjust_points (void) no-op quietly.

Also in this change:
- admin silent refresh (5s poll + 500ms after writes) across all data views;
  Registrations patches in place so rows never slide under the cursor
- Settings "Validate AI connection" via a new sidecar POST /llm-test verdict
  endpoint (never leaks the key, distinguishes "no usage block" from "off")
- new Sessions view between Schedule and Activity: speakers, attendance,
  ratings, attendee filter, and one button that summarises every session with
  feedback (one request each, concurrency 3, UI blocked until all settle)
- provider requests disable thinking through one shared body builder sending
  both reasoning_effort:"none" and chat_template_kwargs.enable_thinking

SQL: 113 / 57 / 24 assertions (set_registration_checked_in section 3 was
rewritten, it asserted the bug). Sidecar 34 unit tests. Full e2e 202 passed,
0 failed. Migration applied locally only -- not deployed.

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]>
This commit is contained in:
committed 2026-10-19 20:14:03 +02:00
1 parent cdb4793273
commit d3083b7940
35 files changed
+2778 -154

No files matched your search

+40 -3
View File
@@ -41,7 +41,7 @@ const event = {
/** Mutable per-test fixtures so a handler can observe its own writes. */
type Harness = { regs: Reg[]; registrationFetches: number; setCheckedInDelayMs: number };
async function openAdmin(page: Page, view: 'Registrations' | 'Settings', h: Harness) {
async function openAdmin(page: Page, view: 'Registrations' | 'Settings' | 'Contacts', h: Harness) {
const payload = Buffer.from(JSON.stringify({ sub: user.id, exp: Math.floor(Date.now() / 1000) + 3600 })).toString('base64url');
const session = { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test`, refresh_token: 'r', expires_in: 3600, token_type: 'bearer' };
await page.route('**/auth/v1/**', (r) => r.fulfill({ json: new URL(r.request().url()).pathname.endsWith('/user') ? user : session }));
@@ -98,11 +98,48 @@ test.describe('Registrations check-in toggle', () => {
await rowToggle(page, 'Ann A').click();
await expect(page.getByText(/Ann A: checked in/)).toBeVisible();
// The whole point: no list reload, therefore no re-sort and no jumping row.
// The whole point: no reload on the write path, therefore no re-sort and no
// jumping row. The checkbox still shows the new state.
expect(h.registrationFetches, 'the toggle must not refetch registrations').toBe(fetchesAfterLoad);
expect(await order(page)).toEqual(before);
// The row still shows the new state.
await expect(rows(page).filter({ hasText: 'Ann A' }).locator('input[type=checkbox]')).toBeChecked();
// The silent pull does arrive (500 ms after the write), and this is the other
// half of the promise: it patches in place instead of reordering or blanking.
await expect.poll(() => h.registrationFetches, { timeout: 5_000 }).toBeGreaterThan(fetchesAfterLoad);
await expect(rows(page)).toHaveCount(4);
expect(await order(page)).toEqual(before);
await expect(rows(page).filter({ hasText: 'Ann A' }).locator('input[type=checkbox]')).toBeChecked();
});
test('a staff row says why it has no points instead of showing 0', async ({ page }) => {
const h: Harness = { regs: mkRegs(), registrationFetches: 0, setCheckedInDelayMs: 0 };
h.regs[3].points = 0; // Dee D, type staff — never earns anything
await openAdmin(page, 'Registrations', h);
const staffRow = rows(page).filter({ hasText: 'Dee D' }).first();
await expect(staffRow.getByTestId('points-exempt-r4')).toBeVisible();
await expect(staffRow.getByTestId('points-exempt-r4')).toContainText('no points');
// Attendees keep the plain number.
await expect(rows(page).filter({ hasText: 'Ann A' }).first().locator('.pts')).toHaveText('40');
await expect(rows(page).filter({ hasText: 'Ann A' }).first().getByTestId('points-exempt-r1')).toHaveCount(0);
});
test('restoring check-in on a row that lost its points reports the award', async ({ page }) => {
const h: Harness = { regs: mkRegs(), registrationFetches: 0, setCheckedInDelayMs: 0 };
// The toggle had been switched off before, so points sit at 0 while the
// server still counts real check-in rows: restoring must top up, not zero.
h.regs[1].checked_in = false;
h.regs[1].points = 0;
await openAdmin(page, 'Registrations', h);
// Registered after openAdmin's handler so it wins (Playwright matches the
// most recently added route first).
await page.route('**/rpc/set_registration_checked_in*', (route) =>
route.fulfill({ json: [{ registration_id: 'r2', checked_in: true, points_removed: 0, points_added: 20 }] }));
await rowToggle(page, 'Bob B').click();
await expect(page.getByText(/\+20 check-in pts restored/)).toBeVisible();
await expect(rows(page).filter({ hasText: 'Bob B' }).locator('.pts')).toHaveText('20');
});
test('only the toggled row is busy; the rest of the table stays usable', async ({ page }) => {