31 lines
3.1 KiB
TypeScript
31 lines
3.1 KiB
TypeScript
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: 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 ? { 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()
|
|
await expect(cells.last()).toHaveText("0")
|
|
})
|