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, within } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
import {
DetailSectionTable,
InlineDetailPanel,
compactDetailRows,
compactDetailSections,
formatDetailBytesValue,
formatDetailCountValue,
formatDetailIntegerValue,
makeDetailRow,
} from '../DetailSectionTable';
import { TechnicalDetailsDisclosure, TechnicalDetailsSection } from '../TechnicalDetailsDisclosure';
describe('DetailSectionTable', () => {
afterEach(() => cleanup());
it('keeps detail section row shaping in the shared model', () => {
expect(
compactDetailRows([
makeDetailRow('Host', ' tower '),
makeDetailRow('Blank', ' '),
makeDetailRow('Fallback', '-'),
]),
).toEqual([{ label: 'Host', value: 'tower' }]);
expect(
compactDetailSections([
{ label: 'Runtime', rows: [] },
{ label: 'Host', rows: [makeDetailRow('Name', 'tower')!] },
]),
).toEqual([{ label: 'Host', rows: [{ label: 'Name', value: 'tower' }] }]);
});
it('keeps detail numeric formatting in the shared model', () => {
expect(formatDetailBytesValue(undefined)).toBeNull();
expect(formatDetailBytesValue(0)).toBeNull();
expect(formatDetailBytesValue(0, { allowZero: true })).toBe('0 B');
expect(formatDetailBytesValue(8 * 1024 ** 3)).toBe('8.00 GB');
expect(
formatDetailBytesValue(8 * 1024 ** 3, {
allowZero: true,
precision: 'compact',
trimWhole: true,
}),
).toBe('8 GB');
expect(formatDetailIntegerValue(1234.6)).toBe(new Intl.NumberFormat().format(1235));
expect(formatDetailCountValue(1, 'disk')).toBe('1 disk');
expect(formatDetailCountValue(2, 'vCPU', 'vCPU')).toBe('2 vCPU');
expect(formatDetailCountValue(undefined, 'disk')).toBeNull();
});
it('keeps compact rows in narrow panels and bounded cards only in a wide local container', () => {
const { container } = render(() => (
<DetailSectionTable
sections={[
{
label: 'Alert',
rows: [
{ label: 'Severity', value: 'Warning', tone: 'warning' },
{ label: 'Resource', value: 'tower', title: 'tower.example.test' },
],
},
{
label: 'Runtime',
rows: [{ label: 'Kernel', value: '6.8.0' }],
},
]}
/>
));
expect(screen.getByText('Alert')).toBeInTheDocument();
expect(screen.getByText('Severity')).toBeInTheDocument();
expect(screen.getByText('Warning').closest('td')).toHaveClass('text-amber-700');
expect(screen.getByText('tower').closest('td')).toHaveAttribute('title', 'tower.example.test');
const table = container.querySelector('table');
expect(table?.closest('[data-detail-section-container]')).toHaveClass(
'@container/detail-sections',
);
expect(table).not.toHaveClass('lg:flex');
expect(table).toHaveClass(
'table-fixed',
'@min-[64rem]/detail-sections:flex',
'@min-[64rem]/detail-sections:flex-wrap',
'@min-[64rem]/detail-sections:items-stretch',
);
const sections = container.querySelectorAll('tbody');
expect(sections).toHaveLength(2);
expect(sections[0]).toHaveClass(
'@min-[64rem]/detail-sections:flex',
'@min-[64rem]/detail-sections:flex-none',
'@min-[64rem]/detail-sections:basis-[calc(50%-0.25rem)]',
'@min-[64rem]/detail-sections:rounded-sm',
'@min-[64rem]/detail-sections:border',
'@min-[64rem]/detail-sections:p-3',
);
expect(screen.getByText('Severity').closest('tr')).toHaveClass(
'@min-[64rem]/detail-sections:grid',
'@min-[64rem]/detail-sections:grid-cols-[7rem_minmax(0,1fr)]',
'@min-[64rem]/detail-sections:gap-3',
);
expect(screen.getByText('Warning').closest('td')).toHaveClass(
'@min-[64rem]/detail-sections:text-left',
);
});
it('preserves section test hooks and rich value content inside the shared layout', () => {
render(() => (
<DetailSectionTable
dataTestId="resource-summary"
sections={[
{
label: 'Container',
testId: 'resource-container-section',
rows: [
{
label: 'Release information',
value: 'View release',
valueClass: 'font-mono',
valueContent: <a href="https://example.test/release">View release</a>,
},
],
},
]}
/>
));
expect(screen.getByTestId('resource-summary')).toBeInTheDocument();
expect(screen.getByTestId('resource-container-section').tagName).toBe('TBODY');
expect(screen.getByRole('link', { name: 'View release' })).toHaveAttribute(
'href',
'https://example.test/release',
);
expect(screen.getByRole('link', { name: 'View release' }).closest('td')).toHaveClass(
'font-mono',
);
});
it('keeps full-width supporting content inside its responsive section card', () => {
render(() => (
<DetailSectionTable
sections={[
{
label: 'Analysis',
rows: [{ label: 'Health', value: 'A · 92/100' }],
footerContent: <div data-testid="analysis-footer">Latest canonical change</div>,
},
]}
/>
));
const footer = screen.getByTestId('analysis-footer');
expect(footer).toBeInTheDocument();
expect(footer.closest('td')).toHaveAttribute('colspan', '2');
expect(footer.closest('tr')).toHaveClass(
'@min-[64rem]/detail-sections:border-t',
'@min-[64rem]/detail-sections:pt-2',
);
});
it('renders optional row progress without replacing its compact text value', () => {
const { container } = render(() => (
<DetailSectionTable
sections={[
{
label: 'Filesystems',
rows: [
{
label: '/',
value: '50% · 5.00 GB/10.0 GB · ROOTFS',
progress: {
value: 50,
fillClass: 'bg-emerald-500',
ariaLabel: 'Filesystem / utilization',
},
},
],
},
]}
/>
));
expect(screen.getByText('50% · 5.00 GB/10.0 GB · ROOTFS')).toBeInTheDocument();
const progress = screen.getByRole('progressbar', { name: 'Filesystem / utilization' });
expect(progress).toHaveAttribute('aria-valuemin', '0');
expect(progress).toHaveAttribute('aria-valuemax', '100');
expect(progress).toHaveAttribute('aria-valuenow', '50');
expect(progress).toHaveClass('h-1.5');
const fill = container.querySelector('[data-progress-fill="true"]');
expect(fill).toHaveAttribute('width', '50');
expect(fill?.firstElementChild).toHaveClass('bg-emerald-500');
});
it('opts long identifying labels into full-width wrapping rows without changing compact rows', () => {
const path = '/mnt/media/animation/series';
render(() => (
<DetailSectionTable
sections={[
{
label: 'Filesystems',
rows: compactDetailRows([
makeDetailRow(path, '50% · 5 GB/10 GB', { layout: 'stacked', wrap: true }),
makeDetailRow('Status', 'Available'),
]),
},
]}
/>
));
const label = screen.getByText(path);
expect(label).toHaveClass('whitespace-normal', 'wrap-anywhere', 'text-left');
expect(label.closest('td')).toHaveAttribute('colspan', '2');
expect(label.closest('tr')?.querySelectorAll('td')).toHaveLength(1);
expect(label.closest('tr')).toHaveClass(
'@min-[64rem]/detail-sections:grid-cols-[minmax(0,1fr)]',
);
expect(screen.getByText('50% · 5 GB/10 GB').closest('td')).toBe(label.closest('td'));
expect(screen.getByText('Status').closest('tr')).toHaveClass(
'@min-[64rem]/detail-sections:grid-cols-[7rem_minmax(0,1fr)]',
);
expect(screen.getByText('Status').closest('tr')?.querySelectorAll('td')).toHaveLength(2);
});
it('fills five desktop sections on the same three-column tracks', () => {
const { container } = render(() => (
<DetailSectionTable
sections={Array.from({ length: 5 }, (_, index) => ({
label: `Section ${index + 1}`,
rows: [{ label: 'Value', value: String(index + 1) }],
}))}
/>
));
const sections = container.querySelectorAll('tbody');
expect(sections).toHaveLength(5);
Array.from(sections)
.slice(0, 3)
.forEach((section) =>
expect(section).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(33.333%-0.333rem)]'),
);
expect(sections[3]).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(66.667%-0.167rem)]');
expect(sections[4]).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(33.333%-0.333rem)]');
});
it('fills seven desktop sections on the same four-column tracks', () => {
const { container } = render(() => (
<DetailSectionTable
sections={Array.from({ length: 7 }, (_, index) => ({
label: `Section ${index + 1}`,
rows: [{ label: 'Value', value: String(index + 1) }],
}))}
/>
));
const sections = container.querySelectorAll('tbody');
expect(sections).toHaveLength(7);
Array.from(sections)
.slice(0, 4)
.forEach((section) =>
expect(section).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(25%-0.375rem)]'),
);
expect(sections[4]).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(50%-0.25rem)]');
expect(sections[5]).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(25%-0.375rem)]');
expect(sections[6]).toHaveClass('@min-[64rem]/detail-sections:basis-[calc(25%-0.375rem)]');
});
it('lazily renders technical details with the same compact section rows', () => {
const { container } = render(() => (
<TechnicalDetailsDisclosure
dataTestId="technical-details"
subtitle="Identity and runtime"
sections={[
{
label: 'Runtime',
rows: [{ label: 'Kernel', value: '6.8.0' }],
},
]}
/>
));
expect(screen.queryByText('Runtime')).toBeNull();
const details = container.querySelector('details');
expect(details).not.toBeNull();
details!.open = true;
fireEvent(details!, new Event('toggle'));
const disclosure = screen.getByTestId('technical-details');
expect(within(disclosure).getByText('Runtime')).toBeInTheDocument();
expect(within(disclosure).getByText('Kernel')).toBeInTheDocument();
expect(within(disclosure).getByText('6.8.0')).toBeInTheDocument();
expect(disclosure.querySelector('table')).toHaveClass('table-fixed');
});
it('renders curated technical rows without an extra disclosure interaction', () => {
render(() => (
<TechnicalDetailsSection
dataTestId="technical-section"
sections={[
{
label: 'Hardware',
rows: [{ label: 'CPU', value: 'Ryzen' }],
},
]}
/>
));
const section = screen.getByTestId('technical-section');
expect(section.tagName).toBe('DIV');
expect(section.querySelector('details')).toBeNull();
expect(within(section).getByText('Hardware')).toBeInTheDocument();
expect(within(section).getByText('Ryzen')).toBeInTheDocument();
});
it('renders inline detail panels with the canonical close action', () => {
const onClose = vi.fn();
render(() => (
<InlineDetailPanel
testId="platform-detail"
detailFor="resource-1"
title="Disk sda"
status={{ variant: 'warning', label: 'Warning' }}
summary="Warning"
sections={[{ label: 'Alert', rows: [{ label: 'Severity', value: 'Warning' }] }]}
detailAttributes={{ 'data-platform-alert-detail-for': 'resource-1' }}
onClose={onClose}
/>
));
const panel = screen.getByTestId('platform-detail');
expect(panel).toHaveAttribute('data-inline-detail-for', 'resource-1');
expect(panel).toHaveAttribute('data-platform-alert-detail-for', 'resource-1');
expect(within(panel).getByRole('heading', { name: 'Disk sda' })).toBeInTheDocument();
expect(within(panel).getByLabelText('Warning')).toBeInTheDocument();
expect(within(panel).getAllByText('Warning')).toHaveLength(2);
within(panel).getByRole('button', { name: 'Collapse Disk sda details' }).click();
expect(onClose).toHaveBeenCalledTimes(1);
});
});