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 {
workspaceGuidanceCopy,
workspaceHealthLabel,
workspaceHealthState,
workspaceIdentityCopy,
workspaceRowNote,
workspaceSetupDiagnostics,
workspaceSetupGuide,
workspaceSetupLabel,
workspaceSetupNextStep,
workspaceSetupSteps,
workspaceSetupState,
workspaceStatusCopy,
} from './workspace_presentation';
import type { PortalWorkspaceSummary } from './types';
function createWorkspace(overrides: Partial<PortalWorkspaceSummary> = {}): PortalWorkspaceSummary {
return {
id: 'ws_1',
display_name: 'Alpha Workspace',
state: 'active',
healthy: true,
health_status: 'healthy',
...overrides,
};
}
describe('workspace presentation', function() {
it('derives consistent literal copy for healthy, pending, unhealthy, and suspended workspaces', function() {
var healthy = createWorkspace({ setup_status: 'ready' });
var checking = createWorkspace({ healthy: false, health_status: 'checking' });
var unhealthy = createWorkspace({ healthy: false, health_status: 'unhealthy' });
var suspended = createWorkspace({ state: 'suspended', health_status: 'healthy' });
expect(workspaceHealthState(healthy)).toBe('healthy');
expect(workspaceStatusCopy(healthy)).toBe('Latest health check is healthy.');
expect(workspaceHealthLabel(healthy)).toBe('Healthy');
expect(workspaceRowNote(healthy)).toBe('Ready');
expect(workspaceHealthState(checking)).toBe('checking');
expect(workspaceStatusCopy(checking)).toBe('Latest health check is still pending.');
expect(workspaceHealthLabel(checking)).toBe('Checking');
expect(workspaceRowNote(checking)).toBe('Health check pending');
expect(workspaceHealthState(unhealthy)).toBe('unhealthy');
expect(workspaceStatusCopy(unhealthy)).toBe('Latest health check is unhealthy.');
expect(workspaceHealthLabel(unhealthy)).toBe('Unhealthy');
expect(workspaceRowNote(unhealthy)).toBe('Unhealthy');
expect(workspaceStatusCopy(suspended)).toBe('This workspace is suspended.');
expect(workspaceRowNote(suspended)).toBe('Suspended');
});
it('uses literal setup guidance instead of commentary', function() {
expect(workspaceGuidanceCopy(createWorkspace({ setup_status: 'ready' }))).toBe('Open the workspace when you need to work inside this client boundary.');
expect(workspaceGuidanceCopy(createWorkspace())).toBe('Open the workspace or install agents from the workspace-bound setup path.');
expect(workspaceGuidanceCopy(createWorkspace({ healthy: false, health_status: 'checking' }))).toBe('This workspace is active. The latest health check is still pending, but the workspace can still own agent install commands.');
expect(workspaceGuidanceCopy(createWorkspace({ healthy: false, health_status: 'unhealthy' }))).toBe('The latest health check is unhealthy. Review the current state before suspending or deleting this workspace.');
expect(workspaceGuidanceCopy(createWorkspace({ state: 'suspended', health_status: 'healthy' }))).toBe('This workspace is suspended. The remaining destructive action here is deletion.');
});
it('derives setup state from explicit status and optional setup counts', function() {
expect(workspaceSetupState(createWorkspace())).toBe('setup_path');
expect(workspaceSetupLabel(createWorkspace())).toBe('Setup path');
expect(workspaceRowNote(createWorkspace())).toBe('Setup path ready');
expect(workspaceSetupNextStep(createWorkspace({ setup_status: 'install_agents' }))).toBe('Install the first agent from this workspace so client data lands in the isolated workspace boundary.');
expect(workspaceSetupState(createWorkspace({ agent_count: 0 }))).toBe('install_agents');
expect(workspaceSetupState(createWorkspace({ setup_status: 'setup_path', agent_count: 0 }))).toBe('install_agents');
expect(workspaceSetupState(createWorkspace({ agent_count: 1, alert_route_count: 0, report_schedule_count: 0 }))).toBe('configure_outputs');
expect(workspaceSetupState(createWorkspace({ agent_count: 1, alert_route_count: 1, report_schedule_count: 1 }))).toBe('ready');
expect(workspaceSetupState(createWorkspace({ state: 'failed', healthy: false, health_status: 'unhealthy' }))).toBe('review');
});
it('explains setup blockers from backend-owned diagnostic facts', function() {
var install = createWorkspace({
agent_count: 0,
agent_token_count: 1,
unused_agent_token_count: 1,
alert_route_count: 0,
report_schedule_count: 0,
});
expect(workspaceSetupGuide(install).title).toBe('Install the first agent');
expect(workspaceSetupGuide(install).primaryAction).toBe('install');
expect(workspaceSetupDiagnostics(install)).toContain('Agent install token exists, but no reporting agent has checked in yet.');
expect(workspaceIdentityCopy(install)).toContain('Hostnames can repeat across clients');
var outputs = createWorkspace({
agent_count: 1,
alert_route_count: 0,
disabled_alert_route_count: 1,
report_schedule_count: 0,
disabled_report_schedule_count: 1,
});
expect(workspaceSetupGuide(outputs).title).toBe('Configure alerts and reports');
expect(workspaceSetupGuide(outputs).primaryAction).toBe('outputs');
expect(workspaceSetupDiagnostics(outputs)).toContain('Alert route configuration exists, but no route is enabled.');
expect(workspaceSetupDiagnostics(outputs)).toContain('Report schedule exists, but no schedule is enabled.');
});
it('builds a guided setup step model from the same readiness rules', function() {
var steps = workspaceSetupSteps(createWorkspace({
agent_count: 1,
alert_route_count: 1,
report_schedule_count: 0,
}));
expect(steps.map(function(step) { return step.id; })).toEqual(['workspace', 'agent', 'alerts', 'reports', 'access']);
expect(steps.find(function(step) { return step.id === 'agent'; })?.tone).toBe('done');
expect(steps.find(function(step) { return step.id === 'alerts'; })?.tone).toBe('done');
expect(steps.find(function(step) { return step.id === 'reports'; })?.tone).toBe('next');
});
});