Summarise this report on every report (2.0.1)
The eight reports that list people get the AI summary too, sent as anonymised totals built on the screen (aiReportData.ts): no names, contact details, notes or comments; consent and medical only as counts. The server refuses personal columns on those reports and logs each summary in the access log (ai_report; sensitive for consent and medical). Roadmap §18: 2.0.1, then crosscode.co.za, then 2.1.0 (AI helpers on the Consent log and Access log). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -700,13 +700,26 @@ describe('AI helpers (2.0)', () => {
|
||||
expect(mockRunHelper.mock.calls[0][0]).toBe('improve_text');
|
||||
});
|
||||
|
||||
test('summarise a report: reports with people in them are refused by validation', async () => {
|
||||
test('summarise a report: unknown reports fail validation, people columns are refused', async () => {
|
||||
signedIn = { id: 's1', role: 'supervisor' };
|
||||
expect((await request(app).post('/api/v2/ai/summarise-report').send({ reportKey: 'nope', title: 'X', columns: ['A'], rows: [[1]] })).status).toBe(400);
|
||||
const res = await request(app).post('/api/v2/ai/summarise-report').send({ reportKey: 'payments', title: 'Payments', columns: ['User'], rows: [['Jane']] });
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.status).toBe(403);
|
||||
expect(res.body.error.reason).toBe('AI_REPORT_HAS_PEOPLE');
|
||||
expect(mockRunHelper).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('summarise a report: a people report as totals, with an access-log entry (sensitive for medical)', async () => {
|
||||
signedIn = { id: 's1', role: 'supervisor' };
|
||||
mockRunHelper.mockResolvedValue({ output: { headline: 'h', insights: [], watchOut: [] }, status: st });
|
||||
const res = await request(app).post('/api/v2/ai/summarise-report').send({ reportKey: 'medicalList', title: 'Medical & emergency list', columns: ['Event', 'Attendees', 'With allergies'], rows: [['Camp', 40, 6]] });
|
||||
expect(res.status).toBe(200);
|
||||
expect(mockAccessLog).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ action: 'ai_report', records: 1, sensitive: true }));
|
||||
mockAccessLog.mockClear();
|
||||
await request(app).post('/api/v2/ai/summarise-report').send({ reportKey: 'revenue', title: 'Revenue', columns: ['Event', 'Amount'], rows: [['Camp', 100]] });
|
||||
expect(mockAccessLog).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('draft an event: the draft with warnings worked out in code', async () => {
|
||||
signedIn = { id: 's1', role: 'supervisor' };
|
||||
const draft = {
|
||||
|
||||
Reference in New Issue
Block a user