test: improve coverage across frontend and backend

Frontend (22 → 37 tests):
- canvasStore: add tests for onNodesChange, onEdgesChange, onConnect,
  addNode with parentId, updateEdge, deleteEdge, setProxmoxContainerMode
  ON/OFF, loadCanvas parent-before-child ordering
- edgeColors: 6 tests for EDGE_DEFAULT_COLORS (all types, hex format, values)

Backend (40 → 80 tests):
- test_canvas (new): load empty canvas, default viewport, save creates/updates/
  deletes nodes+edges, viewport upsert, custom_colors, edge custom_color+path_style,
  auth guard
- test_fingerprint (new): match_port (known, unknown, wrong protocol, banner match,
  banner no-match, no banner), fingerprint_ports (matched, unknown, mixed, empty,
  default protocol), suggest_node_type (proxmox, server, generic, priority)
- test_nodes: update/delete 404, custom_colors CRUD, container_mode CRUD, auth guard
- test_edges: update edge, update/delete 404, custom_color, path_style, auth guard
This commit is contained in:
Pouzor
2026-03-07 15:01:00 +01:00
parent 07d8c4e58b
commit ba91d0f545
6 changed files with 458 additions and 0 deletions
@@ -0,0 +1,35 @@
import { describe, it, expect } from 'vitest'
import { EDGE_DEFAULT_COLORS } from '../edgeColors'
import type { EdgeType } from '@/types'
const EDGE_TYPES: EdgeType[] = ['ethernet', 'wifi', 'iot', 'vlan', 'virtual']
describe('EDGE_DEFAULT_COLORS', () => {
it('has an entry for every EdgeType', () => {
for (const type of EDGE_TYPES) {
expect(EDGE_DEFAULT_COLORS[type]).toBeDefined()
}
})
it('all colors are valid hex strings', () => {
for (const color of Object.values(EDGE_DEFAULT_COLORS)) {
expect(color).toMatch(/^#[0-9a-fA-F]{6}$/)
}
})
it('ethernet default is the dark gray neutral color', () => {
expect(EDGE_DEFAULT_COLORS.ethernet).toBe('#30363d')
})
it('wifi default is cyan', () => {
expect(EDGE_DEFAULT_COLORS.wifi).toBe('#00d4ff')
})
it('iot default is amber', () => {
expect(EDGE_DEFAULT_COLORS.iot).toBe('#e3b341')
})
it('virtual default is muted gray', () => {
expect(EDGE_DEFAULT_COLORS.virtual).toBe('#8b949e')
})
})