Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

1.6 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import type { Resource } from '@/types/resource';
import { buildServiceDetailLinks } from '@/components/Infrastructure/serviceDetailLinks';

const baseResource = (overrides: Partial<Resource>): Resource => ({
  id: 'resource-1',
  type: 'agent',
  name: 'host-1',
  displayName: 'Host 1',
  platformId: 'host-1',
  platformType: 'agent',
  sourceType: 'api',
  status: 'online',
  lastSeen: Date.now(),
  platformData: { sources: ['agent'] },
  ...overrides,
});

describe('buildServiceDetailLinks', () => {
  it('returns no service links for PBS now that the standalone Recovery surface is retired', () => {
    const links = buildServiceDetailLinks(
      baseResource({
        id: 'pbs-main',
        type: 'pbs',
        name: 'pbs-main',
        displayName: 'PBS Main',
        platformType: 'proxmox-pbs',
      }),
    );

    expect(links).toEqual([]);
  });

  it('returns PMG drill-down link to mail gateway thresholds', () => {
    const links = buildServiceDetailLinks(
      baseResource({
        id: 'pmg-main',
        type: 'pmg',
        name: 'pmg-main',
        displayName: 'PMG Main',
        platformType: 'proxmox-pmg',
      }),
    );

    expect(links).toEqual([
      {
        href: '/alerts/thresholds/mail-gateway',
        label: 'Open PMG thresholds',
        compactLabel: 'Thresholds',
        ariaLabel: 'Open PMG thresholds for PMG Main',
      },
    ]);
  });

  it('returns no service links for non-service resources', () => {
    const links = buildServiceDetailLinks(baseResource({ type: 'agent' }));
    expect(links).toEqual([]);
  });
});