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.

Harden infrastructure workload identity regressions

rcourtman439e252a642a
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 307fafb889..2dc6d82e7e 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -220,6 +220,10 @@ cross-source deduplication.
parent evidence, and both snapshot ingest and already-unified registry seed
paths must attach them to the same merged host resource before REST,
websocket, Workloads, or Infrastructure consumers render the estate.
+ This derivation must tolerate node source IDs that retain a previous cluster
+ alias while the current Proxmox metadata exposes a renamed instance or
+ cluster label; current node metadata is the fallback source of truth when
+ source-key lookup misses.
Resource detail mappers now reuse the shared
`frontend-modern/src/utils/textPresentation.ts` title-case helper for sensor
diff --git a/internal/api/resources_test.go b/internal/api/resources_test.go
index 81c3968351..2dafd532e7 100644
--- a/internal/api/resources_test.go
+++ b/internal/api/resources_test.go
@@ -12,9 +12,11 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
+ "github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
"github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"
"github.com/rcourtman/pulse-go-rewrite/internal/truenas"
unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+ authpkg "github.com/rcourtman/pulse-go-rewrite/pkg/auth"
)
type resourceStateProvider struct {
@@ -73,6 +75,10 @@ func (m mockSupplementalRecordsProvider) SnapshotOwnedSources() []unified.DataSo
return out
}
+func (m mockSupplementalRecordsProvider) SupplementalRecords(*monitoring.Monitor, string) []unified.IngestRecord {
+ return m.GetCurrentRecords()
+}
+
func TestResourceListRejectsLegacyHostTypeFilter(t *testing.T) {
cfg := &config.Config{DataPath: t.TempDir()}
h := NewResourceHandlers(cfg)
@@ -555,6 +561,183 @@ func TestResourceListCollapsesClusterAndStandaloneNodeViewsByEndpoint(t *testing
}
}
+func TestResourceListDerivesProxmoxWorkloadParentFromUnifiedSeed(t *testing.T) {
+ now := time.Date(2026, 5, 14, 10, 0, 0, 0, time.UTC)
+ cfg := &config.Config{DataPath: t.TempDir()}
+ h := NewResourceHandlers(cfg)
+ h.SetStateProvider(resourceUnifiedSeedProvider{
+ snapshot: models.StateSnapshot{LastUpdate: now},
+ resources: []unified.Resource{
+ {
+ ID: "agent-delly",
+ Type: unified.ResourceTypeAgent,
+ Name: "delly",
+ Status: unified.StatusOnline,
+ LastSeen: now,
+ Sources: []unified.DataSource{unified.SourceProxmox, unified.SourceAgent},
+ Identity: unified.ResourceIdentity{
+ MachineID: "machine-delly",
+ Hostnames: []string{"delly"},
+ },
+ Proxmox: &unified.ProxmoxData{
+ SourceID: "homelab-delly",
+ NodeName: "delly",
+ ClusterName: "homelab",
+ Instance: "delly",
+ },
+ Agent: &unified.AgentData{
+ AgentID: "agent-source-delly",
+ Hostname: "delly",
+ },
+ },
+ {
+ ID: "system-container-cloudflared",
+ Type: unified.ResourceTypeSystemContainer,
+ Name: "cloudflared",
+ Status: unified.StatusOnline,
+ LastSeen: now,
+ Sources: []unified.DataSource{unified.SourceProxmox},
+ Identity: unified.ResourceIdentity{Hostnames: []string{"cloudflared"}},
+ Proxmox: &unified.ProxmoxData{
+ SourceID: "delly:delly:104",
+ NodeName: "delly",
+ ClusterName: "homelab",
+ Instance: "delly",
+ VMID: 104,
+ },
+ },
+ },
+ })
+
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodGet, "/api/resources?type=system-container&q=cloudflared&page=1&limit=20", nil)
+ h.HandleListResources(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+
+ var resp ResourcesResponse
+ if err := json.NewDecoder(rec.Body).Decode(&resp); err != nil {
+ t.Fatalf("decode response: %v", err)
+ }
+
+ if len(resp.Data) != 1 {
+ t.Fatalf("expected 1 cloudflared resource, got %d: %#v", len(resp.Data), resp.Data)
+ }
+ resource := resp.Data[0]
+ if resource.ParentID == nil || *resource.ParentID != "agent-delly" {
+ t.Fatalf("expected cloudflared parent agent-delly, got %+v", resource.ParentID)
+ }
+ if resource.ParentName != "delly" {
+ t.Fatalf("expected cloudflared parentName delly, got %q", resource.ParentName)
+ }
+ if resource.Proxmox == nil || resource.Proxmox.NodeName != "delly" || resource.Proxmox.ClusterName != "homelab" {
+ t.Fatalf("expected cloudflared Proxmox node metadata, got %+v", resource.Proxmox)
+ }
+}
+
+func TestStateEndpointDerivesProxmoxWorkloadParentFromSupplementalRecords(t *testing.T) {
+ now := time.Date(2026, 5, 14, 10, 0, 0, 0, time.UTC)
+ hashedPassword, err := authpkg.HashPassword("password")
+ if err != nil {
+ t.Fatalf("hash password: %v", err)
+ }
+ dataPath := t.TempDir()
+ InitSessionStore(dataPath)
+ InitCSRFStore(dataPath)
+ cfg := &config.Config{
+ DataPath: dataPath,
+ AuthUser: "admin",
+ AuthPass: hashedPassword,
+ }
+ monitor, err := monitoring.New(cfg)
+ if err != nil {
+ t.Fatalf("new monitor: %v", err)
+ }
+ t.Cleanup(func() { monitor.Stop() })
+
+ monitor.SetResourceStore(unified.NewMonitorAdapter(nil))
+ monitor.SetSupplementalRecordsProvider(unified.SourceProxmox, mockSupplementalRecordsProvider{
+ records: []unified.IngestRecord{
+ {
+ SourceID: "homelab-delly",
+ Resource: unified.Resource{
+ Type: unified.ResourceTypeAgent,
+ Name: "delly",
+ Status: unified.StatusOnline,
+ LastSeen: now,
+ Proxmox: &unified.ProxmoxData{
+ SourceID: "homelab-delly",
+ NodeName: "delly",
+ ClusterName: "homelab",
+ Instance: "delly",
+ },
+ },
+ Identity: unified.ResourceIdentity{
+ MachineID: "machine-delly",
+ Hostnames: []string{"delly"},
+ },
+ },
+ {
+ SourceID: "delly:delly:104",
+ Resource: unified.Resource{
+ Type: unified.ResourceTypeSystemContainer,
+ Name: "cloudflared",
+ Status: unified.StatusOnline,
+ LastSeen: now,
+ Proxmox: &unified.ProxmoxData{
+ SourceID: "delly:delly:104",
+ NodeName: "delly",
+ ClusterName: "homelab",
+ Instance: "delly",
+ VMID: 104,
+ },
+ },
+ Identity: unified.ResourceIdentity{Hostnames: []string{"cloudflared"}},
+ },
+ },
+ })
+
+ router := &Router{config: cfg, monitor: monitor}
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodGet, "/api/state", nil)
+ req.SetBasicAuth("admin", "password")
+ router.handleState(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("/api/state status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+
+ var state models.StateFrontend
+ if err := json.NewDecoder(rec.Body).Decode(&state); err != nil {
+ t.Fatalf("decode /api/state: %v", err)
+ }
+
+ dellyCount := 0
+ dellyID := ""
+ cloudflaredParentID := ""
+ for _, resource := range state.Resources {
+ switch {
+ case resource.Type == string(unified.ResourceTypeAgent) && resource.Name == "delly":
+ dellyCount++
+ dellyID = resource.ID
+ case resource.Type == string(unified.ResourceTypeSystemContainer) && resource.Name == "cloudflared":
+ cloudflaredParentID = resource.ParentID
+ }
+ }
+
+ if dellyCount != 1 {
+ t.Fatalf("expected exactly one delly resource in /api/state, got %d: %#v", dellyCount, state.Resources)
+ }
+ if dellyID == "" {
+ t.Fatalf("expected delly resource id in /api/state: %#v", state.Resources)
+ }
+ if cloudflaredParentID != dellyID {
+ t.Fatalf("expected cloudflared parent %q, got %q: %#v", dellyID, cloudflaredParentID, state.Resources)
+ }
+}
+
func TestResourceListCollapsesAsymmetricLinkedClusterNodeViews(t *testing.T) {
now := time.Now().UTC()
snapshot := models.StateSnapshot{
diff --git a/internal/mock/platform_fixtures_test.go b/internal/mock/platform_fixtures_test.go
index a09d6068b7..0232a8bf68 100644
--- a/internal/mock/platform_fixtures_test.go
+++ b/internal/mock/platform_fixtures_test.go
@@ -54,6 +54,50 @@ func TestUnifiedResourceSnapshotIncludesPlatformFixtures(t *testing.T) {
}
}
+func TestUnifiedResourceSnapshotParentsDemoProxmoxWorkloads(t *testing.T) {
+ previous := IsMockEnabled()
+ SetEnabled(true)
+ t.Cleanup(func() { SetEnabled(previous) })
+
+ resources, _ := UnifiedResourceSnapshot()
+ agentsByID := make(map[string]unifiedresources.Resource)
+ for _, resource := range resources {
+ if resource.Type == unifiedresources.ResourceTypeAgent {
+ agentsByID[resource.ID] = resource
+ }
+ }
+
+ proxmoxWorkloadCount := 0
+ for _, resource := range resources {
+ if resource.Type != unifiedresources.ResourceTypeVM && resource.Type != unifiedresources.ResourceTypeSystemContainer {
+ continue
+ }
+ if !slices.Contains(resource.Sources, unifiedresources.SourceProxmox) {
+ continue
+ }
+ proxmoxWorkloadCount++
+ if resource.ParentID == nil || *resource.ParentID == "" {
+ t.Fatalf("expected mock Proxmox workload %q (%s) to have a parent", resource.Name, resource.ID)
+ }
+ parent, ok := agentsByID[*resource.ParentID]
+ if !ok {
+ t.Fatalf("expected mock Proxmox workload %q parent %q to resolve to an agent", resource.Name, *resource.ParentID)
+ }
+ if resource.Proxmox != nil && parent.Proxmox != nil && resource.Proxmox.NodeName != parent.Proxmox.NodeName {
+ t.Fatalf(
+ "expected mock Proxmox workload %q parent node %q, got %q",
+ resource.Name,
+ resource.Proxmox.NodeName,
+ parent.Proxmox.NodeName,
+ )
+ }
+ }
+
+ if proxmoxWorkloadCount == 0 {
+ t.Fatal("expected mock unified resources to include Proxmox workloads")
+ }
+}
+
func TestSupplementalRecordsNormalizesVMwareAlias(t *testing.T) {
records := SupplementalRecords(unifiedresources.DataSource("vmware-vsphere"))
if len(records) == 0 {
diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.go
index b31d1c41c3..2757eae26c 100644
--- a/internal/unifiedresources/registry.go
+++ b/internal/unifiedresources/registry.go
@@ -1852,7 +1852,7 @@ func (rr *ResourceRegistry) proxmoxNodeParentIDLocked(instance, clusterName, nod
}
return parentID
}
- return ""
+ return rr.proxmoxNodeParentIDFromResourcesLocked(instance, clusterName, nodeName, excludeID)
}
func proxmoxNodeParentSourceIDCandidates(instance, clusterName, nodeName string) []string {
@@ -1882,6 +1882,69 @@ func proxmoxNodeParentSourceIDCandidates(instance, clusterName, nodeName string)
return out
}
+func (rr *ResourceRegistry) proxmoxNodeParentIDFromResourcesLocked(instance, clusterName, nodeName, excludeID string) string {
+ nodeName = strings.TrimSpace(nodeName)
+ if nodeName == "" {
+ return ""
+ }
+
+ excludeID = CanonicalResourceID(strings.TrimSpace(excludeID))
+ bestID := ""
+ bestScore := -1
+ for id, resource := range rr.resources {
+ if resource == nil {
+ continue
+ }
+ candidateID := CanonicalResourceID(strings.TrimSpace(id))
+ if candidateID == "" || candidateID == excludeID {
+ continue
+ }
+ if CanonicalResourceType(resource.Type) != ResourceTypeAgent || resource.Proxmox == nil {
+ continue
+ }
+ if !strings.EqualFold(strings.TrimSpace(resource.Proxmox.NodeName), nodeName) {
+ continue
+ }
+ score := proxmoxNodeParentScopeScore(instance, clusterName, resource.Proxmox)
+ if score < 0 {
+ continue
+ }
+ if score > bestScore || (score == bestScore && (bestID == "" || candidateID < bestID)) {
+ bestID = candidateID
+ bestScore = score
+ }
+ }
+ return bestID
+}
+
+func proxmoxNodeParentScopeScore(instance, clusterName string, parent *ProxmoxData) int {
+ if parent == nil {
+ return -1
+ }
+
+ childInstance := strings.TrimSpace(instance)
+ childCluster := strings.TrimSpace(clusterName)
+ parentInstance := strings.TrimSpace(parent.Instance)
+ parentCluster := strings.TrimSpace(parent.ClusterName)
+
+ switch {
+ case childInstance != "" && parentInstance != "" && strings.EqualFold(childInstance, parentInstance):
+ return 40
+ case childCluster != "" && parentCluster != "" && strings.EqualFold(childCluster, parentCluster):
+ return 35
+ case childInstance != "" && parentCluster != "" && strings.EqualFold(childInstance, parentCluster):
+ return 30
+ case childCluster != "" && parentInstance != "" && strings.EqualFold(childCluster, parentInstance):
+ return 30
+ case childInstance == "" && childCluster == "":
+ return 10
+ case parentInstance == "" && parentCluster == "":
+ return 5
+ default:
+ return -1
+ }
+}
+
func (rr *ResourceRegistry) buildChildCounts() {
// ChildCount and ParentName are derived fields. Clear prior values before
// recomputing to prevent stale state after re-parenting or parent removal.
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 5b936cb71a..d8475b8977 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -1432,6 +1432,81 @@ func TestResourceRegistry_IngestSnapshotParentsClusterNamedProxmoxGuestsToMerged
}
}
+func TestResourceRegistry_IngestSnapshotDerivesProxmoxWorkloadParentWhenNodeSourceIDUsesPreviousClusterAlias(t *testing.T) {
+ rr := NewRegistry(nil)
+ now := time.Date(2026, 5, 14, 10, 0, 0, 0, time.UTC)
+
+ rr.IngestSnapshot(models.StateSnapshot{
+ Nodes: []models.Node{
+ {
+ ID: "mock-cluster-pve1",
+ Name: "pve1",
+ DisplayName: "West Production A",
+ Instance: "Core Fabric",
+ ClusterName: "Core Fabric",
+ IsClusterMember: true,
+ Status: "online",
+ LastSeen: now,
+ },
+ },
+ VMs: []models.VM{
+ {
+ ID: "Core Fabric:pve1:100",
+ VMID: 100,
+ Name: "checkout-web-01",
+ Node: "pve1",
+ Instance: "Core Fabric",
+ Status: "running",
+ LastSeen: now,
+ },
+ },
+ Containers: []models.Container{
+ {
+ ID: "Core Fabric:pve1:104",
+ VMID: 104,
+ Name: "auth-service-01",
+ Node: "pve1",
+ Instance: "Core Fabric",
+ Status: "running",
+ LastSeen: now,
+ },
+ },
+ })
+
+ agents := rr.ListByType(ResourceTypeAgent)
+ if len(agents) != 1 {
+ t.Fatalf("expected 1 Proxmox parent resource, got %d", len(agents))
+ }
+ parentID := agents[0].ID
+
+ vms := rr.ListByType(ResourceTypeVM)
+ if len(vms) != 1 {
+ t.Fatalf("expected 1 vm, got %d", len(vms))
+ }
+ if vms[0].ParentID == nil || *vms[0].ParentID != parentID {
+ t.Fatalf("expected vm parent %q from node metadata fallback, got %+v", parentID, vms[0].ParentID)
+ }
+ if vms[0].ParentName != "West Production A" {
+ t.Fatalf("expected vm parent name West Production A, got %q", vms[0].ParentName)
+ }
+
+ containers := rr.ListByType(ResourceTypeSystemContainer)
+ if len(containers) != 1 {
+ t.Fatalf("expected 1 container, got %d", len(containers))
+ }
+ if containers[0].ParentID == nil || *containers[0].ParentID != parentID {
+ t.Fatalf("expected container parent %q from node metadata fallback, got %+v", parentID, containers[0].ParentID)
+ }
+
+ parent, ok := rr.Get(parentID)
+ if !ok {
+ t.Fatalf("expected parent %q", parentID)
+ }
+ if parent.ChildCount != 2 {
+ t.Fatalf("expected parent child count 2, got %d", parent.ChildCount)
+ }
+}
+
func TestResourceRegistry_IngestSnapshotUnifiesHostLinkedProxmoxNodeViewsAcrossEndpointForms(t *testing.T) {
rr := NewRegistry(nil)
now := time.Date(2026, 3, 7, 12, 0, 0, 0, time.UTC)
diff --git a/tests/integration/tests/74-infrastructure-workloads-resource-coherence.spec.ts b/tests/integration/tests/74-infrastructure-workloads-resource-coherence.spec.ts
new file mode 100644
index 0000000000..e02248c816
--- /dev/null
+++ b/tests/integration/tests/74-infrastructure-workloads-resource-coherence.spec.ts
@@ -0,0 +1,285 @@
+import { expect, test as base, type Page } from "@playwright/test";
+
+import {
+ apiRequest,
+ ensureAuthenticated,
+ getMockMode,
+ setMockMode,
+} from "./helpers";
+
+type APIResource = {
+ id: string;
+ type?: string;
+ name?: string;
+ sources?: string[];
+ parentId?: string;
+ parentName?: string;
+ proxmox?: {
+ nodeName?: string;
+ instance?: string;
+ vmid?: number;
+ };
+};
+
+const test = base;
+
+let mockModeWasEnabled: boolean | null = null;
+
+const isProxmoxResource = (resource: APIResource): boolean =>
+ Boolean(resource.proxmox) ||
+ (resource.sources ?? []).some((source) => source === "proxmox");
+
+const isProxmoxWorkload = (resource: APIResource): boolean =>
+ (resource.type === "vm" || resource.type === "system-container") &&
+ isProxmoxResource(resource);
+
+const cssAttrValue = (value: string): string =>
+ value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
+
+async function ensureMockModeEnabled(page: Page): Promise<void> {
+ const state = await getMockMode(page);
+ if (mockModeWasEnabled === null) {
+ mockModeWasEnabled = state.enabled;
+ }
+ if (!state.enabled) {
+ await setMockMode(page, true);
+ }
+}
+
+async function readResources(page: Page): Promise<APIResource[]> {
+ const response = await apiRequest(
+ page,
+ "/api/resources?type=agent,vm,system-container&page=1&limit=500",
+ );
+ expect(
+ response.ok(),
+ `Expected /api/resources to succeed, got ${response.status()}`,
+ ).toBe(true);
+ const payload = (await response.json()) as { data?: APIResource[] };
+ return payload.data ?? [];
+}
+
+function buildProxmoxWorkloadRouteId(resource: APIResource): string {
+ const instance = (resource.proxmox?.instance ?? "").trim();
+ const node = (resource.proxmox?.nodeName ?? "").trim();
+ const vmid = resource.proxmox?.vmid ?? 0;
+ expect(
+ instance,
+ `Expected Proxmox workload ${resource.id} to expose an instance`,
+ ).not.toBe("");
+ expect(
+ node,
+ `Expected Proxmox workload ${resource.id} to expose a node name`,
+ ).not.toBe("");
+ expect(
+ vmid,
+ `Expected Proxmox workload ${resource.id} to expose a VMID`,
+ ).toBeGreaterThan(0);
+ return `${instance}:${node}:${vmid}`;
+}
+
+function buildProxmoxNodeFilterValue(resource: APIResource): string {
+ const instance = (resource.proxmox?.instance ?? "").trim();
+ const node = (resource.proxmox?.nodeName ?? "").trim();
+ expect(
+ instance,
+ `Expected Proxmox workload ${resource.id} to expose an instance`,
+ ).not.toBe("");
+ expect(
+ node,
+ `Expected Proxmox workload ${resource.id} to expose a node name`,
+ ).not.toBe("");
+ return `${instance}-${node}`;
+}
+
+async function assertSurfaceDoesNotBlank(
+ page: Page,
+ testId: string,
+ durationMs: number,
+): Promise<void> {
+ const result = await page.evaluate(
+ async ({ durationMs: sampleDurationMs, testId: targetTestId }) => {
+ const failures: Array<{
+ elapsedMs: number;
+ bodyText: string;
+ rootChildren: number;
+ }> = [];
+ const startedAt = performance.now();
+ let samples = 0;
+
+ while (performance.now() - startedAt < sampleDurationMs) {
+ const root = document.getElementById("root");
+ const target = document.querySelector<HTMLElement>(
+ `[data-testid="${targetTestId}"]`,
+ );
+ const rect = target?.getBoundingClientRect();
+ const targetVisible = Boolean(
+ rect && rect.width > 0 && rect.height > 0,
+ );
+ const rootChildren = root?.childElementCount ?? 0;
+
+ if (!root || rootChildren === 0 || !target || !targetVisible) {
+ failures.push({
+ elapsedMs: Math.round(performance.now() - startedAt),
+ bodyText: (document.body?.innerText ?? "")
+ .replace(/\s+/g, " ")
+ .trim()
+ .slice(0, 120),
+ rootChildren,
+ });
+ }
+
+ samples += 1;
+ await new Promise((resolve) => window.setTimeout(resolve, 250));
+ }
+
+ return { failures, samples };
+ },
+ { durationMs, testId },
+ );
+
+ expect(
+ result.samples,
+ "Expected browser stability sampling to run",
+ ).toBeGreaterThan(0);
+ expect(
+ result.failures,
+ `Expected ${testId} to stay mounted and visible without a blank route flash`,
+ ).toEqual([]);
+}
+
+test.describe.serial("Infrastructure and workloads resource coherence", () => {
+ test.setTimeout(180_000);
+
+ test.afterAll(async ({ browser }) => {
+ if (mockModeWasEnabled === null) return;
+
+ const context = await browser.newContext();
+ const page = await context.newPage();
+ try {
+ const current = await getMockMode(page);
+ if (current.enabled !== mockModeWasEnabled) {
+ await setMockMode(page, mockModeWasEnabled);
+ }
+ } finally {
+ await context.close();
+ }
+ });
+
+ test("keeps a Proxmox workload visible from its Infrastructure parent through scoped Workloads routing", async ({
+ page,
+ }, testInfo) => {
+ test.skip(
+ testInfo.project.name.startsWith("mobile-"),
+ "Desktop runtime proof",
+ );
+
+ await ensureAuthenticated(page);
+ await ensureMockModeEnabled(page);
+
+ const resources = await readResources(page);
+ const agents = resources.filter((resource) => resource.type === "agent");
+ const workload = resources.find(
+ (resource) =>
+ isProxmoxWorkload(resource) &&
+ Boolean(resource.parentId) &&
+ Boolean(resource.proxmox?.nodeName) &&
+ Boolean(resource.proxmox?.instance) &&
+ Boolean(resource.proxmox?.vmid),
+ );
+
+ expect(
+ workload,
+ "Expected mock/runtime data to include a parented Proxmox workload",
+ ).toBeDefined();
+ const selectedWorkload = workload as APIResource;
+ const parent = agents.find(
+ (resource) => resource.id === selectedWorkload.parentId,
+ );
+
+ expect(
+ parent,
+ `Expected Proxmox workload ${selectedWorkload.id} to resolve to one Infrastructure parent`,
+ ).toBeDefined();
+
+ const selectedParent = parent as APIResource;
+ const duplicateParentIds = agents.filter(
+ (resource) => resource.id === selectedParent.id,
+ );
+ expect(
+ duplicateParentIds,
+ `Expected parent ${selectedParent.id} to appear once in the resource API`,
+ ).toHaveLength(1);
+
+ const parentName = (
+ selectedWorkload.parentName ||
+ selectedParent.name ||
+ selectedParent.id
+ ).trim();
+ const nodeName = (selectedWorkload.proxmox?.nodeName ?? "").trim();
+ const workloadRouteId = buildProxmoxWorkloadRouteId(selectedWorkload);
+ const nodeFilterValue = buildProxmoxNodeFilterValue(selectedWorkload);
+
+ await page.goto(
+ `/infrastructure?source=proxmox-pve&q=${encodeURIComponent(nodeName)}`,
+ {
+ waitUntil: "domcontentloaded",
+ },
+ );
+
+ await expect(page.getByTestId("infrastructure-page")).toBeVisible();
+ await expect(
+ page.getByTestId("infrastructure-table-surface"),
+ ).toContainText(parentName);
+
+ const parentRows = page.locator(
+ `[data-testid="infrastructure-table-surface"] [data-summary-series-id="${cssAttrValue(selectedParent.id)}"]`,
+ );
+ await expect(
+ parentRows,
+ `Expected Infrastructure to render parent ${parentName} exactly once`,
+ ).toHaveCount(1);
+
+ await assertSurfaceDoesNotBlank(
+ page,
+ "infrastructure-table-surface",
+ 3_000,
+ );
+ await expect(
+ parentRows,
+ `Expected Infrastructure parent ${parentName} to remain visible`,
+ ).toHaveCount(1);
+
+ await page.goto(
+ `/workloads?type=${encodeURIComponent(selectedWorkload.type ?? "")}` +
+ `&platform=proxmox-pve&agent=${encodeURIComponent(nodeFilterValue)}` +
+ `&resource=${encodeURIComponent(workloadRouteId)}`,
+ { waitUntil: "domcontentloaded" },
+ );
+
+ await expect(page.getByTestId("workloads-table-surface")).toBeVisible();
+ await expect
+ .poll(() => new URL(page.url()).searchParams.get("platform"))
+ .toBe("proxmox-pve");
+ await expect
+ .poll(() => new URL(page.url()).searchParams.get("agent"))
+ .toBe(nodeFilterValue);
+ await expect(
+ page.getByRole("button", { name: /Platform:\s*PVE/ }),
+ ).toBeVisible();
+ await expect(
+ page.getByRole("button", { name: new RegExp(`Node:\\s*${nodeName}`) }),
+ ).toBeVisible();
+
+ const workloadRows = page.locator(
+ `tr[data-guest-id="${cssAttrValue(workloadRouteId)}"]`,
+ );
+ await expect(
+ workloadRows,
+ `Expected Workloads to render ${selectedWorkload.name || workloadRouteId} from parent ${parentName}`,
+ ).toHaveCount(1);
+
+ await assertSurfaceDoesNotBlank(page, "workloads-table-surface", 5_000);
+ await expect(workloadRows).toHaveCount(1);
+ });
+});