Add host temperature telemetry and history

This commit is contained in:
2026-10-13 23:39:04 -04:00
parent 09396ab584
commit 171f657876
28 changed files with 1466 additions and 32 deletions
+35
View File
@@ -9,6 +9,7 @@ import {
stableHostOrder
} from '../../src/lib/ui/host-overview.js';
import HostList from '../../src/lib/ui/components/HostList.svelte';
import HostTemperatures from '../../src/lib/ui/components/HostTemperatures.svelte';
const now = Date.parse('2026-10-06T12:00:00Z');
function host(id = 'ec-1', changes: Partial<Host> = {}): Host {
@@ -43,6 +44,40 @@ function host(id = 'ec-1', changes: Partial<Host> = {}): Host {
};
}
it('shows CPU temperature with stale status and keeps sensor details expandable', () => {
const target = host('ec-2', {
connected: false,
inventory: {
cpuUsagePercent: 25,
temperatures: [
{
id: 'cpu',
kind: 'cpu-package',
device: 'coretemp',
label: 'Package id 0',
celsius: 65
}
]
}
});
const list = render(HostList, {
props: {
hosts: [{ ...target, serverCount: 0, playerCount: 0, unreportedInstances: 0 }],
now
}
}).body;
expect(list).toContain('CPU temp: 65 °C');
expect(list).toContain('Resource readings stale');
const detail = render(HostTemperatures, { props: { host: target } }).body;
expect(detail).toContain('(last reported)');
expect(detail).toContain('Temperature sensors');
expect(detail).toContain('CPU package 0');
expect(detail).not.toMatch(/<details[^>]*open/);
const missing = render(HostTemperatures, { props: { host: host() } }).body;
expect(missing).toContain('Unavailable');
expect(missing).not.toContain('0 °C');
});
it('does not show an old Ready state as available when the heartbeat becomes stale', () => {
expect(hostListStatus(host(), now).label).toBe('Ready');
expect(hostReadingsStale(host(), now + 90_001)).toBe(true);