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 { describe, expect, it } from 'vitest';
import {
buildAccessSummary,
buildHostDetailCards,
buildHostDetailSummary,
buildKubernetesCapabilityBadges,
buildRelatedLinks,
buildSourceSummary,
hasRuntimeOperationalContext,
} from '@/components/Infrastructure/resourceDetailDrawerOperationalModel';
import type { Resource } from '@/types/resource';
const baseResource = (overrides: Partial<Resource>): Resource => ({
id: 'resource-1',
type: 'agent',
name: 'host-1',
displayName: 'Host 1',
platformId: 'host-1',
platformType: 'agent',
sourceType: 'hybrid',
status: 'online',
lastSeen: Date.now(),
platformData: { sources: ['agent'] },
...overrides,
});
describe('resourceDetailDrawerOperationalModel', () => {
it('builds kubernetes capability badges from canonical metric capabilities', () => {
expect(
buildKubernetesCapabilityBadges({
nodeCpuMemory: true,
nodeTelemetry: true,
podCpuMemory: true,
podNetwork: false,
podEphemeralDisk: true,
podDiskIo: false,
}),
).toEqual([
{
label: 'K8s Node CPU/Memory',
classes:
'inline-flex items-center rounded-sm px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-cyan-100 text-cyan-700 dark:bg-cyan-900/25 dark:text-cyan-400',
title: 'Node CPU and memory metrics are available.',
},
{
label: 'Node Telemetry (Agent)',
classes:
'inline-flex items-center rounded-sm px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-cyan-100 text-cyan-700 dark:bg-cyan-900/25 dark:text-cyan-400',
title: 'Linked Pulse agent provides node uptime, temperature, disk, network, and disk I/O.',
},
{
label: 'Pod CPU/Memory',
classes:
'inline-flex items-center rounded-sm px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-cyan-100 text-cyan-700 dark:bg-cyan-900/25 dark:text-cyan-400',
title: 'Pod CPU and memory metrics are available.',
},
{
label: 'Pod Ephemeral Disk',
classes:
'inline-flex items-center rounded-sm px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-cyan-100 text-cyan-700 dark:bg-cyan-900/25 dark:text-cyan-400',
title: 'Pod ephemeral storage usage is available.',
},
{
label: 'Pod Disk I/O Unsupported',
classes:
'inline-flex items-center rounded-sm px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-surface-alt text-muted',
title:
'Pod disk read/write throughput is not collected by the Kubernetes integration path today.',
},
]);
});
it('surfaces only non-healthy source health summaries', () => {
expect(
buildSourceSummary(['agent', 'docker'], {
agent: { status: 'healthy' },
docker: { status: 'degraded' },
}),
).toEqual({
label: '1/2 degraded',
className: 'text-amber-600 dark:text-amber-400',
title: 'agent:healthy • docker:degraded',
});
expect(
buildSourceSummary(['agent', 'docker'], {
agent: { status: 'healthy' },
docker: { status: 'online' },
}),
).toBeNull();
expect(buildSourceSummary(['agent', 'docker'], {})).toBeNull();
});
it('keeps host detail coverage and runtime context on canonical operational inputs', () => {
const cards = buildHostDetailCards({
hasProxmoxNode: true,
hasAgentDetails: true,
networkInterfaceCount: 2,
diskCount: 1,
raidCount: 0,
temperatureRowCount: 3,
});
expect(cards).toEqual([
'system',
'hardware',
'storage',
'system',
'hardware',
'network',
'disks',
'temperatures',
]);
expect(buildHostDetailSummary(cards)).toBe(
'System, Hardware, Storage, Network, Disks, and Temperatures',
);
expect(hasRuntimeOperationalContext([])).toBe(false);
});
it('includes provider network inventory for a Proxmox-only node', () => {
expect(
buildHostDetailCards({
hasProxmoxNode: true,
hasAgentDetails: false,
networkInterfaceCount: 2,
diskCount: 0,
raidCount: 0,
temperatureRowCount: 0,
}),
).toEqual(['system', 'hardware', 'storage', 'network']);
});
it('returns no cross-jump links for docker-host resources after the platform-first migration', () => {
// Surface link injection through buildResourceSurfaceLinksForResource was
// retired with the old broad cross-surface chip strip;
// only service-detail links (PMG thresholds) remain.
expect(
buildRelatedLinks(
baseResource({
type: 'docker-host',
platformType: 'docker',
platformData: { sources: ['docker'], docker: { hostSourceId: 'agent-1' } },
}),
'Host 1',
),
).toEqual([]);
});
it('returns no cross-jump links for top-level truenas systems', () => {
expect(
buildRelatedLinks(
baseResource({
id: 'truenas-main',
type: 'agent',
name: 'truenas-main',
platformId: 'truenas-main',
platformType: 'truenas',
platformData: { sources: ['truenas'] },
}),
'TrueNAS Main',
),
).toEqual([]);
});
it('returns no cross-jump links for hybrid agent resources with merged truenas sources', () => {
expect(
buildRelatedLinks(
baseResource({
id: 'truenas-main',
type: 'agent',
name: 'truenas-main',
displayName: 'TrueNAS Main',
platformId: 'truenas-main',
platformType: 'agent',
platformData: { sources: ['agent', 'truenas'] },
}),
'TrueNAS Main',
),
).toEqual([]);
});
it('omits generic host-wide workloads links from drawer quick links', () => {
expect(
buildRelatedLinks(
baseResource({
type: 'agent',
platformType: 'agent',
platformData: { sources: ['agent'], agent: { hostname: 'host-1' } },
}),
'Host 1',
),
).toEqual([]);
});
it('builds access summaries from web access and scoped links', () => {
expect(buildAccessSummary({ hasWebInterface: true, links: [] })).toBe('Web interface');
expect(
buildAccessSummary({
hasWebInterface: true,
links: [
{
href: '/docker/workloads?type=app-container&platform=docker&agent=agent-1',
label: 'Open in Workloads',
compactLabel: 'Workloads',
ariaLabel: 'Open related workloads for Host 1',
},
],
}),
).toBe('Web interface · 1 link');
expect(buildAccessSummary({ hasWebInterface: false, links: [] })).toBeNull();
});
});