34 lines
2.6 KiB
TypeScript
34 lines
2.6 KiB
TypeScript
import { test, expect } from "@playwright/test"
|
|
import { writeFileSync } from "node:fs"
|
|
import { optimizerServersSchema,optimizerRulesSchema } from "../../lib/route-optimizer-response"
|
|
|
|
test("Оптимизатор1000 Community: полный источник",async({page},info)=>{
|
|
test.setTimeout(90000)
|
|
const rules=optimizerRulesSchema.parse({rulesets:[{serverId:"1",rules:Array.from({length:1000},(_,i)=>({id:String(i+1),community:`65001:${String(i+1).padStart(4,"0")}`,communityName:`Сервис ${i+1}`,gateway:"192.0.2.2",gatewayTunnelId:"",description:""}))}]})
|
|
const common = { host: "192.0.2.1", enabled: true, status: "online", latency: 10, country: "RU", site: "TEST", model: "CHR" }
|
|
const servers = optimizerServersSchema.parse([
|
|
{ ...common, id: 1, name: "Домашний роутер", type: "home-router", wanUplinks: Array.from({ length: 1 }, (_, i) => ({ id: `wan${i+1}`, name: `WAN${i+1}`, isp: "ISP", iface: `ether${i+1}`, ip: `198.51.100.${i+1}`, maxDl: 100, maxUl: 100 })) },
|
|
...Array.from({ length: 1 }, (_, i) => ({ ...common, id: i+2, name: `Jump ${i+1}`, type: "jump-host" })),
|
|
])
|
|
|
|
|
|
const writes: string[] = []
|
|
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
|
|
await page.route("**/api/**", r => {
|
|
const path = new URL(r.request().url()).pathname
|
|
|
|
|
|
if (r.request().method() !== "GET" && !path.endsWith("/preview")) writes.push(path)
|
|
return r.fulfill({ json: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? servers : path === "/api/filters/rules" ? rules : path === "/api/uptime/speed-probes" ? { probes: [] } : path === "/api/ospf/catalog" ? { interfaces: [], instances: [], neighbors: [], bfdSessions: [], routes: [], failures: [] } : path.endsWith("/ospf/optimize/preview") ? { serverId: 1, serverName: "Домашний роутер", pingWeight: 60, interfacesTotal: 0, changedCount: 0, unchangedCount: 0, interfaces: [], changes: [] } : {} })
|
|
})
|
|
|
|
|
|
const start=Date.now();await page.goto("/route-optimizer?server=1&keep=1")
|
|
await page.getByRole("button",{name:"BGP community (24)",exact:true}).click()
|
|
const table=page.getByRole("table").filter({hasText:"Community"})
|
|
await expect(table.locator("tr[data-row-id]")).toHaveCount(24)
|
|
const profile={sourceCount:1000,rendered:await table.locator("tr[data-row-id]").count(),tableNodes:await table.locator("*").count(),pageNodes:await page.locator("*").count(),readyMs:Date.now()-start}
|
|
console.log("Optimizer Community",JSON.stringify(profile));writeFileSync(info.outputPath("community-profile.json"),JSON.stringify(profile,null,2))
|
|
expect(writes).toEqual([])
|
|
})
|