Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test(alerts): preserve uncertainty after queue action refresh failure

pulse-triage[bot]1eb6d46c35e4
diff --git a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
index 51e63180fe..d30e03af65 100644
--- a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
@@ -171,6 +171,37 @@ describe('useNotificationDeliveryHealth', () => {
);
describe.each(['dismissTerminalFailures', 'retryTerminalFailures'] as const)('%s', (action) => {
+ it('reports unavailable rather than healthy when the post-action refresh fails', () =>
+ createRoot(async (dispose) => {
+ const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(true);
+ const onAfterQueueAction = vi.fn().mockResolvedValue(undefined);
+ try {
+ vi.mocked(NotificationsAPI.getHealth)
+ .mockResolvedValueOnce({
+ queue: { status: 'degraded', attentionRequired: 2 },
+ } as never)
+ .mockRejectedValueOnce(new Error('post-action connection lost'));
+ vi.mocked(NotificationsAPI[action]).mockResolvedValueOnce({ affected: 2 } as never);
+ const state = useNotificationDeliveryHealth({ onAfterQueueAction });
+ await state.loadDeliveryHealth();
+
+ await state[action]();
+
+ expect(NotificationsAPI[action]).toHaveBeenCalledOnce();
+ expect(NotificationsAPI.getHealth).toHaveBeenCalledTimes(2);
+ expect(onAfterQueueAction).toHaveBeenCalledOnce();
+ expect(state.deliveryHealth()).toBeNull();
+ expect(state.deliveryHealthUnavailable()).toBe(true);
+ expect(state.deliveryNeedsAttention()).toBe(true);
+ expect(state.refreshingDeliveryHealth()).toBe(false);
+ expect(state.retryingTerminalFailures()).toBe(false);
+ expect(state.dismissingTerminalFailures()).toBe(false);
+ } finally {
+ confirmSpy.mockRestore();
+ dispose();
+ }
+ }));
+
it.each(['cancelled', 'rejected'] as const)(
'preserves retained failure evidence when the action is %s',
(outcome) =>