chore(ui): зафиксировать профиль тысячи карточек оптимизатора

This commit is contained in:
Denozordec committed 2026-10-04 17:53:24 +07:00
1 parent be54666661
commit 7265709b1c
7 files changed
+40 -2

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test"
import { writeFileSync } from "node:fs"
import { optimizerServersSchema } from "../../lib/route-optimizer-response"
test("Оптимизатор1000 домашних устройств: профиль полного экрана", async ({ page }, info) => {
test.setTimeout(90000)
const servers = optimizerServersSchema.parse(Array.from({ length: 1000 }, (_, i) => ({ id: i+1, name: `Домашний роутер ${i+1}`, host: `10.${Math.floor(i/256)}.${i%256}.1`, type: "home-router", country: "RU", site: "MSK", enabled: true, status: null })))
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/servers" ? servers : path === "/api/filters/rules" ? { rulesets: [] } : path === "/api/uptime/speed-probes" ? { probes: [] } : path === "/api/ospf/catalog" ? { interfaces: [], instances: [], neighbors: [], bfdSessions: [], routes: [], failures: [] } : path.endsWith("/ospf/optimize/preview") ? { serverId: 1, serverName: servers[0].name, pingWeight: 60, interfacesTotal: 0, changedCount: 0, unchangedCount: 0, interfaces: [], changes: [] } : {} })
})
const start = Date.now(); await page.goto("/route-optimizer?server=1&keep=1")
const cards = page.getByRole("button", { name: "WAN × JH (0×0)", exact: true })
await expect(cards).toHaveCount(1000)
const profile = { servers: servers.length, bytes: Buffer.byteLength(JSON.stringify(servers)), homeCards: await cards.count(), pageNodes: await page.locator("*").count(), readyMs: Date.now()-start }
console.log("Optimizer homes", JSON.stringify(profile)); writeFileSync(info.outputPath("optimizer-homes-profile.json"), JSON.stringify(profile, null, 2))
await page.addStyleTag({ content: "nextjs-portal{display:none!important}" })
await page.setViewportSize({ width: 320, height: 1000 })
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(320)
await page.screenshot({ path: info.outputPath("optimizer-homes-baseline-320.png"), animations: "disabled" })
})