fix(ui/alerts): remove dead usePageVisible subscription; align alerts test mock with DTO

NotificationBell used a usePageVisible() subscription that re-rendered on
every visibilitychange without consuming the value. TanStack Query's
refetchIntervalInBackground:false already pauses polling; the extra
subscription was speculative generality. Dropped the import + call + JSDoc
reference; usePageVisible hook + test retained as a reusable primitive.

Also: alerts.test.tsx 'returns the server payload unmodified' asserted a
pre-plan {total, bySeverity} shape, but UnreadCountResponse is actually
{count}. Fixed mock + assertion to {count: 3}.
This commit is contained in:
hsiegeln
2026-04-20 13:30:07 +02:00
parent 197c60126c
commit 38083d7c3f
2 changed files with 6 additions and 20 deletions

View File

@@ -60,14 +60,11 @@ describe('useUnreadCount', () => {
it('returns the server payload unmodified', async () => {
(apiClient.GET as any).mockResolvedValue({
data: { total: 3, bySeverity: { CRITICAL: 1, WARNING: 2, INFO: 0 } },
data: { count: 3 },
error: null,
});
const { result } = renderHook(() => useUnreadCount(), { wrapper });
await waitFor(() => expect(result.current.isSuccess).toBe(true));
expect(result.current.data).toEqual({
total: 3,
bySeverity: { CRITICAL: 1, WARNING: 2, INFO: 0 },
});
expect(result.current.data).toEqual({ count: 3 });
});
});