fix(ui): проверять каталоги дашборда и сохранять неизвестный статус серверов
This commit is contained in:
1 parent
9e0f695684
commit
8f65d1620d
8 files changed
+63
-41
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import assert from "node:assert/strict"
|
||||
import {test} from "node:test"
|
||||
import {parseDashboardServers,parseDashboardProbes} from "./dashboard-readers"
|
||||
const server={id:1,name:"Узел",host:"192.0.2.1",site:"TEST",country:"RU",asn:"64512",type:"exit-node",enabled:true,status:null,latency:null,os:null,model:null,sessions:0}
|
||||
const probe={id:"p1",srcServerId:"1",name:"Проверка",target:"192.0.2.2",filter:"main",rtt:null,loss:100,status:"down",series:[],enabled:true,showOnDashboard:true}
|
||||
test("dashboard server catalog validates identities and keeps unknown status",()=>{
|
||||
assert.equal(parseDashboardServers([server])[0].status,null);assert.deepEqual(parseDashboardServers([]),[])
|
||||
for(const raw of [{},[server,server],[{...server,status:"invalid"}],[{...server,latency:-1}],[{...server,id:0}],[{id:1}]])assert.throws(()=>parseDashboardServers(raw))
|
||||
})
|
||||
test("dashboard probes validate real shape, uniqueness and numeric ranges before publication",()=>{
|
||||
assert.equal(parseDashboardProbes({probes:[probe]}).probes[0].rtt,null);assert.deepEqual(parseDashboardProbes({probes:[]}),{probes:[]})
|
||||
for(const raw of [{},{probes:[probe,probe]},{probes:[{...probe,loss:101}]},{probes:[{...probe,status:"invalid"}]},{probes:[{...probe,series:[null]}]},{probes:[{}]}])assert.throws(()=>parseDashboardProbes(raw))
|
||||
})
|
||||
Reference in new issue
Block a user