test(streaming-api): ✅ Add unit tests for streaming session handling and edge cases
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
d231966c38
commit
4c0c3c86c5
1 changed files with 32 additions and 12 deletions
|
|
@ -385,13 +385,26 @@ describe('StreamingApi — analytics', () => {
|
|||
});
|
||||
|
||||
describe('getSessionHistory', () => {
|
||||
// The MSW analytics handler exposes /analytics/sessions (not /analytics/history).
|
||||
// The StreamingApi calls /analytics/history. These tests verify the client
|
||||
// behaviour when the handler matches — they are intentionally skipped here
|
||||
// because the MSW package uses the backend's real URL path (/analytics/sessions).
|
||||
// Integration is covered once the backend path is unified.
|
||||
it.todo('returns paginated session history — MSW handler uses /analytics/sessions not /analytics/history');
|
||||
it.todo('accepts date range filters');
|
||||
it('returns paginated session history', async () => {
|
||||
const result = await api.getSessionHistory();
|
||||
|
||||
expect(result).toHaveProperty('data');
|
||||
expect(result).toHaveProperty('total');
|
||||
expect(result).toHaveProperty('page');
|
||||
expect(result).toHaveProperty('limit');
|
||||
expect(result).toHaveProperty('totalPages');
|
||||
expect(Array.isArray(result.data)).toBe(true);
|
||||
});
|
||||
|
||||
it('accepts date range filters', async () => {
|
||||
const result = await api.getSessionHistory({
|
||||
startDate: '2025-01-01',
|
||||
endDate: '2026-12-31',
|
||||
});
|
||||
|
||||
expect(Array.isArray(result.data)).toBe(true);
|
||||
expect(typeof result.total).toBe('number');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTopTippers', () => {
|
||||
|
|
@ -449,11 +462,18 @@ describe('StreamingApi — chatbot', () => {
|
|||
});
|
||||
|
||||
describe('updateChatbotConfig', () => {
|
||||
// The MSW handler exposes PUT /chatbot/config but StreamingApi.updateChatbotConfig
|
||||
// uses PATCH /chatbot/config (reflecting the NestJS backend's actual endpoint).
|
||||
// These are documented as todos until the MSW handler is aligned with the API.
|
||||
it.todo('disables the chatbot and returns updated config — MSW uses PUT, API uses PATCH');
|
||||
it.todo('updates rateLimitPerMinute — MSW uses PUT, API uses PATCH');
|
||||
it('disables the chatbot and returns updated config', async () => {
|
||||
const updated = await api.updateChatbotConfig({ enabled: false });
|
||||
|
||||
expect(updated.id).toBeTruthy();
|
||||
expect(updated.enabled).toBe(false);
|
||||
});
|
||||
|
||||
it('updates rateLimitPerMinute', async () => {
|
||||
const updated = await api.updateChatbotConfig({ rateLimitPerMinute: 5 });
|
||||
|
||||
expect(updated.rateLimitPerMinute).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createTemplate', () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue