fix(ui): связывать OSPF узлы по подтверждённым ID
This commit is contained in:
1 parent
7a68ae8184
commit
259c5c3014
16 files changed
+123
-41
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { test,expect } from "@playwright/test"
|
||||
test("OSPF: ссылка main не связывает устройства, фактический Router ID связывает",async({page})=>{
|
||||
let known=false
|
||||
const host=(id:number)=>({serverId:id,serverName:"Роутер "+id,serverSite:"",serverCountry:"RU"})
|
||||
await page.route("**/health",r=>r.fulfill({json:{ok:true}}))
|
||||
await page.route("**/api/**",r=>{const path=new URL(r.request().url()).pathname;return r.fulfill({json:path==="/api/ospf/catalog"?{neighbors:[1,2].map(id=>({...host(id),id:"n",address:"192.0.2."+(3-id),routerId:"192.0.2."+(3-id),instance:"default",area:"backbone",areaId:"0.0.0.0",interface:"ether1",state:"Full",uptime:"1h",priority:1,stateChanges:0})),interfaces:[],instances:[1,2].map(id=>({...host(id),id:"i",name:"default",routerId:id===2&&!known?"main":"192.0.2."+id,version:2,disabled:false,inactive:false,redistribute:""})),bfdSessions:[],routes:[],failures:[]}:path==="/api/servers"?[1,2].map(id=>({id,name:"Роутер "+id,host:"192.0.2."+id,enabled:true,status:null,country:"RU"})):path==="/api/auth/config"?{required:false}:{}})})
|
||||
await page.goto("/ospf?tab=neighbors")
|
||||
const nodes=page.locator("[data-ospf-node]")
|
||||
await expect(nodes).toHaveCount(3)
|
||||
await expect(page.locator('[data-ospf-node="remote-192.0.2.2"]')).toBeVisible()
|
||||
known=true;await page.getByRole("button",{name:"Обновить",exact:true}).click()
|
||||
await expect(nodes).toHaveCount(2)
|
||||
await page.locator('[data-ospf-node="2"] > circle[r="34"]').click()
|
||||
const details=page.getByRole("region",{name:"Детали узла OSPF"});await expect(details).toContainText("192.0.2.2")
|
||||
await expect(page).toHaveURL(/node=2/)
|
||||
})
|
||||
@@ -2,22 +2,27 @@ import { test, expect } from "@playwright/test"
|
||||
test("OSPF/BFD: неизвестные значения отличаются от наблюдаемого нуля", async ({ page }) => {
|
||||
const host = { serverId: 1, serverName: "Роутер", serverSite: "", serverCountry: "RU" }
|
||||
const neighbor = { ...host, id: "n", address: "192.0.2.2", routerId: "192.0.2.2", instance: "default", area: "backbone", areaId: "0.0.0.0", interface: "ether1", state: "full", uptime: null, stateChanges: null, priority: null }
|
||||
const bfd = { ...host, id: "b", localAddr: "192.0.2.1", remoteAddr: "192.0.2.2", interface: "ether1", state: "up", uptime: null, multihop: false, multiplier: null, txInterval: null, rxInterval: null, holdTime: null, packetsRx: null, packetsTx: null, stateChanges: null }
|
||||
const bfd = { ...host, id: "b", localAddr: "192.0.2.1", remoteAddr: "192.0.2.2", interface: "ether1", state: "up", uptime: null, multihop: null, multiplier: null, txInterval: null, rxInterval: null, holdTime: null, packetsRx: null, packetsTx: null, stateChanges: null }
|
||||
let zero = false
|
||||
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
|
||||
await page.route("**/api/**", r => { const path=new URL(r.request().url()).pathname; return r.fulfill({ json: path === "/api/ospf/catalog" ? { neighbors: [{ ...neighbor, ...(zero ? { priority: 0, stateChanges: 0 } : {}) }], bfdSessions: [{ ...bfd, ...(zero ? { multiplier: 0, txInterval: 0, rxInterval: 0.001, holdTime: 0, packetsRx: 0, packetsTx: 0, stateChanges: 0 } : {}) }], interfaces: [], instances: [], routes: [], failures: [] } : path === "/api/servers" ? [{ id: 1, name: "Роутер", host: "192.0.2.1", enabled: true, country: "RU", status: null }] : path === "/api/auth/config" ? { required: false } : {} }) })
|
||||
await page.route("**/api/**", r => { const path=new URL(r.request().url()).pathname; return r.fulfill({ json: path === "/api/ospf/catalog" ? { neighbors: [{ ...neighbor, ...(zero ? { priority: 0, stateChanges: 0 } : {}) }], bfdSessions: [{ ...bfd, ...(zero ? { multihop: false, multiplier: 0, txInterval: 0, rxInterval: 0.001, holdTime: 0, packetsRx: 0, packetsTx: 0, stateChanges: 0 } : {}) }], interfaces: [], instances: [], routes: [{ ...host, id:"r", destination:"192.0.2.0/24", type:zero?"O IA":"Unknown", cost:zero?0:null, nextHop:"192.0.2.2", via:"ether1", area:"backbone" }], failures: [] } : path === "/api/servers" ? [{ id: 1, name: "Роутер", host: "192.0.2.1", enabled: true, country: "RU", status: null }] : path === "/api/auth/config" ? { required: false } : {} }) })
|
||||
await page.goto("/ospf")
|
||||
await page.getByRole("button", { name: "Соседи", exact: true }).click()
|
||||
const cells=page.locator("tr[data-row-id]").locator("td")
|
||||
await expect(cells.last()).toHaveText("—")
|
||||
await page.getByRole("button", { name: "BFD", exact: true }).click()
|
||||
await expect(page.getByText("Режим неизвестен",{exact:true})).toBeVisible()
|
||||
await expect(cells.nth(6)).toHaveText("— / —")
|
||||
for (const index of [7,8,9,10,11]) await expect(cells.nth(index)).toHaveText("—")
|
||||
await expect(page.getByText("Общее число полученных пакетов неизвестно.", { exact: false })).toBeVisible()
|
||||
await page.getByRole("button",{name:"Маршруты",exact:true}).click()
|
||||
await expect(cells.nth(1)).toHaveText("Тип неизвестен")
|
||||
await page.getByRole("button",{name:"BFD",exact:true}).click()
|
||||
zero=true
|
||||
await page.getByRole("button", { name: "Обновить", exact: true }).click()
|
||||
await expect(cells.nth(6)).toHaveText("0ms / 0.001ms")
|
||||
await expect(cells.nth(7)).toHaveText("0ms")
|
||||
await expect(page.getByText("Режим неизвестен",{exact:true})).toHaveCount(0)
|
||||
for (const index of [8,9,10,11]) await expect(cells.nth(index)).toHaveText("0")
|
||||
await expect(page.getByText("Всего получено: 0 пакетов.", { exact: false })).toBeVisible()
|
||||
await page.getByRole("button", { name: "Соседи", exact: true }).click()
|
||||
|
||||
Reference in new issue
Block a user