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]>
56 lines
3.2 KiB
JavaScript
56 lines
3.2 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { validateSettings, generateSummary } = require('../src/feedback-summary');
|
|
const settings = { endpoint: 'https://llm.example/v1/chat/completions', model: 'test-model', api_key: 'test-secret' };
|
|
|
|
test('validates endpoint, model and credential input', () => {
|
|
assert.equal(validateSettings(settings).model, 'test-model');
|
|
for (const endpoint of ['http://localhost:11434', 'https://user:[email protected]', 'https://example.com/?key=secret', 'file:///etc/passwd']) {
|
|
assert.throws(() => validateSettings({ ...settings, endpoint }));
|
|
}
|
|
assert.throws(() => validateSettings({ ...settings, model: '' }));
|
|
assert.throws(() => validateSettings({ ...settings, api_key: 'secret\r\nHeader: value' }));
|
|
});
|
|
|
|
test('does not call LLM without feedback', async () => {
|
|
await assert.rejects(generateSummary(settings, { feedback: [] }, () => { throw new Error('Must not call'); }), /No feedback/);
|
|
});
|
|
|
|
test('sends only ratings and comments and reads OpenAI-compatible output', async () => {
|
|
const result = await generateSummary(settings, {
|
|
scope: 'session', title: 'Session', feedback: [{ rating: 5, comment: 'Useful', contact_email: '[email protected]', id: 'private-id' }],
|
|
}, async (url, options) => {
|
|
assert.equal(url, settings.endpoint);
|
|
assert.equal(options.redirect, 'error');
|
|
assert.equal(options.headers.Authorization, 'Bearer test-secret');
|
|
const request = JSON.parse(options.body);
|
|
assert.equal(request.model, 'test-model');
|
|
assert.ok(!options.body.includes('[email protected]'));
|
|
assert.ok(!options.body.includes('private-id'));
|
|
assert.deepEqual(JSON.parse(request.messages[1].content).responses, [{ rating: 5, comment: 'Useful' }]);
|
|
return new Response(JSON.stringify({ choices: [{ message: { content: ' Useful session. ' } }] }));
|
|
});
|
|
assert.equal(result, 'Useful session.');
|
|
});
|
|
|
|
test('disables model thinking with both supported fields', async () => {
|
|
let request;
|
|
await generateSummary(settings, { scope: 'event', title: 'Event', feedback: [{ rating: 4 }] }, async (_url, options) => {
|
|
request = JSON.parse(options.body);
|
|
return new Response(JSON.stringify({ choices: [{ message: { content: 'Summary.' } }] }));
|
|
});
|
|
assert.equal(request.stream, false);
|
|
assert.equal(request.reasoning_effort, 'none');
|
|
assert.deepEqual(request.chat_template_kwargs, { enable_thinking: false });
|
|
// The ignored shape must never come back — it looks like success but does nothing.
|
|
assert.equal(request.thinking, undefined);
|
|
assert.ok(!('max_tokens' in request));
|
|
});
|
|
|
|
test('rejects provider errors, malformed output and oversized inputs', async () => {
|
|
const input = { scope: 'event', title: 'Event', feedback: [{ rating: 3 }] };
|
|
await assert.rejects(generateSummary(settings, input, async () => new Response('secret error', { status: 401 })), /HTTP 401/);
|
|
await assert.rejects(generateSummary(settings, input, async () => new Response('not JSON')), /invalid JSON/);
|
|
await assert.rejects(generateSummary(settings, input, async () => new Response('{}')), /invalid summary/);
|
|
await assert.rejects(generateSummary(settings, { ...input, feedback: [{ rating: 1, comment: 'x'.repeat(200001) }] }), /200 KB/);
|
|
}); |