Files
rust-discovery/web/src/proxmox.test.tsx
T
kevin_janssenandClaude Opus 5.5 ce356f0de7
Rust development slice / linux (push) Failing after 14s
Show Proxmox guests and scheduled backup status in device details
The host detail lists VMs and containers with linked inventory devices and
last successful backup, each vzdump job with its due time and result, an
overall 'all scheduled backups ran' answer and guests without a job. VM hosts
detected from a Proxmox guest list are labelled and the assignment form can
hand the decision back to automatic detection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:12:54 +01:00

41 lines
2.4 KiB
TypeScript

import { renderToStaticMarkup } from 'react-dom/server';
import { expect, it } from 'vitest';
import { ProxmoxDetails } from './proxmox';
const data = { node: 'pve', cluster: null, version: '9.2.2', not_backed_up: [101],
guests: [
{ vmid: 100, name: 'debian-guest', kind: 'qemu', status: 'running', template: false, cpus: 1,
memory_bytes: 2 ** 30, disk_bytes: 2 ** 33, macs: ['bc:24:11:88:35:97'] },
{ vmid: 101, name: 'alpine-ct', kind: 'lxc', status: 'running', template: false, cpus: 1,
memory_bytes: 2 ** 27, disk_bytes: 2 ** 30, macs: [] }],
backup_jobs: [{ id: 'backup-debian', enabled: true, schedule: '*/2:00', storage: 'local',
selection: 'vmid', covered_vmids: [100], last_expected_run: 1795172400, next_run: 1795179600 }],
backup_runs: [] };
it('lists guests, linked devices and an overall backup answer', () => {
const view = renderToStaticMarkup(<ProxmoxDetails device={{ tenant_id: 't', proxmox: {
quality: 'valid', observed_at: '2026-11-20T12:00:00Z', data,
backup_status: { all_scheduled_backups_ran: true, last_success_at: { '100': 1795172488 },
jobs: [{ id: 'backup-debian', status: 'ok', guests: [{ vmid: 100, status: 'ok' }] }] },
guest_devices: [{ vmid: 100, asset_id: 'a', agent_id: 'b', hostname: 'debian-guest' }] } }} />);
expect(view).toContain('Alle geplanten Backups sind gelaufen.');
expect(view).toContain('href="#geraete/t/a/b"');
expect(view).toContain('Container');
expect(view).toMatch(/Ohne Backupjob<\/h3><p>101 alpine-ct/);
expect(view).toContain('Gelaufen');
});
it('names failed guests and explains a missing read token', () => {
const failed = renderToStaticMarkup(<ProxmoxDetails device={{ proxmox: { quality: 'valid', data,
backup_status: { all_scheduled_backups_ran: false, last_success_at: {},
jobs: [{ id: 'backup-debian', status: 'failed', guests: [{ vmid: 100, status: 'failed' }] }] },
guest_devices: [] } }} />);
expect(failed).toContain('Nicht alle geplanten Backups sind gelaufen.');
expect(failed).toContain('100 debian-guest: Fehlgeschlagen');
expect(failed).toContain('nicht zugeordnet');
const missing = renderToStaticMarkup(<ProxmoxDetails device={{ proxmox: {
quality: 'unsupported', error_code: 'PROXMOX_NOT_CONFIGURED', data: null } }} />);
expect(missing).toContain('kein Lesezugang');
expect(renderToStaticMarkup(<ProxmoxDetails device={{}} />)).toBe('');
});