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.0 KB
Raw Blame
import { afterEach, describe, expect, it, vi } from 'vitest';

const apiFetchJSONMock = vi.hoisted(() => vi.fn());

vi.mock('@/utils/apiClient', () => ({
  apiFetchJSON: apiFetchJSONMock,
}));

import { AgentContextAPI } from '@/api/agentContext';

describe('AgentContextAPI', () => {
  afterEach(() => {
    apiFetchJSONMock.mockReset();
  });

  it('fetches resource context with encoded canonical or source IDs', async () => {
    apiFetchJSONMock.mockResolvedValue({
      canonicalId: 'system-container-6adaf34f529d241a',
      resourceType: 'system-container',
      resourceName: 'homeassistant',
      activeFindings: [],
      pendingApprovals: [],
      recentActions: [],
      contextSections: [],
      generatedAt: '2026-06-04T15:00:00Z',
    });

    const context = await AgentContextAPI.getResourceContext('delly:delly:101');

    expect(apiFetchJSONMock).toHaveBeenCalledWith(
      '/api/agent/resource-context/delly%3Adelly%3A101',
    );
    expect(context.canonicalId).toBe('system-container-6adaf34f529d241a');
  });
});