feat: gate full notes behind auth on single session endpoint
Made-with: Cursor
This commit is contained in:
@@ -104,3 +104,44 @@ describe('GET /api/sessions list', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/sessions/:id notes visibility', () => {
|
||||
beforeEach(() => {
|
||||
cleanDb();
|
||||
});
|
||||
|
||||
test('returns full notes when authenticated', async () => {
|
||||
const session = seedSession({ notes: '**Full notes** here\n\nSecond paragraph' });
|
||||
|
||||
const res = await request(app)
|
||||
.get(`/api/sessions/${session.id}`)
|
||||
.set('Authorization', getAuthHeader());
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.notes).toBe('**Full notes** here\n\nSecond paragraph');
|
||||
expect(res.body.has_notes).toBe(true);
|
||||
expect(res.body.notes_preview).toBe('Full notes here');
|
||||
});
|
||||
|
||||
test('returns only preview when unauthenticated', async () => {
|
||||
const session = seedSession({ notes: '**Full notes** here\n\nSecond paragraph' });
|
||||
|
||||
const res = await request(app)
|
||||
.get(`/api/sessions/${session.id}`);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.notes).toBeUndefined();
|
||||
expect(res.body.has_notes).toBe(true);
|
||||
expect(res.body.notes_preview).toBe('Full notes here');
|
||||
});
|
||||
|
||||
test('returns has_notes false when no notes', async () => {
|
||||
const session = seedSession({ notes: null });
|
||||
|
||||
const res = await request(app)
|
||||
.get(`/api/sessions/${session.id}`);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.has_notes).toBe(false);
|
||||
expect(res.body.notes_preview).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user