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 {
getProxmoxHostColumnWidthStyle,
getProxmoxHostTableMinWidthClass,
getProxmoxHostTableLayoutModeForContainer,
getProxmoxHostVisibleColumnsForLayout,
} from '../proxmoxHostTableModel';
describe('proxmoxHostTableModel', () => {
it('keeps five legible identity and health columns in ultra-narrow containers', () => {
const columns = getProxmoxHostVisibleColumnsForLayout('narrow');
const ids = columns.map((column) => column.id);
expect(ids).toEqual(['node', 'cpu', 'memory', 'disk', 'uptime']);
expect(getProxmoxHostTableMinWidthClass('narrow')).toBe('min-w-0');
expect(getProxmoxHostColumnWidthStyle('node', 'narrow', ids)).toEqual({ width: '40%' });
expect(getProxmoxHostColumnWidthStyle('cpu', 'narrow', ids)).toEqual({ width: '15%' });
expect(getProxmoxHostColumnWidthStyle('uptime', 'narrow', ids)).toEqual({ width: '15%' });
});
it('drops the cluster column when every node shares one cluster', () => {
const wide = getProxmoxHostVisibleColumnsForLayout('wide').map((column) => column.id);
const single = getProxmoxHostVisibleColumnsForLayout('wide', { singleCluster: true }).map(
(column) => column.id,
);
expect(wide).toContain('cluster');
expect(single).not.toContain('cluster');
expect(single).toEqual(wide.filter((id) => id !== 'cluster'));
});
it('matches the guest table columns and keeps node names whole at phone width', () => {
const columns = getProxmoxHostVisibleColumnsForLayout('phone');
const ids = columns.map((column) => column.id);
expect(ids).toEqual(['node', 'cpu', 'memory', 'disk', 'uptime']);
expect(getProxmoxHostTableMinWidthClass('phone')).toBe('min-w-0');
expect(getProxmoxHostColumnWidthStyle('node', 'phone', ids)).toEqual({ width: '38%' });
expect(getProxmoxHostColumnWidthStyle('cpu', 'phone', ids)).toEqual({ width: '15.5%' });
expect(getProxmoxHostColumnWidthStyle('disk', 'phone', ids)).toEqual({ width: '15.5%' });
expect(getProxmoxHostColumnWidthStyle('uptime', 'phone', ids)).toEqual({ width: '15.5%' });
});
it('prioritizes live utilization columns in the mobile host table', () => {
const columns = getProxmoxHostVisibleColumnsForLayout('mobile');
const ids = columns.map((column) => column.id);
expect(ids).toEqual(['node', 'cpu', 'memory', 'disk', 'temp', 'uptime']);
expect(getProxmoxHostTableMinWidthClass('mobile')).toBe('min-w-0');
expect(getProxmoxHostColumnWidthStyle('node', 'mobile', ids)).toEqual({ width: '30%' });
expect(getProxmoxHostColumnWidthStyle('cpu', 'mobile', ids)).toEqual({ width: '13.3824%' });
expect(getProxmoxHostColumnWidthStyle('memory', 'mobile', ids)).toEqual({
width: '13.3824%',
});
expect(getProxmoxHostColumnWidthStyle('disk', 'mobile', ids)).toEqual({ width: '13.3824%' });
expect(getProxmoxHostColumnWidthStyle('temp', 'mobile', ids)).toEqual({ width: '15.4412%' });
expect(getProxmoxHostColumnWidthStyle('uptime', 'mobile', ids)).toEqual({
width: '14.4118%',
});
});
it('adds operational context before inventory metadata on tablet', () => {
expect(getProxmoxHostVisibleColumnsForLayout('tablet').map((column) => column.id)).toEqual([
'node',
'cpu',
'memory',
'disk',
'temp',
'uptime',
'cluster',
]);
expect(getProxmoxHostTableMinWidthClass('tablet')).toBe('min-w-200');
});
it('adds guest counts on compact and reserves version for wide layouts', () => {
const compactIds = getProxmoxHostVisibleColumnsForLayout('compact').map((column) => column.id);
expect(compactIds).toEqual([
'node',
'cpu',
'memory',
'disk',
'temp',
'uptime',
'vms',
'cts',
'cluster',
]);
expect(getProxmoxHostColumnWidthStyle('cluster', 'compact', compactIds)).toEqual({
width: '10%',
});
expect(getProxmoxHostVisibleColumnsForLayout('wide').map((column) => column.id)).toEqual([
'node',
'version',
'cpu',
'memory',
'disk',
'temp',
'uptime',
'vms',
'cts',
'cluster',
]);
});
it('chooses host columns from available container width', () => {
expect(getProxmoxHostTableLayoutModeForContainer(359)).toBe('narrow');
expect(getProxmoxHostTableLayoutModeForContainer(360)).toBe('phone');
expect(getProxmoxHostTableLayoutModeForContainer(439)).toBe('phone');
expect(getProxmoxHostTableLayoutModeForContainer(440)).toBe('mobile');
expect(getProxmoxHostTableLayoutModeForContainer(799)).toBe('mobile');
expect(getProxmoxHostTableLayoutModeForContainer(800)).toBe('tablet');
expect(getProxmoxHostTableLayoutModeForContainer(1039)).toBe('tablet');
expect(getProxmoxHostTableLayoutModeForContainer(1040)).toBe('compact');
expect(getProxmoxHostTableLayoutModeForContainer(1319)).toBe('compact');
expect(getProxmoxHostTableLayoutModeForContainer(1320)).toBe('wide');
});
it('fits the container on compact and reserves the fixed floor only on wide', () => {
// The compact band covers most laptops. Forcing a 1240px floor
// there pushed the rightmost column behind a horizontal scroll, so compact
// now fits its container; only wide keeps the fixed-width floor.
expect(getProxmoxHostTableMinWidthClass('compact')).toBe('min-w-5xl');
expect(getProxmoxHostTableMinWidthClass('wide')).toBe('min-w-[1240px]');
});
});