fix(canvas): include MAC property in approved node sent to canvas (#168)
The backend stored the MAC, but the frontend built the approved canvas node locally with properties=[] (non-zigbee) and no mac field. On save, canvas/save upserts every node field from the in-memory canvas, so the empty properties overwrote the DB MAC — the address showed after a no-save reload but vanished once saved. Now both approve paths (single + bulk) attach a MAC property row and the mac field to the node added to the canvas, mirroring the backend build_mac_property. Hidden by default, toggleable from the right panel. - new buildMacProperty util + unit tests - bulk-approve modal test asserts MAC propagation (IP device) and absence for a zigbee device ha-relevant: yes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { buildMacProperty } from '../macProperty'
|
||||
|
||||
describe('buildMacProperty', () => {
|
||||
it('returns a hidden MAC property row for a MAC', () => {
|
||||
expect(buildMacProperty('aa:bb:cc:dd:ee:ff')).toEqual([
|
||||
{ key: 'MAC', value: 'aa:bb:cc:dd:ee:ff', icon: null, visible: false },
|
||||
])
|
||||
})
|
||||
|
||||
it('returns an empty array when MAC is null/undefined/empty', () => {
|
||||
expect(buildMacProperty(null)).toEqual([])
|
||||
expect(buildMacProperty(undefined)).toEqual([])
|
||||
expect(buildMacProperty('')).toEqual([])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user