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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { Route, Router } from '@solidjs/router';
import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { NotificationQueueHealth } from '@/api/notifications';
import { AlertQueueActionFeedback } from './AlertQueueActionFeedback';
import { AlertDeliveryHealthCard } from './AlertDeliveryHealthCard';
const degradedHealth: NotificationQueueHealth = {
pending: 2,
sending: 0,
sent: 12,
failed: 1,
deadLetter: 2,
healthy: false,
status: 'degraded',
attentionRequired: 3,
reasonCodes: ['retained_failed_deliveries', 'retained_dead_letter_deliveries'],
completedRetentionDays: 7,
deadLetterRetentionDays: 30,
countsAreRetentionBounded: true,
retryAttemptsAffectHealth: false,
terminalFailuresAffectHealth: true,
failureClasses7d: {
authentication: 2,
rate_limited: 0,
connectivity: 1,
tls: 0,
configuration: 0,
rejected: 0,
server_error: 0,
unknown: 0,
},
failureClassesAvailable: true,
failureClassWindowDays: 7,
};
describe('AlertDeliveryHealthCard', () => {
afterEach(() => cleanup());
it('tells operators that retained terminal deliveries were not delivered', () => {
const onRefresh = vi.fn();
const onRetryFailures = vi.fn();
const onDismissFailures = vi.fn();
render(() => (
<Router>
<Route
path="/"
component={() => (
<AlertDeliveryHealthCard
health={degradedHealth}
unavailable={false}
refreshing={false}
onRefresh={onRefresh}
onRetryFailures={onRetryFailures}
onDismissFailures={onDismissFailures}
detailsHref="/alerts/notifications"
/>
)}
/>
</Router>
));
expect(screen.getByRole('alert')).toHaveTextContent('Notification delivery needs attention');
expect(screen.getByRole('alert')).toHaveTextContent('1 failed delivery retained for 7 days');
expect(screen.getByRole('alert')).toHaveTextContent(
'2 dead-lettered deliveries retained for 30 days',
);
expect(screen.getByRole('alert')).toHaveTextContent(
'Recoverable retry attempts do not trigger this warning',
);
expect(screen.getByRole('alert')).toHaveTextContent('classified as authentication (2)');
expect(screen.getByRole('alert')).toHaveTextContent(
'Check destination credentials, tokens, and account permissions',
);
expect(screen.getByRole('alert')).toHaveTextContent(
'Dismiss retained failures to clear this warning without deleting delivery history',
);
expect(screen.getByRole('link', { name: 'Review delivery activity' })).toHaveAttribute(
'href',
'/alerts/notifications',
);
fireEvent.click(screen.getByRole('button', { name: 'Refresh delivery status' }));
expect(onRefresh).toHaveBeenCalledTimes(1);
fireEvent.click(screen.getByRole('button', { name: 'Retry retained deliveries' }));
expect(onRetryFailures).toHaveBeenCalledTimes(1);
fireEvent.click(screen.getByRole('button', { name: 'Dismiss retained failures' }));
expect(onDismissFailures).toHaveBeenCalledTimes(1);
});
it('fails closed when queue health cannot be verified', () => {
render(() => (
<AlertDeliveryHealthCard health={null} unavailable refreshing onRefresh={vi.fn()} />
));
expect(screen.getByRole('alert')).toHaveTextContent(
'Notification delivery status is unavailable',
);
expect(screen.getByRole('alert')).toHaveTextContent('send a test before relying on delivery');
expect(screen.getByRole('button', { name: 'Refresh delivery status' })).toBeDisabled();
});
it('allows unavailable summary health to be rechecked without a queue mutation', () => {
const onRefresh = vi.fn();
render(() => (
<AlertDeliveryHealthCard
health={null}
unavailable
refreshing={false}
onRefresh={onRefresh}
detailLevel="summary"
showRefresh
/>
));
expect(screen.getByRole('alert')).toHaveTextContent(
'Notification delivery status is unavailable',
);
fireEvent.click(screen.getByRole('button', { name: 'Refresh delivery status' }));
expect(onRefresh).toHaveBeenCalledOnce();
expect(screen.getByRole('alert')).toBeTruthy();
});
it('replaces stale failure advice when status becomes unavailable, then restores fresh evidence', () => {
const [unavailable, setUnavailable] = createSignal(false);
render(() => (
<AlertDeliveryHealthCard
health={degradedHealth}
unavailable={unavailable()}
refreshing={false}
onRefresh={vi.fn()}
/>
));
expect(screen.getByRole('alert')).toHaveTextContent('classified as authentication (2)');
setUnavailable(true);
expect(screen.getByRole('alert')).toHaveTextContent(
'Notification delivery status is unavailable',
);
expect(screen.getByRole('alert')).toHaveTextContent('send a test before relying on delivery');
expect(screen.getByRole('alert')).not.toHaveTextContent('classified as authentication (2)');
setUnavailable(false);
expect(screen.getByRole('alert')).toHaveTextContent('Notification delivery needs attention');
expect(screen.getByRole('alert')).toHaveTextContent('classified as authentication (2)');
expect(screen.getByRole('alert')).not.toHaveTextContent(
'Notification delivery status is unavailable',
);
});
it.each(['retry', 'dismiss'] as const)(
'disables conflicting controls throughout %s and restores them afterwards',
(action) => {
const [busy, setBusy] = createSignal(true);
render(() => (
<AlertDeliveryHealthCard
health={degradedHealth}
unavailable={false}
refreshing={false}
retryingFailures={action === 'retry' && busy()}
dismissingFailures={action === 'dismiss' && busy()}
onRefresh={vi.fn()}
onRetryFailures={vi.fn()}
onDismissFailures={vi.fn()}
/>
));
const labels = [
'Refresh delivery status',
'Retry retained deliveries',
'Dismiss retained failures',
];
for (const name of labels) expect(screen.getByRole('button', { name })).toBeDisabled();
expect(screen.getByRole('alert')).toHaveTextContent('Notification delivery needs attention');
setBusy(false);
for (const name of labels) expect(screen.getByRole('button', { name })).toBeEnabled();
expect(screen.getByRole('alert')).toHaveTextContent('Notification delivery needs attention');
},
);
it('keeps the overview treatment concise and points directly to delivery evidence', () => {
render(() => (
<Router>
<Route
path="/"
component={() => (
<AlertDeliveryHealthCard
health={degradedHealth}
unavailable={false}
refreshing={false}
onRefresh={vi.fn()}
onRetryFailures={vi.fn()}
onDismissFailures={vi.fn()}
detailsHref="/alerts/notifications#notification-delivery-activity"
detailLevel="summary"
showRefresh={false}
/>
)}
/>
</Router>
));
const alert = screen.getByRole('alert');
expect(alert).toHaveTextContent('Most recent failures: authentication (2)');
expect(alert).toHaveTextContent(
'Review delivery activity for timestamps, destinations, alerts, and errors',
);
expect(alert).not.toHaveTextContent('Otherwise Pulse removes expired records hourly');
expect(screen.queryByRole('button', { name: 'Refresh delivery status' })).toBeNull();
expect(screen.getByRole('link', { name: 'Review delivery activity' })).toHaveAttribute(
'href',
'/alerts/notifications#notification-delivery-activity',
);
});
});
describe('recovery feedback beside delivery health', () => {
afterEach(() => cleanup());
it('preserves editing focus and live-region identity when failure feedback changes', () => {
const [message, setMessage] = createSignal<string | null>(null);
render(() => (
<>
<input aria-label="Destination name" />
<AlertQueueActionFeedback message={message()} onClear={() => setMessage(null)} />
</>
));
const input = screen.getByRole('textbox', { name: 'Destination name' });
const status = screen.getByRole('status');
expect(status).toHaveAttribute('aria-live', 'polite');
expect(status).toHaveAttribute('aria-atomic', 'true');
input.focus();
fireEvent.input(input, { target: { value: 'Unfinished edit' } });
for (const failure of [
'Unable to retry retained notification deliveries.',
'Unable to dismiss retained notification failures.',
]) {
setMessage(failure);
expect(screen.getByRole('status')).toBe(status);
expect(status).toHaveTextContent(failure);
expect(input).toHaveFocus();
expect(input).toHaveValue('Unfinished edit');
}
});
it('keeps a mounted live region and returns focus to it when deliberately cleared', () => {
const [message, setMessage] = createSignal<string | null>(null);
render(() => <AlertQueueActionFeedback message={message()} onClear={() => setMessage(null)} />);
expect(screen.getByRole('status')).toBeEmptyDOMElement();
setMessage('Unable to retry retained notification deliveries.');
expect(screen.getByRole('status')).toHaveTextContent('Unable to retry');
const clear = screen.getByRole('button', { name: 'Clear recovery message' });
clear.focus();
fireEvent.click(clear);
expect(screen.getByRole('status')).toBeEmptyDOMElement();
expect(screen.getByRole('region', { name: 'Notification recovery feedback' })).toHaveFocus();
});
});