Skip to content

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

test: cover custom_icon persistence and cctv icon presence

Pouzor0cd263537f97
diff --git a/backend/tests/test_canvas.py b/backend/tests/test_canvas.py
index 615cb2e..d943ee4 100644
--- a/backend/tests/test_canvas.py
+++ b/backend/tests/test_canvas.py
@@ -120,6 +120,25 @@ async def test_save_canvas_persists_edge_custom_color_and_path_style(client: Asy
assert edge["path_style"] == "smooth"
+async def test_save_canvas_persists_custom_icon(client: AsyncClient, headers: dict):
+ n1 = node_payload(custom_icon="cctv")
+ await client.post("/api/v1/canvas/save", json={"nodes": [n1], "edges": [], "viewport": {}}, headers=headers)
+
+ canvas = (await client.get("/api/v1/canvas", headers=headers)).json()
+ assert canvas["nodes"][0]["custom_icon"] == "cctv"
+
+
+async def test_save_canvas_custom_icon_cleared_when_null(client: AsyncClient, headers: dict):
+ n1 = node_payload(custom_icon="cctv")
+ await client.post("/api/v1/canvas/save", json={"nodes": [n1], "edges": [], "viewport": {}}, headers=headers)
+
+ n1_cleared = {**n1, "custom_icon": None}
+ await client.post("/api/v1/canvas/save", json={"nodes": [n1_cleared], "edges": [], "viewport": {}}, headers=headers)
+
+ canvas = (await client.get("/api/v1/canvas", headers=headers)).json()
+ assert canvas["nodes"][0]["custom_icon"] is None
+
+
async def test_save_canvas_requires_auth(client: AsyncClient):
res = await client.post("/api/v1/canvas/save", json={"nodes": [], "edges": [], "viewport": {}})
assert res.status_code == 401
diff --git a/frontend/src/utils/__tests__/nodeIcons.test.ts b/frontend/src/utils/__tests__/nodeIcons.test.ts
index 7824128..d800dd0 100644
--- a/frontend/src/utils/__tests__/nodeIcons.test.ts
+++ b/frontend/src/utils/__tests__/nodeIcons.test.ts
@@ -30,6 +30,7 @@ describe('ICON_REGISTRY', () => {
expect(keys).toContain('anchor') // Portainer
expect(keys).toContain('key') // Vaultwarden
expect(keys).toContain('database') // DB services
+ expect(keys).toContain('cctv') // IP Camera / CCTV
})
})