From 0cd263537f97ef4822be4d35cbeb87abbb81d94a Mon Sep 17 00:00:00 2001 From: Pouzor Date: Sun, 8 Mar 2026 12:01:46 +0100 Subject: [PATCH] test: cover custom_icon persistence and cctv icon presence --- backend/tests/test_canvas.py | 19 +++++++++++++++++++ .../src/utils/__tests__/nodeIcons.test.ts | 1 + 2 files changed, 20 insertions(+) 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 }) })