fix(ui): ограничить списки деталей OSPF без потери данных
This commit is contained in:
1 parent
8d86c5cbb0
commit
086f118204
9 files changed
+110
-11
No files matched your search
@@ -144,3 +144,53 @@ test("OSPF: тысяча параллельных связей не обходи
|
||||
await expect(page.locator("[data-ospf-node]")).toHaveCount(2)
|
||||
expect(await page.getByRole("group", { name: "Топология OSPF", exact: true }).locator("*").count()).toBeLessThan(200)
|
||||
})
|
||||
|
||||
|
||||
test("OSPF детали1000: полные списки, поиск, страницы и сохранение узла", async ({ page }, info) => {
|
||||
test.setTimeout(90000)
|
||||
const host = { serverId: 1, serverName: "Роутер 1", serverSite: "", serverCountry: "RU" }
|
||||
let 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: [] })
|
||||
|
||||
let currentInterfaces = interfaces
|
||||
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/auth/config" ? { required: false } : path === "/api/ospf/catalog" ? { ...catalog, neighbors, interfaces: currentInterfaces } : path === "/api/servers" ? [{ id: 1, name: "Роутер 1", host: "192.0.2.1", enabled: true, country: "RU", status: null }] : {} })
|
||||
})
|
||||
await page.goto("/ospf?tab=neighbors&server=1&node=1&keep=1")
|
||||
const details = page.getByRole("region", { name: "Детали узла OSPF" })
|
||||
const peers = details.getByRole("region", { name: "Соседи узла OSPF", exact: true })
|
||||
const ports = details.getByRole("region", { name: "Интерфейсы узла OSPF", exact: true })
|
||||
const peerRows = peers.locator(':scope > div').last().locator(':scope > div')
|
||||
const portRows = ports.locator(':scope > div').last().locator(':scope > div')
|
||||
await expect(peerRows).toHaveCount(50); await expect(portRows).toHaveCount(50)
|
||||
await expect(peers.getByRole("status")).toContainText("1–50 из 1000. Всего 1000")
|
||||
const profile = { neighbors: neighbors.length, interfaces: interfaces.length, renderedNeighbors: await peerRows.count(), renderedInterfaces: await portRows.count(), panelNodes: await details.locator("*").count(), pageNodes: await page.locator("*").count() }
|
||||
console.log("OSPF detail", JSON.stringify(profile)); writeFileSync(info.outputPath("ospf-detail-profile.json"), JSON.stringify(profile, null, 2))
|
||||
expect(profile.pageNodes).toBeLessThan(5000)
|
||||
await peers.getByRole("button", { name: "Следующая страница: Соседи узла OSPF", exact: true }).click()
|
||||
await expect(peerRows.first()).toContainText("ether51")
|
||||
await page.getByRole("button", { name: "Обновить", exact: true }).click()
|
||||
await expect(peers.getByRole("status")).toContainText("51–100 из 1000")
|
||||
const peerSearch = peers.getByRole("textbox", { name: "Поиск: Соседи узла OSPF" })
|
||||
await peerSearch.fill("ether1000"); await expect(peerRows).toHaveCount(1); await expect(peerRows.first()).toContainText("10.3.231.1")
|
||||
const portSearch = ports.getByRole("textbox", { name: "Поиск: Интерфейсы узла OSPF" })
|
||||
await portSearch.fill("ether1000"); await expect(portRows).toHaveCount(1); await expect(portRows.first()).toContainText("cost 1000")
|
||||
await portSearch.fill("несуществующий"); await expect(ports).toContainText("По вашему запросу ничего не найдено")
|
||||
await peerSearch.fill(""); await portSearch.fill("")
|
||||
await page.setViewportSize({ width: 320, height: 1000 }); await details.evaluate(el => el.scrollIntoView({ block: "start" }))
|
||||
for (const button of await details.locator("button").all()) expect((await button.boundingBox())!.height).toBeGreaterThanOrEqual(44)
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(320)
|
||||
await page.addStyleTag({ content: "nextjs-portal{display:none!important}" })
|
||||
await page.screenshot({ path: info.outputPath("ospf-large-detail-320.png"), animations: "disabled" })
|
||||
await page.addScriptTag({ content: axe.source })
|
||||
expect((await page.evaluate(async () => (window as unknown as { axe: typeof axe }).axe.run(document.querySelector('[aria-label="Детали узла OSPF"]')!, { runOnly: { type: "tag", values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"] } }))).violations.map(v => ({ id: v.id, nodes: v.nodes.map(n => n.target) }))).toEqual([])
|
||||
await peers.getByRole("button", { name: "Следующая страница: Соседи узла OSPF", exact: true }).click()
|
||||
neighbors = neighbors.slice(0, 1); currentInterfaces = interfaces.slice(0, 1)
|
||||
await page.getByRole("button", { name: "Обновить", exact: true }).click()
|
||||
await expect(peerRows).toHaveCount(1); await expect(portRows).toHaveCount(1)
|
||||
await expect(peerRows.first()).toContainText("ether1")
|
||||
await expect(page).toHaveURL(url => url.searchParams.get("node") === "1" && url.searchParams.get("keep") === "1")
|
||||
})
|
||||
Reference in new issue
Block a user