From 4c0c3c86c55b614b776db33532241aa098ebcd64 Mon Sep 17 00:00:00 2001 From: Lilith Date: Fri, 27 Feb 2026 16:26:26 -0800 Subject: [PATCH] =?UTF-8?q?test(streaming-api):=20=E2=9C=85=20Add=20unit?= =?UTF-8?q?=20tests=20for=20streaming=20session=20handling=20and=20edge=20?= =?UTF-8?q?cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../src/api/streaming-api.test.ts | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/features/streaming/frontend-dashboard/src/api/streaming-api.test.ts b/features/streaming/frontend-dashboard/src/api/streaming-api.test.ts index 21faf0560..bf01c50a0 100644 --- a/features/streaming/frontend-dashboard/src/api/streaming-api.test.ts +++ b/features/streaming/frontend-dashboard/src/api/streaming-api.test.ts @@ -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', () => {