fix(ui): не подменять неизвестный индекс маршрута нулём

This commit is contained in:
Denozordec committed 2026-09-30 23:27:14 +07:00
1 parent fb70d80220
commit 2cdfa2cb13
6 files changed
+40 -10

No files matched your search

+12 -2
View File
@@ -8,7 +8,7 @@ const servers: OptimizerApiServer[] = (["home-router", "jump-host", "exit-node"]
...(i === 0 ? { wanUplinks: ids.map(id => ({ id: `wan${id}`, name: `WAN${id}`, isp: "ISP", iface: `ether${id}`, ip: `198.51.100.${id}`, maxDl: 100, maxUl: 100 })) } : {}),
}))
async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok") {
async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok", missingExit = false) {
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", route => {
const path = new URL(route.request().url()).pathname
@@ -17,7 +17,7 @@ async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok") {
const interfaces = preview === "empty" ? [] : ids.map(i => ({ id: String(i), interface: `ether${i}`, currentCost: i, optimalCost: 20, score: i, pingMs: i, dlMbps: 100, ulMbps: 50 }))
return route.fulfill({ json: {serverId:1,serverName:"Роутер 1",pingWeight:60,unchangedCount:0, interfaces, changes: interfaces, changedCount: interfaces.length, interfacesTotal: interfaces.length } })
}
return route.fulfill({ json: path === "/api/servers" ? servers
return route.fulfill({ json: path === "/api/servers" ? servers.filter(server => !missingExit || server.type !== "exit-node")
: path === "/api/auth/config" ? { required: false }
: path === "/api/evobgp/settings" ? { enabled: false, baseUrl: "", secretConfigured: false }
: path === "/api/filters/rules" ? { rulesets: [{ serverId: "1", rules: ids.map(i => ({ id: String(i), community: `65001:${i}`, communityName: `Сервис ${i}`, gateway: "192.0.2.2", gatewayTunnelId: "", description: "" })) }] }
@@ -74,3 +74,13 @@ for (const state of ["empty", "error"] as const) {
await expect(page.getByRole("table").filter({ hasText: "Speed (dl/ul)" })).toHaveCount(0)
})
}
test("Оптимизатор: без ExitNode отсутствующие индексы не становятся нулями", async ({page}) => {
await setup(page,"ok",true)
await page.getByRole("button",{name:"BGP community (12)",exact:true}).click()
const grid=page.getByRole("table").filter({hasText:"Community"})
await expect(grid.locator("tr[data-row-id]")).toHaveCount(12)
await expect(grid.getByLabel("Индекс неизвестен")).toHaveCount(24)
await expect(grid).not.toContainText("0 б.")
await expect(grid.getByRole("button",{name:"Симулировать",exact:true})).toHaveCount(0)
})