diff --git a/frontend-modern/src/features/vmware/VsphereNetworksTable.tsx b/frontend-modern/src/features/vmware/VsphereNetworksTable.tsx index 9b84a2c7a8..0e18f57e9d 100644 --- a/frontend-modern/src/features/vmware/VsphereNetworksTable.tsx +++ b/frontend-modern/src/features/vmware/VsphereNetworksTable.tsx @@ -56,8 +56,23 @@ const VSPHERE_NETWORK_STATUS_OPTIONS: PlatformTableFilterOption asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id; -const networkType = (resource: Resource): string => - asTrimmedString(resource.vmware?.networkType) || '—'; +// vCenter exposes the network type as a raw enum like `STANDARD_PORTGROUP`, +// `DISTRIBUTED_PORTGROUP`, or `OPAQUE_NETWORK`. The Datastores table shows +// raw enums too (NFS41 / VMFS / vSAN) but those are recognizable shorthand +// every vSphere operator already speaks; the network enums are not. Map the +// known ones to the names vCenter itself uses in the UI, and leave any +// unknown future enum value as-is (uppercased) rather than guessing. +const NETWORK_TYPE_LABELS: Record = { + STANDARD_PORTGROUP: 'Standard port group', + DISTRIBUTED_PORTGROUP: 'vDS port group', + OPAQUE_NETWORK: 'NSX network', +}; + +const networkType = (resource: Resource): string => { + const raw = asTrimmedString(resource.vmware?.networkType); + if (!raw) return '—'; + return NETWORK_TYPE_LABELS[raw.toUpperCase()] ?? raw; +}; const compactList = (values: Array): string[] => values.map((value) => asTrimmedString(value)).filter((value): value is string => Boolean(value)); diff --git a/frontend-modern/src/features/vmware/__tests__/VsphereNetworksTable.test.tsx b/frontend-modern/src/features/vmware/__tests__/VsphereNetworksTable.test.tsx index 784e757c98..e865353238 100644 --- a/frontend-modern/src/features/vmware/__tests__/VsphereNetworksTable.test.tsx +++ b/frontend-modern/src/features/vmware/__tests__/VsphereNetworksTable.test.tsx @@ -66,8 +66,11 @@ describe('VsphereNetworksTable', () => { expect(within(table).getByText('Hosts')).toBeInTheDocument(); expect(within(table).getByText('Connected VMs')).toBeInTheDocument(); expect(within(table).queryByRole('columnheader', { name: 'State' })).not.toBeInTheDocument(); - expect(screen.getByText('STANDARD_PORTGROUP')).toBeInTheDocument(); - expect(screen.getByText('DISTRIBUTED_PORTGROUP')).toBeInTheDocument(); + // vCenter's raw enums (STANDARD_PORTGROUP / DISTRIBUTED_PORTGROUP) are + // mapped to operator-friendly labels matching the names vCenter uses + // in its own UI; the raw enum is no longer surfaced. + expect(screen.getByText('Standard port group')).toBeInTheDocument(); + expect(screen.getByText('vDS port group')).toBeInTheDocument(); expect(screen.getByText('esxi-01.lab.local, esxi-02.lab.local')).toBeInTheDocument(); expect(screen.getByText('warehouse-api-01, etl-batch-01')).toBeInTheDocument();