chore(ui): зафиксировать профиль большой топологии OSPF

This commit is contained in:
Denozordec committed 2026-10-04 16:58:53 +07:00
1 parent ab56225a1a
commit 2554c3572a
8 files changed
+55 -1

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { test, expect } from "@playwright/test"
import { writeFileSync } from "node:fs"
import { ospfCatalogSchema } from "../../lib/ospf-response"
test("OSPF1000 соседей: профиль всего экрана с topology", async ({ page }, info) => {
test.setTimeout(90000)
const host = { serverId: 1, serverName: "Роутер 1", serverSite: "", serverCountry: "RU" }
const neighbors = Array.from({ length: 1000 }, (_, i) => ({ ...host, id: `n${i + 1}`, address: `10.${Math.floor(i / 256)}.${i % 256}.1`, routerId: `10.${Math.floor(i / 256)}.${i % 256}.1`, instance: "default", area: "backbone", areaId: "0.0.0.0", interface: `ether${i + 1}`, state: "Full", uptime: "1h", stateChanges: 0, priority: 1 }))
const interfaces = neighbors.map((n, i) => ({ ...host, id: `i${i + 1}`, instance: "default", area: "backbone", areaId: "0.0.0.0", interface: n.interface, cost: i + 1, type: "broadcast", disabled: false, inactive: false, priority: 1, helloInterval: 10, deadInterval: 40, useBfd: false }))
const catalog = ospfCatalogSchema.parse({ neighbors, interfaces, instances: [{ ...host, id: "instance1", name: "default", routerId: "192.0.2.1", version: 2, disabled: false, inactive: false, redistribute: "" }], bfdSessions: [], routes: [], failures: [] })
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
await page.route("**/api/**", r => {
const p = new URL(r.request().url()).pathname
return r.fulfill({ json: p === "/api/auth/config" ? { required: false } : p === "/api/ospf/catalog" ? catalog : p === "/api/servers" ? [{ id: 1, name: "Роутер 1", host: "192.0.2.1", enabled: true, country: "RU", status: null }] : {} })
})
await page.setViewportSize({ width: 1440, height: 1000 })
const start = Date.now(); await page.goto("/ospf?tab=neighbors&server=1&keep=1")
const rows = page.locator("tr[data-row-id]")
await expect(rows).toHaveCount(1000)
await expect(page.locator("[data-ospf-node]")).toHaveCount(1001)
const profile = { count: neighbors.length, bytes: Buffer.byteLength(JSON.stringify(catalog)), rows: await rows.count(), graphNodes: await page.locator("[data-ospf-node]").count(), svgNodes: await page.getByRole("group", { name: "Топология OSPF", exact: true }).locator("*").count(), pageNodes: await page.locator("*").count(), readyMs: Date.now() - start }
console.log("OSPF neighbors baseline", JSON.stringify(profile))
writeFileSync(info.outputPath("ospf-neighbors-profile.json"), JSON.stringify(profile, null, 2))
await info.attach("profile", { body: JSON.stringify(profile), contentType: "application/json" })
await page.addStyleTag({ content: "nextjs-portal{display:none!important}" })
await page.screenshot({ path: info.outputPath("ospf-neighbors-baseline-1440.png"), animations: "disabled" })
await page.setViewportSize({ width: 320, height: 1000 })
console.log("OSPF neighbors baseline mobileWidth", await page.evaluate(() => document.documentElement.scrollWidth))
await page.screenshot({ path: info.outputPath("ospf-neighbors-baseline-320.png"), animations: "disabled" })
})