t32-live-network-level.mjs 1.1 KB

123456789101112
  1. import assert from 'node:assert/strict'
  2. import { toPipeNetwork } from '../../../src/modules/cockpit/domain/pipeNetwork.js'
  3. import { pipeColorKey } from '../../../src/modules/cockpit/domain/pipeVisual.js'
  4. const response=await fetch('http://192.168.110.96:8301/api/cockpit/v1/infrastructure/geometry')
  5. const body=await response.json();assert.equal(response.status,200);assert.equal(body.code,200)
  6. const drainage=toPipeNetwork(body.data).pipes.filter(p=>p.industry==='DRAINAGE')
  7. assert.ok(drainage.length>0)
  8. assert.ok(drainage.every(p=>p.networkLevel===0),'legacy live response defaults to sewage')
  9. assert.ok(drainage.every(p=>pipeColorKey(p)==='SEWAGE'))
  10. const syntheticRain=toPipeNetwork({features:[{geometry:{type:'LineString',coordinates:[[110.39,28.44],[110.3901,28.44]]},properties:{code:'live-contract-1',industry:'DRAINAGE',networkLevel:1,coordinateValidation:{renderable:true}}}]})
  11. assert.equal(pipeColorKey(syntheticRain.pipes[0]),'RAINWATER')
  12. console.log(JSON.stringify({liveDrainage:drainage.length,liveNetworkLevelKeys:drainage.filter(p=>p.networkLevel!==0).length,legacyColor:'SEWAGE',syntheticLevel1Color:'RAINWATER'}))