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.

fix(tests): format delivery failure regression coverage

pulse-triage[bot]f0466ce2cff4
diff --git a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
index 328d0f81d5..51e63180fe 100644
--- a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryHealth.test.tsx
@@ -173,39 +173,43 @@ describe('useNotificationDeliveryHealth', () => {
describe.each(['dismissTerminalFailures', 'retryTerminalFailures'] as const)('%s', (action) => {
it.each(['cancelled', 'rejected'] as const)(
'preserves retained failure evidence when the action is %s',
- (outcome) => createRoot(async (dispose) => {
- const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(outcome !== 'cancelled');
- const onAfterQueueAction = vi.fn();
- try {
- const health = { queue: { status: 'degraded', attentionRequired: 2 } } as never;
- vi.mocked(NotificationsAPI.getHealth).mockResolvedValueOnce(health);
- const state = useNotificationDeliveryHealth({ onAfterQueueAction });
- await state.loadDeliveryHealth();
- let rejectAction!: (reason: Error) => void;
- vi.mocked(NotificationsAPI[action]).mockReturnValueOnce(new Promise((_, reject) => {
- rejectAction = reject;
- }));
- const pending = state[action]();
- const busy = action === 'dismissTerminalFailures'
- ? state.dismissingTerminalFailures : state.retryingTerminalFailures;
- expect(busy()).toBe(outcome === 'rejected');
- if (outcome === 'rejected') rejectAction(new Error('request rejected'));
- await pending;
-
- expect(confirmSpy).toHaveBeenCalledOnce();
- expect(NotificationsAPI[action]).toHaveBeenCalledTimes(outcome === 'rejected' ? 1 : 0);
- expect(NotificationsAPI.getHealth).toHaveBeenCalledTimes(1);
- expect(onAfterQueueAction).not.toHaveBeenCalled();
- expect(state.deliveryHealth()).toBe(health);
- expect(state.deliveryNeedsAttention()).toBe(true);
- expect(state.deliveryHealthUnavailable()).toBe(false);
- expect(busy()).toBe(false);
- } finally {
- confirmSpy.mockRestore();
- dispose();
- }
- }),
+ (outcome) =>
+ createRoot(async (dispose) => {
+ const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(outcome !== 'cancelled');
+ const onAfterQueueAction = vi.fn();
+ try {
+ const health = { queue: { status: 'degraded', attentionRequired: 2 } } as never;
+ vi.mocked(NotificationsAPI.getHealth).mockResolvedValueOnce(health);
+ const state = useNotificationDeliveryHealth({ onAfterQueueAction });
+ await state.loadDeliveryHealth();
+ let rejectAction!: (reason: Error) => void;
+ vi.mocked(NotificationsAPI[action]).mockReturnValueOnce(
+ new Promise((_, reject) => {
+ rejectAction = reject;
+ }),
+ );
+ const pending = state[action]();
+ const busy =
+ action === 'dismissTerminalFailures'
+ ? state.dismissingTerminalFailures
+ : state.retryingTerminalFailures;
+ expect(busy()).toBe(outcome === 'rejected');
+ if (outcome === 'rejected') rejectAction(new Error('request rejected'));
+ await pending;
+
+ expect(confirmSpy).toHaveBeenCalledOnce();
+ expect(NotificationsAPI[action]).toHaveBeenCalledTimes(outcome === 'rejected' ? 1 : 0);
+ expect(NotificationsAPI.getHealth).toHaveBeenCalledTimes(1);
+ expect(onAfterQueueAction).not.toHaveBeenCalled();
+ expect(state.deliveryHealth()).toBe(health);
+ expect(state.deliveryNeedsAttention()).toBe(true);
+ expect(state.deliveryHealthUnavailable()).toBe(false);
+ expect(busy()).toBe(false);
+ } finally {
+ confirmSpy.mockRestore();
+ dispose();
+ }
+ }),
);
});
-
});