47 lines
2.6 KiB
TypeScript
47 lines
2.6 KiB
TypeScript
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { expect, it } from 'vitest';
|
|
import { DeviceInventoryPanels, systemDetails } from './device-inventory';
|
|
|
|
const report = (scope: string, data: unknown, truncated = false, quality = 'valid') =>
|
|
({ scope, data, truncated, quality, observed_at: '2026-11-18T08:00:00Z' });
|
|
|
|
it('reads current and older Linux snapshots, and labels approximate installation time', () => {
|
|
const device = { inventory: { observations: [
|
|
report('linux.os', { installed_at: '2025-03-12T10:00:00Z', install_date_source: 'root_filesystem', uptime_seconds: 60 }),
|
|
report('linux.hardware', { readable_dmi: { sys_vendor: 'Vendor' } }),
|
|
report('linux.interfaces', [{ name: 'eth0', addresses: ['192.0.2.1', '2001:db8::1%0'] }]),
|
|
report('linux.users', ['alice']),
|
|
report('linux.software', [{ name: 'openssh-server', version: '1.2', architecture: 'arm64' }], true)
|
|
] } };
|
|
expect(systemDetails(device, value => typeof value === 'string' ? value : 'Nicht gemeldet')).toEqual([
|
|
['OS installiert am', '2025-03-12T10:00:00Z · geschätzt (Root-Dateisystem)'],
|
|
['Letzter Neustart', '2026-11-18T07:59:00.000Z'],
|
|
['Hersteller', 'Vendor'],
|
|
['BIOS-Seriennummer', 'Nicht gemeldet'],
|
|
['Garantie bis', 'Nicht gemeldet']
|
|
]);
|
|
const view = renderToStaticMarkup(<DeviceInventoryPanels device={device} />);
|
|
expect(view).toContain('192.0.2.1, 2001:db8::1');
|
|
expect(view).toContain('alice');
|
|
expect(view).toContain('openssh-server');
|
|
expect(view).toContain('einen Teil der gefundenen Einträge');
|
|
});
|
|
|
|
it('shows Windows adapters, serial and registry software, with unknown distinct from empty sessions', () => {
|
|
const device = { inventory: { observations: [
|
|
report('windows.os', { booted_at: '2026-11-18T08:00:00Z' }),
|
|
report('windows.hardware', { manufacturer: 'Vendor', bios_serial_number: 'ABC123' }),
|
|
report('windows.interfaces', { entries: [{ name: 'Ethernet', addresses: ['192.0.2.2'] }] }),
|
|
report('windows.users', null, false, 'permission_denied'),
|
|
report('windows.software', { entries: [{ display_name: 'Produkt', publisher: 'Hersteller' }] })
|
|
] } };
|
|
const view = renderToStaticMarkup(<DeviceInventoryPanels device={device} />);
|
|
expect(view).toContain('Ethernet');
|
|
expect(view).toContain('Produkt');
|
|
expect(view).toContain('Nicht gemeldet');
|
|
expect(view).not.toContain('Keine Benutzer angemeldet');
|
|
expect(systemDetails(device, String)).toContainEqual(['BIOS-Seriennummer', 'ABC123']);
|
|
device.inventory.observations[3] = report('windows.users', { entries: [] });
|
|
expect(renderToStaticMarkup(<DeviceInventoryPanels device={device} />)).toContain('Keine Benutzer angemeldet');
|
|
});
|