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:
@@ -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 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user