Skip to content

Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring

fix(inventory): search a device by the name shown on its card

Pouzore60204589ac2
diff --git a/frontend/src/components/modals/DeviceInventoryModal.tsx b/frontend/src/components/modals/DeviceInventoryModal.tsx
index ddfaaf8..0750c32 100644
--- a/frontend/src/components/modals/DeviceInventoryModal.tsx
+++ b/frontend/src/components/modals/DeviceInventoryModal.tsx
@@ -237,7 +237,7 @@ export function DeviceInventoryModal({ open, onClose, highlightId, initialStatus
if (rackableOnly && !isRackable(d)) return false
if (q) {
const hay = [
- d.friendly_name, d.hostname, d.ip, d.mac, d.ieee_address, d.vendor, d.model,
+ d.label, d.friendly_name, d.hostname, deviceType(d), d.ip, d.mac, d.ieee_address, d.vendor, d.model,
...d.services.map((s) => s.service_name),
].filter(Boolean).join(' ').toLowerCase()
if (!hay.includes(q)) return false
diff --git a/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx b/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx
index 6b60897..88ad974 100644
--- a/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx
+++ b/frontend/src/components/modals/__tests__/DeviceInventoryModal.test.tsx
@@ -212,6 +212,28 @@ describe('DeviceInventoryModal', () => {
expect(screen.getByTestId('pending-card-dev-b')).toBeInTheDocument()
})
+ it('finds a device by the curated label shown on its card', async () => {
+ // Regression #522: a canvas-imported device carries only `label` — no
+ // hostname or friendly_name — and searching its visible name found nothing.
+ const named = { ...DEVICE_IP, id: 'dev-named', hostname: null, label: 'Router', discovery_source: 'canvas' }
+ mockPending.mockResolvedValue({ data: [DEVICE_IP, named] })
+ render(<DeviceInventoryModal {...baseProps} />)
+ await waitFor(() => expect(screen.getByTestId('pending-card-dev-named')).toBeInTheDocument())
+ fireEvent.change(screen.getByPlaceholderText(/Search/), { target: { value: 'router' } })
+ expect(screen.getByTestId('pending-card-dev-named')).toBeInTheDocument()
+ expect(screen.queryByTestId('pending-card-dev-a')).not.toBeInTheDocument()
+ })
+
+ it('finds a device by its type', async () => {
+ const nas = { ...DEVICE_IP, id: 'dev-nas', hostname: 'box', type: 'nas' }
+ mockPending.mockResolvedValue({ data: [DEVICE_IP, nas] })
+ render(<DeviceInventoryModal {...baseProps} />)
+ await waitFor(() => expect(screen.getByTestId('pending-card-dev-nas')).toBeInTheDocument())
+ fireEvent.change(screen.getByPlaceholderText(/Search/), { target: { value: 'nas' } })
+ expect(screen.getByTestId('pending-card-dev-nas')).toBeInTheDocument()
+ expect(screen.queryByTestId('pending-card-dev-a')).not.toBeInTheDocument()
+ })
+
it('filters by source (zigbee only)', async () => {
render(<DeviceInventoryModal {...baseProps} />)
await waitFor(() => expect(screen.getByTestId('pending-card-dev-a')).toBeInTheDocument())